-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add plan for Puppet agent state summary
- Loading branch information
1 parent
793f801
commit ae1c538
Showing
3 changed files
with
105 additions
and
0 deletions.
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
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
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,63 @@ | ||
# | ||
# @summary provides an overview of all Puppet agents and their error states | ||
# | ||
# @param runinterval the runinterval for the Puppet Agent in minutes. We consider latest reports that are older than runinterval as unresponsive | ||
# | ||
# @author Tim Meusel <tim@bastelfreak.de> | ||
# | ||
plan pe_status_check::agent_state_summary ( | ||
Integer[0] $runinterval = 30, | ||
){ | ||
# a list of all nodes and their latest catalog state | ||
$nodes = puppetdb_query('nodes[certname,latest_report_noop,latest_report_corrective_change,cached_catalog_status,latest_report_status,report_timestamp]{}') | ||
|
||
# check if the last catalog is older than X minutes | ||
$current_timestamp = Integer(Timestamp().strftime('%s')) | ||
$runinterval_seconds = $runinterval * 60 | ||
$unresponsive = $nodes.map |$node| { | ||
$old_timestamp = Integer(Timestamp($node['report_timestamp']).strftime('%s')) | ||
if ($current_timestamp - $old_timestamp) >= $runinterval_seconds { | ||
$node['certname'] | ||
} | ||
}.delete_undef_values | ||
|
||
# all nodes that delivered a report in time | ||
$responsive = $nodes.map{ $node['certname'] } - $unresponsive | ||
|
||
# all nodes that used noop for the last catalog | ||
$noop = $nodes.map |$node| { if ($node['latest_report_noop'] == true){ $node['certname'] } }.delete_undef_values | ||
|
||
# all nodes that reported corrective changes | ||
$corrective_changes = $nodes.map |$node| { if ($node['latest_report_corrective_change'] == true){ $node['certname'] } }.delete_undef_values | ||
|
||
# all nodes that used a cached catalog on the last run | ||
$used_cached_catalog = $nodes.map |$node| { if ($node['cached_catalog_status'] != 'not_used'){ $node['certname'] } }.delete_undef_values | ||
|
||
# all nodes with failed resources in the last report | ||
$failed = $nodes.map |$node| { if ($node['latest_report_status'] == 'failed'){ $node['certname'] } }.delete_undef_values | ||
|
||
# all nodes with changes in the last report | ||
$changed = $nodes.map |$node| { if ($node['latest_report_status'] == 'changed'){ $node['certname'] } }.delete_undef_values | ||
|
||
# all nodes that aren't healthy in any form | ||
$unhealthy = [$noop, $corrective_changes, $used_cached_catalog, $failed, $changed, $unresponsive].flatten.uniq | ||
|
||
# all healthy nodes | ||
$healthy = $nodes.map{ $node['certname'] } - $unhealthy | ||
|
||
$data = { | ||
'noop' => $noop, | ||
'corrective_changes' => $corrective_changes, | ||
'used_cached_catalog' => $used_cached_catalog, | ||
'failed' => $failed, | ||
'changed' => $changed, | ||
'unresponsive' => $unresponsive, | ||
'responsive' => $responsive, | ||
'unhealthy' => $unhealthy, | ||
'unhealthy_counter' => $unhealthy.count, | ||
'healthy' => $healthy, | ||
'healthy_counter' => $healthy.count, | ||
} | ||
|
||
return $data | ||
} |