Skip to content

Commit

Permalink
Merge pull request #18340 from jrafanie/restore_app_log_usage_event
Browse files Browse the repository at this point in the history
Restore an event for the main app logs' disk usage

(cherry picked from commit bc8fadc)

https://bugzilla.redhat.com/show_bug.cgi?id=1672698
  • Loading branch information
carbonin authored and simaishi committed Feb 5, 2019
1 parent 0c2fad6 commit eda8fff
Show file tree
Hide file tree
Showing 3 changed files with 34 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
30 changes: 23 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,29 @@
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 eda8fff

Please sign in to comment.