3
# check_arping.pl - Nagios plugin to check host status via ARP ping
6
# check_arping -H hostname -I interface -T timeout
9
# Copyright (C) 2003 Kenny Root
11
# This program is free software; you can redistribute it and/or
12
# modify it under the terms of the GNU General Public License
13
# as published by the Free Software Foundation; either version 2
14
# of the License, or (at your option) any later version.
16
# This program is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
# GNU General Public License for more details.
21
# You should have received a copy of the GNU General Public License
22
# along with this program; if not, write to the Free Software
23
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
# Report bugs to: kenny@the-b.org, nagiosplug-help@lists.sf.net
30
use lib "/usr/lib/nagios/plugins" ;
31
use utils qw($TIMEOUT %ERRORS &print_revision &support);
36
my $PROGNAME = "check_arping";
38
my($status, $state, $answer);
39
my($opt_V, $opt_h, $opt_t, $opt_I, $opt_H);
44
"V|version" => \$opt_V,
46
"I|interface=s" => \$opt_I,
47
"H|host=s" => \$opt_H,
48
"t|timeout=i" => \$opt_t);
58
print_revision($PROGNAME,'$Revision: 1112 $ ');
68
if ($opt_t ne int($opt_t)) {
69
print "Timeout not in seconds!\n";
78
if (! utils::is_hostname($opt_H)){
80
exit $ERRORS{"UNKNOWN"};
83
my $ping = Net::Arping->new();
85
my $reply = $ping->arping(Host => $opt_H, Interface => $opt_I, Timeout => $opt_t);
89
print "$state: no reply from $opt_H on interface $opt_I in $opt_t seconds.\n";
93
$answer = "replied with MAC address $reply";
96
print "ARPING $state - $answer\n";
101
print "\nMissing arguments!\n";
103
print "check_arping -I <interface> -H <host IP> [-t <timeout>]\n";
106
exit $ERRORS{"UNKNOWN"};
110
print "check_arping pings hosts that normally wouldn't allow\n";
111
print "ICMP packets but are still on the local network.\n";
113
print " -H (--host) IP to query - (required)\n";
114
print " -I (--interface) Interface to use.\n";
115
print " -t (--timeout) Timeout in seconds.\n";
116
print " -V (--version) Plugin version\n";
117
print " -h (--help) usage help \n\n";
118
print_revision($PROGNAME, '$Revision: 1112 $');