From 0d7246524a25f6875273d18e38adccca8c8cc74a Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Fri, 4 Jan 2019 16:10:29 -0500 Subject: [PATCH] Restore an event for the main app logs' disk usage https://bugzilla.redhat.com/show_bug.cgi?id=1658670 Although removed in https://github.com/ManageIQ/manageiq/pull/5551 and related appliance PRs, it's quite possible that users could mount their own disk at this moint point and would want to monitor for this event. It's trivial processing to skip it if they don't have a disk mounted at this location. The description of the event needed to be changed to include the full log path to make it less ambiguous with the other "log" disk usage events. --- .../miq_server/environment_management.rb | 19 ++++++------ db/fixtures/miq_event_definitions.csv | 1 + .../miq_server/environment_manager_spec.rb | 29 ++++++++++++++----- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/app/models/miq_server/environment_management.rb b/app/models/miq_server/environment_management.rb index 1505d098b9c8..37bbc5243a37 100644 --- a/app/models/miq_server/environment_management.rb +++ b/app/models/miq_server/environment_management.rb @@ -101,15 +101,16 @@ def check_disk_usage(disks) disks.each do |disk| next unless disk[:used_bytes_percent].to_i > threshold disk_usage_event = case disk[:mount_point].chomp - when '/' then 'evm_server_system_disk_high_usage' - when '/boot' then 'evm_server_boot_disk_high_usage' - when '/home' then 'evm_server_home_disk_high_usage' - when '/var' then 'evm_server_var_disk_high_usage' - when '/var/log' then 'evm_server_var_log_disk_high_usage' - when '/var/log/audit' then 'evm_server_var_log_audit_disk_high_usage' - when '/var/www/miq_tmp' then 'evm_server_miq_tmp_disk_high_usage' - when '/tmp' then 'evm_server_tmp_disk_high_usage' - when %r{lib/pgsql} then 'evm_server_db_disk_high_usage' + when '/' then 'evm_server_system_disk_high_usage' + when '/boot' then 'evm_server_boot_disk_high_usage' + when '/home' then 'evm_server_home_disk_high_usage' + when '/var' then 'evm_server_var_disk_high_usage' + when '/var/log' then 'evm_server_var_log_disk_high_usage' + when '/var/log/audit' then 'evm_server_var_log_audit_disk_high_usage' + when '/var/www/miq/vmdb/log' then 'evm_server_log_disk_high_usage' + when '/var/www/miq_tmp' then 'evm_server_miq_tmp_disk_high_usage' + when '/tmp' then 'evm_server_tmp_disk_high_usage' + when %r{lib/pgsql} then 'evm_server_db_disk_high_usage' end next unless disk_usage_event diff --git a/db/fixtures/miq_event_definitions.csv b/db/fixtures/miq_event_definitions.csv index ad780dab208c..2f89c275467c 100644 --- a/db/fixtures/miq_event_definitions.csv +++ b/db/fixtures/miq_event_definitions.csv @@ -21,6 +21,7 @@ evm_server_home_disk_high_usage,Server High /home Disk Usage,Default,evm_operati evm_server_var_disk_high_usage,Server High /var Disk Usage,Default,evm_operations evm_server_var_log_disk_high_usage,Server High /var/log Disk Usage,Default,evm_operations evm_server_var_log_audit_disk_high_usage,Server High /var/log/audit Disk Usage,Default,evm_operations +evm_server_log_disk_high_usage,Server High /var/www/miq/vmdb/log Disk Usage,Default,evm_operations evm_server_miq_tmp_disk_high_usage,Server High Temp Storage Disk Usage,Default,evm_operations evm_server_tmp_disk_high_usage,Server High /tmp Disk Usage,Default,evm_operations evm_server_db_disk_high_usage,Server High DB Disk Usage,Default,evm_operations diff --git a/spec/models/miq_server/environment_manager_spec.rb b/spec/models/miq_server/environment_manager_spec.rb index a8de103f1959..ef10aaea96f9 100644 --- a/spec/models/miq_server/environment_manager_spec.rb +++ b/spec/models/miq_server/environment_manager_spec.rb @@ -97,13 +97,28 @@ expect(MiqQueue.count).to eql 0 end - it "database disk exceeds usage" do - disks = [{:used_bytes_percent => 85, :mount_point => '/var/lib/pgsql'}] - expect(@miq_server.check_disk_usage(disks)) - queue = MiqQueue.first - - expect(queue.args[1]).to eql 'evm_server_db_disk_high_usage' - expect(queue.args[2][:event_details]).to include disks.first[:mount_point] + ['/var/lib/pgsql', 'evm_server_db_disk_high_usage', + '/var/www/miq/vmdb/log', 'evm_server_log_disk_high_usage', + '/' , 'evm_server_system_disk_high_usage', + '/boot', 'evm_server_boot_disk_high_usage', + '/home', 'evm_server_home_disk_high_usage', + '/var', 'evm_server_var_disk_high_usage', + '/var/log', 'evm_server_var_log_disk_high_usage', + '/var/log/audit', 'evm_server_var_log_audit_disk_high_usage', + '/var/www/miq/vmdb/log', 'evm_server_log_disk_high_usage', + '/var/www/miq_tmp', 'evm_server_miq_tmp_disk_high_usage', + '/tmp', 'evm_server_tmp_disk_high_usage' + ].each_slice(2) do |path, event| + it "raises an event when disk exceeds usage for #{path}" do + disks = [{:used_bytes_percent => 85, :mount_point => path}] + expect(@miq_server.check_disk_usage(disks)) + expect(MiqQueue.count).to eql(1) + queue = MiqQueue.first + + expect(queue.method_name).to eql("raise_evm_event") + expect(queue.args[1]).to eql(event) + expect(queue.args[2][:event_details]).to include disks.first[:mount_point] + end end end end