Aggiunge monitoraggio ops: health check, log scanner, dashboard e notifiche.
Introduce incidenti con dedup, job Sidekiq ogni 3 min, scan log cron, /up/deep, dashboard /admin/ops e push ntfy; include Sentry opzionale e fix test suite. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
39
backend/spec/services/admin/host_metrics_spec.rb
Normal file
39
backend/spec/services/admin/host_metrics_spec.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Admin::HostMetrics do
|
||||
subject(:metrics) { described_class.new }
|
||||
|
||||
describe "#build_disk_usage" do
|
||||
it "costruisce la struttura disco" do
|
||||
result = metrics.send(:build_disk_usage, "/", total: 115_964_116_992, used: 9_388_032_000, free: 106_576_084_992, used_percent: 9.0)
|
||||
|
||||
expect(result[:path]).to eq("/")
|
||||
expect(result[:total_bytes]).to eq(115_964_116_992)
|
||||
expect(result[:used_bytes]).to eq(9_388_032_000)
|
||||
expect(result[:free_bytes]).to eq(106_576_084_992)
|
||||
expect(result[:used_percent]).to eq(9.0)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#disk_usage_for" do
|
||||
it "usa df quando statvfs non è disponibile" do
|
||||
allow(File).to receive(:respond_to?).and_call_original
|
||||
allow(File).to receive(:respond_to?).with(:statvfs).and_return(false)
|
||||
allow(Dir).to receive(:exist?).with("/recordings").and_return(true)
|
||||
allow(metrics).to receive(:disk_usage_via_statvfs).with("/recordings").and_return(nil)
|
||||
allow(metrics).to receive(:disk_usage_via_df).with("/recordings").and_return(
|
||||
path: "/recordings",
|
||||
total_bytes: 100_000,
|
||||
used_bytes: 9_000,
|
||||
free_bytes: 91_000,
|
||||
used_percent: 9.0
|
||||
)
|
||||
allow(metrics).to receive(:shell_out).with(/du -sb/).and_return("1048576\t/recordings\n")
|
||||
|
||||
result = metrics.send(:disk_usage_for, "/recordings")
|
||||
|
||||
expect(result[:total_bytes]).to eq(100_000)
|
||||
expect(result[:dir_size_bytes]).to eq(1_048_576)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user