#!/usr/bin/perl
#Copyright 2010 Thomas Vachon
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#See .
use IO::File;
my $tmpFile = `mktemp`;
my $puppetCheckCmd = ("/usr/share/puppet/ext/puppetlast 1>$tmpFile");
system ($puppetCheckCmd) == 0 or die "Checking puppet client status failed";
my @staleClients = ();
open (FILE, $tmpFile);
while () {
chomp;
($client, $junk1, $junk2, $time, $timeUnit, $junk3) = split(/ /);
if ($time > 60){
my $error = "$client last checked in $time $timeUnit ago";
printf "$error \n";
push(@staleClients, $error);
}
}
close (FILE);
if (scalar(@staleClients) > 0){
printf "There are stale puppet clients, please investigate.\n";
printf "The stale clients are below\n";
foreach (@staleClients) {
printf "$_ \n";
}
}
exit;