ÿØÿà JFIF ÿþ
ÿÛ C
ÿÛ C ÿÀ ÿÄ ÿÄ " #QrÿÄ ÿÄ & 1! A"2qQaáÿÚ ? Øy,æ/3JæÝ¹Èß²Ø5êXw²±ÉyR¾I0ó2PI¾IÌÚiMö¯þrìN&"KgX:íµnTJnLK
@!-ýùúmë;ºgµ&ó±hw¯Õ@Ü9ñ-ë.²1<yà¹ïQÐUÛ?.¦èûbß±©Ö«Âw*V) `$bØÔëXÖ-ËTÜíGÚ3ð«g §¯JxU/ÂÅv_s(Hÿ @TñJÑãõçn!ÈgfbÓc:él[ðQe9ÀPLbÃãCµm[5¿ç'ªjglåÛí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢S x?"¸¦ùYé¨ÒOÈ q`~~ÚtËU¹CÚêV I1Áß_ÿÙ#!/usr/bin/perl
###############
#
# Check ICMP connectivity for various IPs
# see https://incidencias.irontec.com/view.php?id=39261
#
# this script is a wrapper for /usr/lib/nagios/plugins/check_icmp
# see it for more options
#
###############
use strict;
use Getopt::Long;
use Data::Dumper;
use File::Basename;
use Switch;
use vars qw($opt_h $output $exit_status $perfdata $path);
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
$path="/usr/lib64/nagios/plugins";
Getopt::Long::Configure('bundling');
GetOptions
("h|help" => \$opt_h, "help");
my $program = basename($0);
sub print_help () {
print "
Check ICMP status, it allows multiple IPs separated by commas (,)
Example:
$program 10.10.0.81,10.10.0.39 200.000ms,40% 500.000ms,80%
\$ARG1\$
specify a target
\$ARG2\$
warning threshold (currently 200.000ms,40%)
\$ARG3\$
critical threshold (currently 500.000ms,80%)
-h, --help
Show this help
";
}
sub usage {
my $format=shift;
printf($format,@_);
exit $ERRORS{'UNKNOWN'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
}
if (@ARGV < 1) {
print "NOT HOST EXPLAINED\n";
exit $ERRORS{'CRITICAL'};
}
$output="";
$perfdata="";
$exit_status=0;
my @output;
my @perfdata;
my $outpout;
my $perfdata;
for my $host (split(/,/,@ARGV[0])){
my $command="sudo $path/check_icmp -H $host";
$command .= " -w @ARGV[1]" if @ARGV[1];
$command .= " -c @ARGV[2]" if @ARGV[2];
my $out = `$command`;
if ($? > 0) {
$exit_status=2;
}
my @data = split /\|/, $out;
my @rta = split / /, $data[0];
$output = $data[0];
$output = "$data[0]" if $rta[0] ne "OK";
push @output, $output;
@rta = split / /, $data[1];
push @perfdata, "$host-$rta[0]";
}
$output = join '
', @output;
$perfdata = join ' ', @perfdata;
print "$output|$perfdata\n";
if ($exit_status > 0){
exit $ERRORS{'CRITICAL'};
}
exit $ERRORS{'OK'};