#!/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"]}" 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=#{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