3
# check_atalk_ping plugin for nagios
6
# check_atalk_ping atalkaddress
8
# Checks if an atalkhost responds to an atalk echo
11
# initial version: 23 October 2002 by Stefan Beck, IT Software Solutions
12
# current status: $Revision: 1.1 $
14
# Copyright Notice: GPL
17
if ( $0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/ ) {
27
use utils qw($TIMEOUT %ERRORS &print_revision &support);
28
use vars qw($PROGNAME);
30
$PROGNAME = "check_atalk";
33
$verbose, $host, $warning_avg, $warning_loss,
34
$critical_avg, $critical_loss, $count, $cmd,
37
my ( $opt_c, $opt_w, $opt_H, $opt_p );
38
$opt_c = $opt_w = $opt_p = $opt_H = '';
45
# Just in case of problems, let's not hang NetSaint
47
print "Plugin Timeout\n";
52
delete @ENV{ 'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV' };
55
Getopt::Long::Configure( 'bundling', 'no_ignore_case' );
57
"V|version" => \&version,
59
"p|packets=i" => \$opt_p,
60
"c|critical=s" => \$opt_c,
61
"w|warning=s" => \$opt_w,
62
"H|hostname=s" => \$opt_H
66
# appletalk hostname ot address
67
$opt_H = shift unless ($opt_H);
68
unless ($opt_H) { print_usage (); exit $ERRORS{'UNKNOWN'}; }
69
if ( $opt_H && $opt_H =~ m/^([-a-zA-Z\.\:0-9]+)$/ ) {
73
print "$opt_H is not a valid host name\n";
74
exit $ERRORS{'UNKNOWN'};
78
$opt_p = 5 unless $opt_p;
79
if ( $opt_p && $opt_p =~ m/^([1-9]+[0-9]*)$/ ) {
83
print "$opt_p is not a valid packet number\n";
84
exit $ERRORS{'UNKNOWN'};
87
if ( $opt_w && $opt_w =~ m/^([1-9]+[0-9]*),([1-9][0-9]*)%$/ ) {
92
print "$opt_w is not a valid threshold\n";
93
exit $ERRORS{'UNKNOWN'};
96
if ( $opt_c && $opt_c =~ m/^([1-9]+[0-9]*),([1-9][0-9]*)%$/ ) {
101
print "$opt_c is not a valid threshold\n";
102
exit $ERRORS{'UNKNOWN'};
105
$cmd = "/usr/bin/aecho -c $count $host 2>&1 |";
106
print "$cmd\n" if ($verbose);
110
print $_ if ($verbose);
113
# 5 packets sent, 5 packets received, 0% packet loss
114
# round-trip (ms) min/avg/max = 0/0/0
116
if (/received, ([0-9]+)% packet loss/) {
119
if (/min\/avg\/max = [0-9]+\/([0-9]+)\/[0-9]+/) {
125
print_revision( $PROGNAME, '$Revision: 1.1 $ ' );
126
print "Copyright (c) 2002 Stefan Beck\n";
128
print "Check if an atalkhost responds to an atalk echo using\n";
129
print " aecho -c <packets> <atalkhost>\n";
133
print "-H, --hostname=HOST\n";
134
print " host to ping\n";
135
print "-w, --warning=THRESHOLD\n";
136
print " warning threshold pair\n";
137
print "-c, --critical=THRESHOLD\n";
138
print " critical threshold pair\n";
139
print "-p, --packets=INTEGER\n";
140
print " number of ICMP ECHO packets to send (Default: 5)\n";
143
"THRESHOLD is <rta>,<pl>% where <rta> is the round trip average
146
"time (ms) which triggers a WARNING or CRITICAL state, and <pl>
148
print "percentage of packet loss to trigger an alarm state.\n";
155
print "$PROGNAME -H atalkhost -w <wrta>,<wpl>% -c <crta>,<cpl>%\n";
156
print " [-p packets] [-t timeout] [-L]\n";
157
print "$PROGNAME [-h | --help]\n";
158
print "$PROGNAME [-V | --version]\n";
162
print_revision( $PROGNAME, '$Revision: 1.1 $ ' );
174
if ( defined $loss && defined $avg ) {
175
if ( $loss >= $critical_loss ) {
178
elsif ( $avg >= $critical_avg ) {
181
elsif ( $loss >= $warning_loss ) {
184
elsif ( $avg >= $warning_avg ) {
190
$answer = "Appletalk PING $state - Packet loss = $loss%, RTA = $avg
195
$answer = "UNKNOWN - $line";
198
exit $ERRORS{$state};
203
-------------------------------------------------------
204
This sf.net email is sponsored by:ThinkGeek
205
Welcome to geek heaven.
206
http://thinkgeek.com/sf
207
_______________________________________________
208
Nagios-devel mailing list
209
Nagios-devel@lists.sourceforge.net
210
https://lists.sourceforge.net/lists/listinfo/nagios-devel