Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore an event for the main app logs' disk usage #18340

Merged
merged 1 commit into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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