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

Schedule a daily count of managed VMs and print result to audit log. #19830

Merged
merged 4 commits into from
Feb 14, 2020
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
4 changes: 4 additions & 0 deletions app/models/miq_schedule_worker/jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def miq_server_worker_log_status
queue_work(:class_name => "MiqWorker", :method_name => "log_status_all", :task_id => "log_status", :server_guid => MiqServer.my_guid, :priority => MiqQueue::HIGH_PRIORITY)
end

def miq_server_audit_managed_resources
queue_work(:class_name => "MiqServer", :method_name => "audit_managed_resources", :task_id => "audit_managed_resources", :server_guid => MiqServer.my_guid)
end

def vmdb_database_connection_log_statistics
queue_work(:class_name => "VmdbDatabaseConnection", :method_name => "log_statistics", :server_guid => MiqServer.my_guid)
end
Expand Down
5 changes: 5 additions & 0 deletions app/models/miq_schedule_worker/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ def schedules_for_all_roles
) { enqueue(:miq_server_queue_update_registration_status) }
end

# Schedule - Add audit log entry for total number of vms managed by system.
scheduler.schedule_every(
worker_settings[:audit_managed_resources],
:tags =>[:miq_server_audit_managed_resources, schedule_category]
) { enqueue(:miq_server_audit_managed_resources) }
@schedules[:all]
end

Expand Down
14 changes: 14 additions & 0 deletions app/models/miq_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,20 @@ def self.zone_is_modifiable?
Zone.visible.in_my_region.count > 1
end

def self.audit_managed_resources
total_vms = 0
total_hosts = 0

ExtManagementSystem.all.each do |e|
vms = e.all_vms_and_templates.count
hosts = e.all_hosts.count
total_vms += vms
total_hosts += hosts
end
totals = {"vms" => total_vms, "hosts" => total_hosts}
$audit_log.info("Under Management: #{totals.to_json}")
end

private

def zone_unchanged_in_pods
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,7 @@
:queue_timeout: 20.minutes
:heartbeat_thread_shutdown_timeout: 10.seconds
:schedule_worker:
:audit_managed_resources: 1.days
:container_entities_purge_interval: 1.day
:binary_blob_purge_interval: 1.hour
:authentication_check_interval: 1.hour
Expand Down