summaryrefslogtreecommitdiffstats
path: root/plugins-scripts/check_rpc.pl
diff options
context:
space:
mode:
authorEthan Galstad <egalstad@users.sourceforge.net>2002-02-28 06:42:51 +0000
committerEthan Galstad <egalstad@users.sourceforge.net>2002-02-28 06:42:51 +0000
commit44a321cb8a42d6c0ea2d96a1086a17f2134c89cc (patch)
treea1a4d9f7b92412a17ab08f34f04eec45433048b7 /plugins-scripts/check_rpc.pl
parent54fd5d7022ff2d6a59bc52b8869182f3fc77a058 (diff)
downloadmonitoring-plugins-44a321cb8a42d6c0ea2d96a1086a17f2134c89cc.tar.gz
Initial revision
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins-scripts/check_rpc.pl')
-rwxr-xr-xplugins-scripts/check_rpc.pl274
1 files changed, 274 insertions, 0 deletions
diff --git a/plugins-scripts/check_rpc.pl b/plugins-scripts/check_rpc.pl
new file mode 100755
index 00000000..51901ac0
--- /dev/null
+++ b/plugins-scripts/check_rpc.pl
@@ -0,0 +1,274 @@
1#! /usr/bin/perl -wT
2#
3# check_rpc plugin for nagios
4#
5# usage:
6# check_rpc host service
7#
8# Check if an rpc serice is registered and running
9# using rpcinfo - $proto $host $prognum 2>&1 |";
10#
11# Use these hosts.cfg entries as examples
12#
13# command[check_nfs]=/some/path/libexec/check_rpc $HOSTADDRESS$ nfs
14# service[check_nfs]=NFS;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_rpc
15#
16# initial version: 3 May 2000 by Truongchinh Nguyen and Karl DeBisschop
17# current status: $Revision$
18#
19# Copyright Notice: GPL
20#
21BEGIN {
22 if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
23 $runtimedir = $1;
24 $PROGNAME = $2;
25 }
26}
27
28use strict;
29use lib $main::runtimedir;
30use utils qw($TIMEOUT %ERRORS &print_revision &support);
31use vars qw($PROGNAME);
32my ($verbose,@proto,%prognum,$host,$response,$prognum,$port,$cmd);
33my ($array_ref,$test,$element,@progkeys,$proto,$a,$b);
34my ($opt_V,$opt_h,$opt_C,$opt_p,$opt_H);
35$opt_V = $opt_h = $opt_C = $opt_p = $opt_H = '';
36
37sub print_help ();
38sub print_usage ();
39sub in ($$);
40
41$ENV{'BASH_ENV'}='';
42$ENV{'ENV'}='';
43$ENV{'PATH'}='';
44
45#Initialise protocol for each progname number
46# 'u' for UDP, 't' for TCP
47$proto[10003]='u';
48$proto[10004]='u';
49$proto[10007]='u';
50
51use Getopt::Long;
52Getopt::Long::Configure('bundling');
53GetOptions
54 ("V" => \$opt_V, "version" => \$opt_V,
55 "h" => \$opt_h, "help" => \$opt_h,
56 "C=s" => \$opt_C, "command=s" => \$opt_C,
57 "p=i" => \$opt_p, "port=i" => \$opt_p,
58 "H=s" => \$opt_H, "hostname=s" => \$opt_H);
59
60# -h means display verbose help screen
61if ($opt_h) { print_help(); exit 0; }
62
63# -V means display version number
64if ($opt_V) { print_revision($PROGNAME,'$Revision$ '); exit 0; }
65
66# -H means host name
67$opt_H = shift unless ($opt_H);
68unless ($opt_H) { print_usage(); exit -1; }
69if($opt_H && $opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]+(\.[a-zA-Z][-a-zA-Z0-9]+)*)$/) {
70 $host = $1;
71} else {
72 print "$opt_H is not a valid host name\n";
73 exit -1;
74}
75
76while (<DATA>) {
77 ($a,$b) = split;
78 $prognum{$a} = $b;
79}
80close DATA;
81
82# -C means command name or number
83$opt_C = shift unless ($opt_C);
84unless ($opt_C) { print_usage(); exit -1; }
85@progkeys = keys %prognum;
86if ($opt_C =~ m/^([0-9]+)$/){
87 $response = "RPC ok: program $opt_p (version ";
88 $prognum = $1;
89} elsif ( in( \@progkeys, $opt_C)) {
90 $response = "RPC ok: $opt_C (version ";
91 $prognum = $prognum{$opt_C};
92} else {
93 print "Program $opt_C is not defined\n";
94 exit -1;
95}
96
97# -p means port number
98if($opt_p =~ /^([0-9]+)$/){
99 $port = "-n $1";
100} else {
101 $port = "";
102}
103
104$proto = 'u';
105$proto = $proto[$prognum] if ($proto[$prognum]);
106$cmd = "/usr/sbin/rpcinfo $port -" . "$proto $host $prognum 2>&1 |";
107print "$cmd\n" if ($verbose);
108open CMD, $cmd;
109
110while ( <CMD> ) {
111 chomp;
112 if ( /program $prognum version ([0-9]*) ready and waiting/ ) {
113 $response .= "$1) is running";
114 print "$response\n";
115 exit 0;
116 }
117}
118
119print "RPC CRITICAL: Program $opt_C not registered\n";
120exit 2;
121
122
123
124sub print_help() {
125 print_revision($PROGNAME,'$Revision$ ');
126 print "Copyright (c) 2000 Karl DeBisschop/Truongchinh Nguyen\n";
127 print "\n";
128 print "Check if a rpc service is registered and running using\n";
129 print " rpcinfo -<protocol> <host> <program number>\n";
130 print "\n";
131 print_usage();
132 print "\n";
133 print "<host> The server providing the rpc service\n";
134 print "<program> The program name (or number).\n\n";
135 support();
136}
137
138sub print_usage () {
139 print "$PROGNAME -H host -C rpc_command [-p port]\n";
140 print "$PROGNAME [-h | --help]\n";
141 print "$PROGNAME [-V | --version]\n";
142}
143
144sub in ($$) {
145 $array_ref = shift;
146 $test = shift;
147
148 while ( $element = shift @{$array_ref} ) {
149 if ($test eq $element) {
150 return 1;
151 }
152 }
153 return 0;
154}
155
156__DATA__
157portmapper 100000
158portmap 100000
159sunrpc 100000
160rpcbind 100000
161rstatd 100001
162rstat 100001
163rup 100001
164perfmeter 100001
165rstat_svc 100001
166rusersd 100002
167rusers 100002
168nfs 100003
169nfsprog 100003
170ypserv 100004
171ypprog 100004
172mountd 100005
173mount 100005
174showmount 100005
175ypbind 100007
176walld 100008
177rwall 100008
178shutdown 100008
179yppasswdd 100009
180yppasswd 100009
181etherstatd 100010
182etherstat 100010
183rquotad 100011
184rquotaprog 100011
185quota 100011
186rquota 100011
187sprayd 100012
188spray 100012
1893270_mapper 100013
190rje_mapper 100014
191selection_svc 100015
192selnsvc 100015
193database_svc 100016
194rexd 100017
195rex 100017
196alis 100018
197sched 100019
198llockmgr 100020
199nlockmgr 100021
200x25_inr 100022
201statmon 100023
202status 100024
203bootparam 100026
204ypupdated 100028
205ypupdate 100028
206keyserv 100029
207keyserver 100029
208sunlink_mapper 100033
209tfsd 100037
210nsed 100038
211nsemntd 100039
212showfhd 100043
213showfh 100043
214ioadmd 100055
215rpc.ioadmd 100055
216NETlicense 100062
217sunisamd 100065
218debug_svc 100066
219dbsrv 100066
220ypxfrd 100069
221rpc.ypxfrd 100069
222bugtraqd 100071
223kerbd 100078
224event 100101
225na.event 100101
226logger 100102
227na.logger 100102
228sync 100104
229na.sync 100104
230hostperf 100107
231na.hostperf 100107
232activity 100109
233na.activity 100109
234hostmem 100112
235na.hostmem 100112
236sample 100113
237na.sample 100113
238x25 100114
239na.x25 100114
240ping 100115
241na.ping 100115
242rpcnfs 100116
243na.rpcnfs 100116
244hostif 100117
245na.hostif 100117
246etherif 100118
247na.etherif 100118
248iproutes 100120
249na.iproutes 100120
250layers 100121
251na.layers 100121
252snmp 100122
253na.snmp 100122
254snmp-cmc 100122
255snmp-synoptics 100122
256snmp-unisys 100122
257snmp-utk 100122
258traffic 100123
259na.traffic 100123
260nfs_acl 100227
261sadmind 100232
262nisd 100300
263rpc.nisd 100300
264nispasswd 100303
265rpc.nispasswdd 100303
266ufsd 100233
267ufsd 100233
268pcnfsd 150001
269pcnfs 150001
270amd 300019
271amq 300019
272bwnfsd 545580417
273fypxfrd 600100069
274freebsd-ypxfrd 600100069