8 my ($SEC, $MIN, $HOUR, $DAY,$MONTH,$YEAR) = (localtime(time))[0,1,2,3,4,5,6];
18 my $posF = "/tmp/eg_stats_position.log";
19 my $statsF = "/var/log/evergreen/prod/$YEAR/$MONTH/$DAY/eg_stats.log";
22 my $status = 0; #status is OK!
25 #if it exists open it and get the current position
26 #if not set the current position to 0
30 if (@values != 2) { #make sure the array is the correct size
33 chomp($loc = $values[0]);
34 if ($loc ne $statsF) { #check to see that we are in the correct file
37 chomp($pos = $values[1]);
38 #check to see if $pos is a valid positive integer(or 0), if not set to 0
39 if (!( $pos =~ /^\d+$/ )) {
48 #parse the file and output for Nagios if necessary
50 open(DATA, "<$statsF");
55 #check for lost controller first
56 if (($line =~ m/listener count: 0/) || ($line =~ m/controller count: 0/) || ($line =~ m/master count: 0/)){
57 if ($line =~ m/listener count: 0/) {
58 $info = $info."Lost a listener: $line - ";
60 if ($line =~ m/master count: 0/) {
61 $info = $info."Lost a master: $line - ";
63 if ($line =~ m/controller count: 0/) {
64 $info = $info."Lost a controller: $line - ";
68 #now check for drone ratio
69 if ($line =~ m/SERVICE/) {
70 my ($count) = $line =~ /drone count: (\d+\/\d+)/i;
71 my $ratio = eval($count);
72 my $pct = ceil($ratio * 100);
74 $info = $info."Drone count is $pct % - $line - ";
78 $info = $info."Drone count is $pct % - $line - ";
92 print DATA "$statsF\n$pos\n";
96 $info = "EG-STATS-COLLECTOR STATUS: OK!";