Skip to content
This repository was archived by the owner on Jun 17, 2020. It is now read-only.
Open
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ object CheckCommand "puppetdb-node" {
"--critical" = "$crit_lag$"
"--warnfails" = "$warn_fails$"
"--critfails" = "$crit_fails$"
"--warnnoops" = "$warn_noops$"
"--critnoops" = "$crit_noops$"
}

vars.node_name = "$host_name$"
vars.warn_lag = 45
vars.crit_lag = 120
vars.warn_fails = 1
vars.crit_fails = 1
vars.warn_noops = 1
vars.crit_noops = 999
}

apply Service "puppet agent" {
Expand Down
35 changes: 33 additions & 2 deletions check_puppetdb_nodes
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ my $np = Monitoring::Plugin->new(
usage => "Usage: %s [ -H|--hostname=<hostname>] "
. "[ -p|--port=<port> ] [-s] [ -w|--warning=<minutes> ] "
. "[ -c|--critical=<minutes> ] [ -W|--warnfails=<num> ] "
. "[ --critnoops=<num> ] [ --warnnoops=<num> ] "
. "[ -C|--critfails=<num> ] [ -n|--node=<node> ]"
. "[ -a|--apiversion=<num> ]",
shortname => 'Check last node runs from PuppetDB',
Expand Down Expand Up @@ -77,6 +78,20 @@ $np->add_arg(
default => 1,
);

$np->add_arg(
spec => 'warnnoops',
help => "Exit with WARNING status if nodes had at least INTEGER "
. "noops in the last run (default: %s)",
default => 1,
);

$np->add_arg(
spec => 'critnoops',
help => "Exit with CRITICAL status if nodes had at least INTEGER "
. "noops in the last run (default: %s)",
default => 999,
);

$np->add_arg(
spec => 'hostname|H=s',
help => 'Hostname of the PuppetDB (default: %s)',
Expand Down Expand Up @@ -203,13 +218,29 @@ foreach my $node (@$data) {
$failures = @$node_data[0]->{'failures'};
}

my $noops = 0;
if ( defined( @$node_data[0] )
and defined( @$node_data[0]->{'noops'} ) )
{
$noops = @$node_data[0]->{'noops'};
}

if ( $failures >= $np->opts->critfails ) {
$np->add_message( CRITICAL,
"$certname had $failures failures in the last run\n" );
"$certname had $failures failures in the last run ($noops noops)\n" );
}
elsif ( $failures >= $np->opts->warnfails ) {
$np->add_message( WARNING,
"$certname had $failures failures in the last run\n" );
"$certname had $failures failures in the last run ($noops noops)\n" );
}

if ( $noops >= $np->opts->critnoops ) {
$np->add_message( CRITICAL,
"$certname had $noops noops in the last run\n" );
}
elsif ( $noops >= $np->opts->warnnoops ) {
$np->add_message( WARNING,
"$certname had $noops noops in the last run\n" );
}
elsif ( exists $apiurls{$np->opts->apiversion}{'logs'} ) {
my $apiurl = $apiurls{$np->opts->apiversion}{'logs'};
Expand Down