diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-03-28 17:57:40 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-03-28 17:57:40 -0400 |
commit | 5666a7aa0ac0c1396ac170ceefbbce36d86f24af (patch) | |
tree | 36aa83e23835bc805f7071afc46a8bc71202a0c0 | |
parent | 119c6f6645f660f76d255861296570eca05f0112 (diff) | |
download | puppet-tozt-5666a7aa0ac0c1396ac170ceefbbce36d86f24af.tar.gz puppet-tozt-5666a7aa0ac0c1396ac170ceefbbce36d86f24af.zip |
more accurate rclone measurements
actually track the full amount of space used on the underlying b2 repo
rather than the size of the current data set
-rw-r--r-- | modules/tick/files/plugins/rclone | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/modules/tick/files/plugins/rclone b/modules/tick/files/plugins/rclone index 68b0dc4..757369d 100644 --- a/modules/tick/files/plugins/rclone +++ b/modules/tick/files/plugins/rclone @@ -4,17 +4,20 @@ require 'date' require 'json' rclone = "rclone --config /etc/rclone.conf" +crypt_repo = "crypt:" +b2_repo = "b2:doy-rclone" now = Time.now -JSON.load(%x{#{rclone} lsjson crypt:}).each do |dir| - repo_path = "crypt:#{dir["Path"]}" +JSON.load(%x{#{rclone} lsjson #{crypt_repo}}).each do |dir| + crypt_path = "#{crypt_repo}#{dir["Path"]}" + b2_path = "#{b2_repo}/#{dir["Path"]}" - date = %x{#{rclone} cat #{repo_path}/last_run} - data = JSON.load(%x{#{rclone} size #{repo_path} --json}) + date = %x{#{rclone} cat #{crypt_path}/last_run} + data = JSON.load(%x{#{rclone} size #{b2_path} --b2-versions --json}) ago_s = now - DateTime.iso8601(date).to_time file_size_b = data["bytes"] file_count_n = data["count"] - puts "rclone,location=#{repo_path} days_since_last_run=#{ago_s / 60.0 / 60.0 / 24.0},file_size=#{file_size_b}i,file_count=#{file_count_n}i" + puts "rclone,location=#{crypt_path} days_since_last_run=#{ago_s / 60.0 / 60.0 / 24.0},file_size=#{file_size_b}i,file_count=#{file_count_n}i" end |