-
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
Showing
2 changed files
with
34 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,32 @@ | ||
module Checks | ||
module Foreman | ||
class FactsNames < ForemanMaintain::Check | ||
metadata do | ||
label :foreman_fact_names | ||
tags :default | ||
confine do | ||
feature(:foreman_database) | ||
end | ||
description 'Check number of fact names in database' | ||
end | ||
|
||
def run | ||
max = 10_000 | ||
sql = <<-SQL | ||
select fact_values.host_id, count(fact_values.id) from fact_values | ||
group by fact_values.host_id order by count desc limit 1 | ||
SQL | ||
result = feature(:foreman_database).query(sql).first | ||
if result | ||
host_id = result['host_id'] | ||
count = result['count'].to_i | ||
assert(count < max, | ||
"Host (ID #{host_id}) has #{count} fact values which is more than #{max}.\n" \ | ||
'This can cause slow fact processing.', | ||
:warn => true, | ||
:next_steps => [Procedures::KnowledgeBaseArticle.new(:doc => 'many_fact_values')]) | ||
end | ||
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