Skip to content

Commit

Permalink
Restore an event for the main app logs' disk usage
Browse files Browse the repository at this point in the history
https://bugzilla.redhat.com/show_bug.cgi?id=1658670

Although removed in #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.
  • Loading branch information
jrafanie committed Jan 8, 2019
1 parent 97c8dba commit 0d72465
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
19 changes: 10 additions & 9 deletions app/models/miq_server/environment_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions db/fixtures/miq_event_definitions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 22 additions & 7 deletions spec/models/miq_server/environment_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0d72465

Please sign in to comment.