-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3287cd4
commit 23c7456
Showing
4 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# copy the file and add the .rb suffix | ||
module Checks | ||
module Report | ||
class Inventory < ForemanMaintain::Report | ||
metadata do | ||
description 'Facts about hosts and the rest of the inventory' | ||
end | ||
|
||
def run | ||
# Hosts | ||
hosts_by_type_count = feature(:foreman_database).query("select type, count(*) from hosts group by type") | ||
|
||
# OS usage | ||
hosts_by_os_count = feature(:foreman_database).query("select max(operatingsystems.name) as os_name, max(operatingsystems.type) as os_type, count(*) as hosts_count from hosts inner join operatingsystems on operatingsystem_id = operatingsystems.id group by operatingsystem_id") | ||
|
||
# Facts usage | ||
facts_by_type = feature(:foreman_database).query("select fact_names.type, min(fact_values.updated_at) as min_update_time, max(fact_values.updated_at) as max_update_time, count(fact_values.id) from fact_values inner join fact_names on fact_name_id = fact_names.id group by fact_names.type") | ||
|
||
# Audits | ||
audits = feature(:foreman_database).query("select count(*), min(created_at), max(created_at) from audits") | ||
|
||
# Parameters | ||
parameters = feature(:foreman_database).query("select type, count(*) from parameters group by type") | ||
|
||
self.data = { | ||
hosts_by_type_count: hosts_by_type_count, | ||
hosts_by_os_count: hosts_by_os_count, | ||
facts_by_type: facts_by_type, | ||
audits: audits, | ||
parameters: parameters, | ||
} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# copy the file and add the .rb suffix | ||
module Checks | ||
module Report | ||
class Platform < ForemanMaintain::Report | ||
metadata do | ||
description 'Report about platform usages' | ||
end | ||
|
||
def run | ||
# General | ||
smart_proxies_count = feature(:foreman_database).query("select count(*) from smart_proxies").first['count'].to_i | ||
smart_proxies_creation_date = feature(:foreman_database).query("select id, created_at from smart_proxies") | ||
|
||
#RBAC | ||
total_users_count = feature(:foreman_database).query("select count(*) from users").first['count'].to_i | ||
non_admin_users_count = feature(:foreman_database).query("select count(*) from users where admin = false").first['count'].to_i | ||
|
||
custom_roles_count = feature(:foreman_database).query("select count(*) from roles where origin = null").first['count'].to_i | ||
taxonomies_counts = feature(:foreman_database).query("select type, count(*) from taxonomies group by type") | ||
|
||
#Settings | ||
modified_settings = feature(:foreman_database).query("select name from settings") | ||
|
||
#User groups | ||
user_groups_count = feature(:foreman_database).query("select count(*) from usergroups").first['count'].to_i | ||
|
||
#User groups | ||
user_groups_count = feature(:foreman_database).query("select count(*) from usergroups").first['count'].to_i | ||
|
||
#Bookmarks | ||
bookmarks = feature(:foreman_database).query("select id, public, owner_id, owner_type from bookmarks") | ||
|
||
#Mail notifications | ||
users_per_mail_notification = feature(:foreman_database).query("select max(mail_notifications.name) as notification_name, count(user_mail_notifications.user_id) from user_mail_notifications inner join mail_notifications on mail_notification_id = mail_notifications.id group by mail_notification_id") | ||
|
||
#Webhooks | ||
#TODO | ||
|
||
self.data = { | ||
smart_proxies_count: proxies_count, | ||
smart_proxies_creation_date: proxies_creation_date, | ||
total_users_count: total_users_count, | ||
non_admin_users_count: non_admin_users_count, | ||
custom_roles_count: custom_roles_count, | ||
taxonomies_counts: taxonomies_counts, | ||
modified_settings: modified_settings, | ||
user_groups_count: user_groups_count, | ||
user_groups_count: user_groups_count, | ||
bookmarks: bookmarks, | ||
users_per_mail_notification: users_per_mail_notification, | ||
} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module Checks | ||
module Report | ||
class Provisioning < ForemanMaintain::Report | ||
metadata do | ||
description 'Provisioning facts about the system' | ||
end | ||
|
||
def run | ||
hosts_in_3_months = sql_count("SELECT COUNT(*) FROM hosts WHERE managed = true AND created_at >= current_date - interval '3 months'") | ||
|
||
# Compute resources | ||
compute_resources_by_type = feature(:foreman_database).query("select type, count(*) from compute_resources group by type") | ||
|
||
hosts_by_compute_resources_type = feature(:foreman_database).query("select compute_resources.type, count(hosts.id) from hosts left outer join compute_resources on compute_resource_id = compute_resources.id group by compute_resources.type") | ||
hosts_by_compute_profile = feature(:foreman_database).query("select max(compute_profiles.name), count(hosts.id) from hosts left outer join compute_profiles on compute_profile_id = compute_profiles.id group by compute_profile_id") | ||
|
||
# Bare metal | ||
nics_by_type_count = feature(:foreman_database).query("select type, count(*) from nics group by type") | ||
discovery_rules_count = sql_count("select count(*) from discovery_rules") | ||
hosts_by_managed_count = feature(:foreman_database).query("select managed, count(*) from hosts group by managed") | ||
|
||
|
||
# Templates | ||
non_default_templates_per_type = feature(:foreman_database).query("select type, count(*) from templates where templates.default = false group by type") | ||
|
||
self.data = { managed_hosts_created_in_last_3_months: hosts_in_3_months } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters