lib/rest-ftp-daemon/api/status.rb in rest-ftp-daemon-0.250.0 vs lib/rest-ftp-daemon/api/status.rb in rest-ftp-daemon-0.250.3

- old
+ new

@@ -6,34 +6,42 @@ desc "Show daemon status" get "/" do mem = GetProcessMem.new status 200 + + # Get counters + counters = $counters.stats + + # Amend counters with legacy attributes + if counters[:jobs].is_a? Hash + counters[:jobs_finished] = counters[:jobs][:finished] || 0 + counters[:jobs_failed] = counters[:jobs][:failed] || 0 + end + if counters[:data].is_a? Hash + counters[:transferred] = counters[:data][:transferred] || 0 + end + + # Generate sutrcture return { hostname: `hostname`.to_s.chomp, version: APP_VER, started: APP_STARTED, uptime: (Time.now - APP_STARTED).round(1), memory_bytes: mem.bytes.to_i, memory_mb: mem.mb.round(0), - stats: $stats.stats, - + status: $queue.jobs_by_status, jobs_count: $queue.jobs_count, - status: $queue.jobs_count_by_status, - # jobs_finished: $queue.jobs_finished, - #rate_by_pool1: $queue.rate_by_pool, + counters: counters, + rate_by_pool: $queue.rate_by(:pool), rate_by_targethost: $queue.rate_by(:targethost), - jobs_by_status: $queue.jobs_by_status, - #rates_per_host: $queue.rates_per_host, - workers: $pool.worker_variables, - #kpis: $queue.queued_ids, } end end end