summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alex@spline.inf.fu-berlin.de>2014-05-12 15:45:10 +0000
committerAlexander Sulfrian <alex@spline.inf.fu-berlin.de>2014-05-12 15:45:10 +0000
commitdbcf456a45682c9891076be0bd836fbd6c6dec20 (patch)
treefe7c6ac4c540fe711bf83eb3ced1d7e0b52c2864
parent344f3d4b4c227673d911e794aecbe66f533b7ed7 (diff)
downloadbcfg2-tools-dbcf456a45682c9891076be0bd836fbd6c6dec20.tar.gz
bcfg2-tools-dbcf456a45682c9891076be0bd836fbd6c6dec20.tar.bz2
bcfg2-tools-dbcf456a45682c9891076be0bd836fbd6c6dec20.zip
hosts-state: add hostnames into status message
-rwxr-xr-xhosts-state32
1 files changed, 20 insertions, 12 deletions
diff --git a/hosts-state b/hosts-state
index acf7552..eee878c 100755
--- a/hosts-state
+++ b/hosts-state
@@ -13,10 +13,11 @@ my $stale = DateTime->now(time_zone => 'local')->set_time_zone('floating');
$stale->subtract( hours => 24 );
my $summary = {
- stale => 0,
- bad => 0,
- clean => 0,
+ stale => [],
+ bad => [],
+ clean => [],
msg => 'OK',
+ hosts => '',
status => 0
};
@@ -41,18 +42,18 @@ while(<$reports>) {
if ($dt < $stale) {
$msg = "CRITICAL $host is stale";
$status = 2;
- $summary->{stale}++;
+ push($summary->{stale}, $short_host);
}
else {
if ($bad > 0) {
$msg = "CRITICAL $bad bad entries";
$status = 2;
- $summary->{bad}++;
+ push($summary->{bad}, $short_host);
}
else {
$msg = "OK Total managed entries: $total (extra: $extra)";
$status = 0;
- $summary->{clean}++;
+ push($summary->{clean}, $short_host);
}
}
@@ -60,15 +61,22 @@ while(<$reports>) {
print("$host\tBcfg2\t$status\t$msg | $perf\n\x17");
}
-if ($summary->{bad} > 0) {
- $summary->{msg} = 'CRITICAL';
- $summary->{status} = 2;
-}
-elsif ($summary->{stale} > 0) {
+my $bad_count = @{ $summary->{bad} };
+my $stale_count = @{ $summary->{stale} };
+my $clean_count = @{ $summary->{clean} };
+
+if ($stale_count > 0) {
$summary->{msg} = 'WARNING';
+ $summary->{hosts} = ' STALE: ' . join(', ', @{ $summary->{stale} });
$summary->{status} = 1;
}
-print("vm-bcfg2\tBcfg2 Status\t$summary->{status}\t$summary->{msg} | clean=$summary->{clean};;;0 bad=$summary->{bad};;;0 stale=$summary->{stale};;;0\n\x17");
+if ($bad_count > 0) {
+ $summary->{msg} = 'CRITICAL';
+ $summary->{hosts} = ' BAD: ' . join(', ', @{ $summary->{bad} }) . $summary->{hosts};
+ $summary->{status} = 2;
+}
+
+print("vm-bcfg2.spline.inf.fu-berlin.de\tBcfg2 Status\t$summary->{status}\t$summary->{msg}$summary->{hosts} | clean=$clean_count;;;0 bad=$bad_count;;;0 stale=$stale_count;;;0\n\x17");
close($reports);