diff options
author | Jesse Luehrs <doy@tozt.net> | 2024-03-03 08:45:24 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2024-03-03 08:45:24 -0500 |
commit | 367708ef171d7914854c68f7d7a32217683bad6d (patch) | |
tree | 713dbcc6ef91ff37e3c10a6afa201c82579af9a7 /modules/tick/files/plugins/rclone | |
parent | 191355452eb47222ab98148f0215dd6724852377 (diff) | |
download | puppet-tozt-367708ef171d7914854c68f7d7a32217683bad6d.tar.gz puppet-tozt-367708ef171d7914854c68f7d7a32217683bad6d.zip |
improve rclone metrics a bit
Diffstat (limited to 'modules/tick/files/plugins/rclone')
-rw-r--r-- | modules/tick/files/plugins/rclone | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/modules/tick/files/plugins/rclone b/modules/tick/files/plugins/rclone index c26a190..0292512 100644 --- a/modules/tick/files/plugins/rclone +++ b/modules/tick/files/plugins/rclone @@ -12,15 +12,19 @@ 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 #{crypt_path}/last_run} - ago_s = now - DateTime.iso8601(date).to_time + run_start = %x{#{rclone} cat #{crypt_path}/last_run_start} + run_end = %x{#{rclone} cat #{crypt_path}/last_run_end} + ago_s = now - DateTime.iso8601(run_end).to_time + dur_s = DateTime.iso8601(run_end).to_time - DateTime.iso8601(run_start).to_time + if dur_s > 0 + duration_minutes = ",duration_minutes=#{dur_s / 60.0}" + else + duration_minutes = "" + end - # rclone size uses quite a lot of backblaze api calls, which turns out to be - # super expensive - # data = JSON.load(%x{#{rclone} size #{b2_path} --b2-versions --json}) - # file_size_b = data["bytes"] - # file_count_n = data["count"] + data = JSON.load(%x{#{rclone} size #{b2_path} --b2-versions --json --fast-list}) + file_size_b = data["bytes"] + file_count_n = data["count"] - # 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" - puts "rclone,location=#{crypt_path} days_since_last_run=#{ago_s / 60.0 / 60.0 / 24.0}" + 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#{duration_minutes}" end |