3 # Copyright (c) 2014 Joey Schulze <joey@infodrom.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
21 use lib '/usr/lib/nagios/plugins';
22 use utils qw(%ERRORS);
23 use POSIX qw(strftime);
33 Getopt::Long::Configure('no_ignore_case');
35 'ticker=s' => \$ticker,
36 'warn=s' => \$config->{warn},
37 'crit=s' => \$config->{crit},
38 'help' => \&print_help;
53 return sprintf("/var/www/private-lists/ticker-%s/ticker-%s.%s", $name, $name, $month);
56 my $month = strftime '%Y%m', localtime;
57 my $fname = path $ticker, $month;
60 my $mtime = (stat(_))[9];
62 if ($mtime < time - ($config->{crit} * 60*60)) {
63 printf "TICKER CRITICAL - %s older than %d hours\n", $fname, $config->{crit};
64 exit $ERRORS{'CRITICAL'};
65 } elsif ($mtime < time - ($config->{warn} * 60*60)) {
66 printf "TICKER WARNING - %s older than %d hours\n", $fname, $config->{warn};
67 exit $ERRORS{'WARNING'};
70 my $diff = (time - $mtime) / 60;
71 my $time = $diff % 60;
73 $time = sprintf('%d:%02d hours', $diff / 60, $time);
78 printf "TICKER OK - %s updated %s ago\n", $ticker, $time;
81 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
82 my $monthstart = time - ($mday-1) * 60*60*24 - $hour*60*60 - $min*60 - $sec;
84 if (time > $monthstart + ($config->{crit} * 60*60)) {
85 printf "TICKER CRITICAL - %s not updated for %d hours\n", $ticker, $config->{crit};
86 exit $ERRORS{'CRITICAL'};
87 } elsif (time > $monthstart + ($config->{warn} * 60*60)) {
88 printf "TICKER WARNING - %s not updated for %d hours\n", $ticker, $config->{warn};
89 exit $ERRORS{'WARNING'};
92 my $diff = (time - $monthstart) / 60;
93 my $time = $diff % 60;
95 $time = sprintf('%d:%02d', $diff / 60, $time);
100 printf "TICKER OK - %s not updated for %s\n", $ticker, $time;