blob: 251e48c5822dc3eb5f15a2689b2713b606da9f22 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/usr/bin/env ruby
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_repo}}).each do |dir|
crypt_path = "#{crypt_repo}#{dir["Path"]}"
b2_path = "#{b2_repo}/#{dir["Path"]}"
run_start = %x{#{rclone} cat #{crypt_path}/last_run_start}
run_end = File.ready("/media/persistent/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
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#{duration_minutes}"
end
|