Code: Select all
#!/usr/bin/perl
use strict;
use IO::Socket::INET;
my $host = $ARGV[0];
my $port = $ARGV[1];
my $sock = IO::Socket::INET->new(PeerAddr => $host,
PeerPort => $port,
Proto => 'udp') || exit 1;
my $retry = 3;
my $count = 0;
while ($retry--) {
unless (send($sock, "ping!", 0)) {
$count++;
}
sleep(5);
}
if ($count == 0) {
print "OK\n";
exit 0;
} elsif ($count > 0) {
print "CRITICAL - $count pings failed\n";
exit 2;
}
./check_udp -H <host> -p 1812
With UDP checks, a send/expect string must be specified.
Usage:
check_udp -H host -p port [-w <warning time>] [-c <critical time>] [-s <send string>]
[-e <expect string>] [-q <quit string>][-m <maximum bytes>] [-d <delay>]
[-t <timeout seconds>] [-r <refuse state>] [-M <mismatch state>] [-v] [-4|-6] [-j]
[-D <warn days cert expire>[,<crit days cert expire>]] [-S <use SSL>] [-E]
What should I use for the send/expect string or is there a different check that I should be using?