diff options
Diffstat (limited to 'plugins-scripts')
-rw-r--r-- | plugins-scripts/.cvsignore | 5 | ||||
-rw-r--r-- | plugins-scripts/Makefile.am | 30 | ||||
-rwxr-xr-x | plugins-scripts/check_breeze.pl | 86 | ||||
-rwxr-xr-x | plugins-scripts/check_disk_smb.pl | 240 | ||||
-rwxr-xr-x | plugins-scripts/check_flexlm.pl | 149 | ||||
-rwxr-xr-x | plugins-scripts/check_ircd.pl | 257 | ||||
-rwxr-xr-x | plugins-scripts/check_log.sh | 214 | ||||
-rwxr-xr-x | plugins-scripts/check_netdns.pl | 129 | ||||
-rwxr-xr-x | plugins-scripts/check_nfs.pl | 48 | ||||
-rwxr-xr-x | plugins-scripts/check_ntp.pl | 236 | ||||
-rwxr-xr-x | plugins-scripts/check_oracle.sh | 126 | ||||
-rwxr-xr-x | plugins-scripts/check_rpc.pl | 274 | ||||
-rwxr-xr-x | plugins-scripts/check_sensors.sh | 65 | ||||
-rwxr-xr-x | plugins-scripts/check_wave.pl | 129 | ||||
-rw-r--r-- | plugins-scripts/subst.in | 56 | ||||
-rw-r--r-- | plugins-scripts/t/check_rpc.t | 19 | ||||
-rw-r--r-- | plugins-scripts/utils.pm.in | 38 | ||||
-rw-r--r-- | plugins-scripts/utils.sh.in | 22 |
18 files changed, 2123 insertions, 0 deletions
diff --git a/plugins-scripts/.cvsignore b/plugins-scripts/.cvsignore new file mode 100644 index 00000000..95d79c72 --- /dev/null +++ b/plugins-scripts/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile | ||
2 | Makefile.in | ||
3 | subst | ||
4 | utils.pm | ||
5 | utils.sh \ No newline at end of file | ||
diff --git a/plugins-scripts/Makefile.am b/plugins-scripts/Makefile.am new file mode 100644 index 00000000..4bdf7175 --- /dev/null +++ b/plugins-scripts/Makefile.am | |||
@@ -0,0 +1,30 @@ | |||
1 | ## Process this file with automake to produce Makefile.in | ||
2 | |||
3 | SUFFIXES = .pl .sh | ||
4 | |||
5 | VPATH=$(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/t | ||
6 | |||
7 | libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \ | ||
8 | check_log check_ntp check_oracle check_rpc check_sensors check_wave \ | ||
9 | utils.sh utils.pm | ||
10 | |||
11 | EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \ | ||
12 | check_log.sh check_ntp.pl check_oracle.sh check_rpc.pl check_sensors.sh \ | ||
13 | check_wave.pl utils.sh.in utils.pm.in t | ||
14 | |||
15 | TESTS_ENVIRONMENT=perl -I $(top_builddir) -I $(top_srcdir) | ||
16 | |||
17 | TESTS = @SCRIPT_TEST@ | ||
18 | |||
19 | test: | ||
20 | perl -I $(top_builddir) -I $(top_srcdir) ../test.pl | ||
21 | |||
22 | CLEANFILES=$(libexec_SCRIPTS) | ||
23 | |||
24 | .pl : | ||
25 | $(AWK) -f ./subst $< > $@ | ||
26 | chmod +x $@ | ||
27 | |||
28 | .sh : | ||
29 | $(AWK) -f ./subst $< > $@ | ||
30 | chmod +x $@ | ||
diff --git a/plugins-scripts/check_breeze.pl b/plugins-scripts/check_breeze.pl new file mode 100755 index 00000000..79e36be7 --- /dev/null +++ b/plugins-scripts/check_breeze.pl | |||
@@ -0,0 +1,86 @@ | |||
1 | #! /usr/bin/perl -wT | ||
2 | |||
3 | BEGIN { | ||
4 | if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { | ||
5 | $runtimedir = $1; | ||
6 | $PROGNAME = $2; | ||
7 | } | ||
8 | } | ||
9 | |||
10 | use strict; | ||
11 | use Getopt::Long; | ||
12 | use vars qw($opt_V $opt_h $opt_H $opt_w $opt_c $PROGNAME); | ||
13 | use lib $main::runtimedir; | ||
14 | use utils qw(%ERRORS &print_revision &support &usage); | ||
15 | |||
16 | sub print_help (); | ||
17 | sub print_usage (); | ||
18 | |||
19 | $ENV{'PATH'}=''; | ||
20 | $ENV{'BASH_ENV'}=''; | ||
21 | $ENV{'ENV'}=''; | ||
22 | |||
23 | Getopt::Long::Configure('bundling'); | ||
24 | GetOptions | ||
25 | ("V" => \$opt_V, "version" => \$opt_V, | ||
26 | "h" => \$opt_h, "help" => \$opt_h, | ||
27 | "w=s" => \$opt_w, "warning=s" => \$opt_w, | ||
28 | "c=s" => \$opt_c, "critical=s" => \$opt_c, | ||
29 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); | ||
30 | |||
31 | if ($opt_V) { | ||
32 | print_revision($PROGNAME,'$Revision$'); | ||
33 | exit $ERRORS{'OK'}; | ||
34 | } | ||
35 | |||
36 | if ($opt_h) {print_help(); exit $ERRORS{'OK'};} | ||
37 | |||
38 | ($opt_H) || ($opt_H = shift) || usage("Host name/address not specified\n"); | ||
39 | my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/); | ||
40 | ($host) || usage("Invalid host: $opt_H\n"); | ||
41 | |||
42 | ($opt_w) || ($opt_w = shift) || usage("Warning threshold not specified\n"); | ||
43 | my $warning = $1 if ($opt_w =~ /([0-9]{1,2}|100)+/); | ||
44 | ($warning) || usage("Invalid warning threshold: $opt_w\n"); | ||
45 | |||
46 | ($opt_c) || ($opt_c = shift) || usage("Critical threshold not specified\n"); | ||
47 | my $critical = $1 if ($opt_c =~ /([0-9]{1,2}|100)/); | ||
48 | ($critical) || usage("Invalid critical threshold: $opt_c\n"); | ||
49 | |||
50 | my $sig=0; | ||
51 | $sig = `/usr/bin/snmpget $host public .1.3.6.1.4.1.710.3.2.3.1.3.0`; | ||
52 | my @test=split(/ /,$sig); | ||
53 | $sig=$test[2]; | ||
54 | $sig=int($sig); | ||
55 | if ($sig>100){$sig=100} | ||
56 | |||
57 | print "Signal Strength at: $sig%\n"; | ||
58 | |||
59 | exit $ERRORS{'CRITICAL'} if ($sig<$critical); | ||
60 | exit $ERRORS{'WARNING'} if ($sig<$warning); | ||
61 | exit $ERRORS{'OK'}; | ||
62 | |||
63 | |||
64 | sub print_usage () { | ||
65 | print "Usage: $PROGNAME -H <host> -w <warn> -c <crit>\n"; | ||
66 | } | ||
67 | |||
68 | sub print_help () { | ||
69 | print_revision($PROGNAME,'$Revision$'); | ||
70 | print "Copyright (c) 2000 Jeffrey Blank/Karl DeBisschop | ||
71 | |||
72 | This plugin reports the signal strength of a Breezecom wireless equipment | ||
73 | |||
74 | "; | ||
75 | print_usage(); | ||
76 | print " | ||
77 | -H, --hostname=HOST | ||
78 | Name or IP address of host to check | ||
79 | -w, --warning=INTEGER | ||
80 | Percentage strength below which a WARNING status will result | ||
81 | -c, --critical=INTEGER | ||
82 | Percentage strength below which a CRITICAL status will result | ||
83 | |||
84 | "; | ||
85 | support(); | ||
86 | } | ||
diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl new file mode 100755 index 00000000..d1b0b3d6 --- /dev/null +++ b/plugins-scripts/check_disk_smb.pl | |||
@@ -0,0 +1,240 @@ | |||
1 | #! /usr/bin/perl -wT | ||
2 | # | ||
3 | # | ||
4 | # check_disk.pl <host> <share> <user> <pass> [warn] [critical] [port] | ||
5 | # | ||
6 | # Nagios host script to get the disk usage from a SMB share | ||
7 | # | ||
8 | # Changes and Modifications | ||
9 | # ========================= | ||
10 | # 7-Aug-1999 - Michael Anthon | ||
11 | # Created from check_disk.pl script provided with netsaint_statd (basically | ||
12 | # cause I was too lazy (or is that smart?) to write it from scratch) | ||
13 | # 8-Aug-1999 - Michael Anthon | ||
14 | # Modified [warn] and [critical] parameters to accept format of nnn[M|G] to | ||
15 | # allow setting of limits in MBytes or GBytes. Percentage settings for large | ||
16 | # drives is a pain in the butt | ||
17 | |||
18 | BEGIN { | ||
19 | if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { | ||
20 | $runtimedir = $1; | ||
21 | $PROGNAME = $2; | ||
22 | } | ||
23 | } | ||
24 | |||
25 | require 5.004; | ||
26 | use POSIX; | ||
27 | use strict; | ||
28 | use Getopt::Long; | ||
29 | use vars qw($opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $verbose); | ||
30 | use vars qw($PROGNAME); | ||
31 | use lib $main::runtimedir; | ||
32 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); | ||
33 | |||
34 | sub print_help (); | ||
35 | sub print_usage (); | ||
36 | |||
37 | $ENV{'PATH'}=''; | ||
38 | $ENV{'BASH_ENV'}=''; | ||
39 | $ENV{'ENV'}=''; | ||
40 | |||
41 | Getopt::Long::Configure('bundling'); | ||
42 | GetOptions | ||
43 | ("v" => \$verbose, "verbose" => \$verbose, | ||
44 | "V" => \$opt_V, "version" => \$opt_V, | ||
45 | "h" => \$opt_h, "help" => \$opt_h, | ||
46 | "w=s" => \$opt_w, "warning=s" => \$opt_w, | ||
47 | "c=s" => \$opt_c, "critical=s" => \$opt_c, | ||
48 | "p=s" => \$opt_p, "password=s" => \$opt_p, | ||
49 | "u=s" => \$opt_u, "username=s" => \$opt_u, | ||
50 | "s=s" => \$opt_s, "share=s" => \$opt_s, | ||
51 | "W=s" => \$opt_W, "workgroup=s" => \$opt_W, | ||
52 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); | ||
53 | |||
54 | if ($opt_V) { | ||
55 | print_revision($PROGNAME,'$Revision$'); #' | ||
56 | exit $ERRORS{'OK'}; | ||
57 | } | ||
58 | |||
59 | if ($opt_h) {print_help(); exit $ERRORS{'OK'};} | ||
60 | |||
61 | my $smbclient="/usr/bin/smbclient"; | ||
62 | my $smbclientoptions=""; | ||
63 | |||
64 | ($opt_H) || ($opt_H = shift) || usage("Host name not specified\n"); | ||
65 | my $host = $1 if ($opt_H =~ /([-_.A-Za-z0-9]+)/); | ||
66 | ($host) || usage("Invalid host: $opt_H\n"); | ||
67 | |||
68 | ($opt_s) || ($opt_s = shift) || usage("Share volume not specified\n"); | ||
69 | my $share = $1 if ($opt_s =~ /([-_.A-Za-z0-9]+)/); | ||
70 | ($share) || usage("Invalid share: $opt_s\n"); | ||
71 | |||
72 | ($opt_u) || ($opt_u = shift) || ($opt_u = "guest"); | ||
73 | my $user = $1 if ($opt_u =~ /([-_.A-Za-z0-9]+)/); | ||
74 | ($user) || usage("Invalid user: $opt_u\n"); | ||
75 | |||
76 | ($opt_p) || ($opt_p = shift) || ($opt_p = "guest"); | ||
77 | my $pass = $1 if ($opt_p =~ /(.*)/); | ||
78 | |||
79 | ($opt_w) || ($opt_w = shift) || ($opt_w = 85); | ||
80 | my $warn = $1 if ($opt_w =~ /([0-9]{1,2}\%?|100\%?|[0-9]+[kmKM])+/); | ||
81 | ($warn) || usage("Invalid warning threshold: $opt_w\n"); | ||
82 | |||
83 | ($opt_c) || ($opt_c = shift) || ($opt_c = 95); | ||
84 | my $crit = $1 if ($opt_c =~ /([0-9]{1,2}\%?|100\%?|[0-9]+[kmKM])/); | ||
85 | ($crit) || usage("Invalid critical threshold: $opt_c\n"); | ||
86 | |||
87 | my $workgroup = $1 if (defined($opt_W) && $opt_W =~ /(.*)/); | ||
88 | |||
89 | my $state = "OK"; | ||
90 | my $answer = undef; | ||
91 | my $res = undef; | ||
92 | my @lines = undef; | ||
93 | |||
94 | # Just in case of problems, let's not hang Nagios | ||
95 | $SIG{'ALRM'} = sub { | ||
96 | print "No Answer from Client\n"; | ||
97 | exit $ERRORS{"UNKNOWN"}; | ||
98 | }; | ||
99 | alarm($TIMEOUT); | ||
100 | |||
101 | # Execute an "ls" on the share using smbclient program | ||
102 | # get the results into $res | ||
103 | if (defined($workgroup)) { | ||
104 | $res = qx/$smbclient \/\/$host\/$share $pass -W $workgroup -U $user $smbclientoptions -c ls/; | ||
105 | } else { | ||
106 | $res = qx/$smbclient \/\/$host\/$share $pass -U $user $smbclientoptions -c ls/; | ||
107 | } | ||
108 | #Turn off alarm | ||
109 | alarm(0); | ||
110 | |||
111 | #Split $res into an array of lines | ||
112 | @lines = split /\n/, $res; | ||
113 | |||
114 | #Get the last line into $_ | ||
115 | $_ = $lines[$#lines]; | ||
116 | #print "$_\n"; | ||
117 | |||
118 | #Process the last line to get free space. | ||
119 | #If line does not match required regexp, return an UNKNOWN error | ||
120 | if (/\s*(\d*) blocks of size (\d*)\. (\d*) blocks available/) { | ||
121 | |||
122 | my ($avail) = ($3*$2)/1024; | ||
123 | my ($avail_bytes) = $avail; | ||
124 | my ($capper) = int(($3/$1)*100); | ||
125 | my ($mountpt) = "\\\\$host\\$share"; | ||
126 | |||
127 | #Check $warn and $crit for type (%/M/G) and set up for tests | ||
128 | #P = Percent, K = KBytes | ||
129 | my $warn_type; | ||
130 | my $crit_type; | ||
131 | if ($warn =~ /^([0-9]+$)/) { | ||
132 | $warn_type = "P"; | ||
133 | } elsif ($warn =~ /^([0-9]+)k$/) { | ||
134 | my ($warn_type) = "K"; | ||
135 | $warn = $1; | ||
136 | } elsif ($warn =~ /^([0-9]+)M$/) { | ||
137 | $warn_type = "K"; | ||
138 | $warn = $1 * 1024; | ||
139 | } elsif ($warn =~ /^([0-9]+)G$/) { | ||
140 | $warn_type = "K"; | ||
141 | $warn = $1 * 1048576; | ||
142 | } | ||
143 | if ($crit =~ /^([0-9]+$)/) { | ||
144 | $crit_type = "P"; | ||
145 | } elsif ($crit =~ /^([0-9]+)k$/) { | ||
146 | $crit_type = "K"; | ||
147 | $crit = $1; | ||
148 | } elsif ($crit =~ /^([0-9]+)M$/) { | ||
149 | $crit_type = "K"; | ||
150 | $crit = $1 * 1024; | ||
151 | } elsif ($crit =~ /^([0-9]+)G$/) { | ||
152 | $crit_type = "K"; | ||
153 | $crit = $1 * 1048576; | ||
154 | } | ||
155 | |||
156 | if (int($avail / 1024) > 0) { | ||
157 | $avail = int($avail / 1024); | ||
158 | if (int($avail /1024) > 0) { | ||
159 | $avail = (int(($avail / 1024)*100))/100; | ||
160 | $avail = $avail."G"; | ||
161 | } else { | ||
162 | $avail = $avail."M"; | ||
163 | } | ||
164 | } else { | ||
165 | $avail = $avail."K"; | ||
166 | } | ||
167 | |||
168 | #print ":$warn:$warn_type:\n"; | ||
169 | #print ":$crit:$crit_type:\n"; | ||
170 | #print ":$avail:$avail_bytes:$capper:$mountpt:\n"; | ||
171 | if ((($warn_type eq "P") && (100 - $capper) < $warn) || (($warn_type eq "K") && ($avail_bytes > $warn))) { | ||
172 | $answer = "Disk ok - $avail ($capper%) free on $mountpt\n"; | ||
173 | } elsif ((($crit_type eq "P") && (100 - $capper) < $crit) || (($crit_type eq "K") && ($avail_bytes > $crit))) { | ||
174 | $state = "WARNING"; | ||
175 | $answer = "Only $avail ($capper%) free on $mountpt\n"; | ||
176 | } else { | ||
177 | $state = "CRITICAL"; | ||
178 | $answer = "Only $avail ($capper%) free on $mountpt\n"; | ||
179 | } | ||
180 | } else { | ||
181 | $answer = "Result from smbclient not suitable\n"; | ||
182 | $state = "UNKNOWN"; | ||
183 | foreach (@lines) { | ||
184 | if (/Access denied/) { | ||
185 | $answer = "Access Denied\n"; | ||
186 | $state = "CRITICAL"; | ||
187 | last; | ||
188 | } | ||
189 | if (/(Unknown host \w*)/) { | ||
190 | $answer = "$1\n"; | ||
191 | $state = "CRITICAL"; | ||
192 | last; | ||
193 | } | ||
194 | if (/(You specified an invalid share name)/) { | ||
195 | $answer = "Invalid share name \\\\$host\\$share\n"; | ||
196 | $state = "CRITICAL"; | ||
197 | last; | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | |||
202 | |||
203 | print $answer; | ||
204 | print "$state\n" if ($verbose); | ||
205 | exit $ERRORS{$state}; | ||
206 | |||
207 | sub print_usage () { | ||
208 | print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password> | ||
209 | -w <warn> -c <crit> [-W <workgroup>]\n"; | ||
210 | } | ||
211 | |||
212 | sub print_help () { | ||
213 | print_revision($PROGNAME,'$Revision$'); | ||
214 | print "Copyright (c) 2000 Michael Anthon/Karl DeBisschop | ||
215 | |||
216 | Perl Check SMB Disk plugin for Nagios | ||
217 | |||
218 | "; | ||
219 | print_usage(); | ||
220 | print " | ||
221 | -H, --hostname=HOST | ||
222 | NetBIOS name of the server | ||
223 | -s, --share=STRING | ||
224 | Share name to be tested | ||
225 | -W, --workgroup=STRING | ||
226 | Workgroup or Domain used (Defaults to \"WORKGROUP\") | ||
227 | -u, --user=STRING | ||
228 | Username to log in to server. (Defaults to \"guest\") | ||
229 | -p, --password=STRING | ||
230 | Password to log in to server. (Defaults to \"guest\") | ||
231 | -w, --warning=INTEGER | ||
232 | Percent of used space at which a warning will be generated (Default: 85%) | ||
233 | |||
234 | -c, --critical=INTEGER | ||
235 | Percent of used space at which a critical will be generated (Defaults: 95%) | ||
236 | |||
237 | |||
238 | "; | ||
239 | support(); | ||
240 | } | ||
diff --git a/plugins-scripts/check_flexlm.pl b/plugins-scripts/check_flexlm.pl new file mode 100755 index 00000000..1d26b7c8 --- /dev/null +++ b/plugins-scripts/check_flexlm.pl | |||
@@ -0,0 +1,149 @@ | |||
1 | #! /usr/bin/perl -wT | ||
2 | # | ||
3 | # usage: | ||
4 | # check_flexlm.pl license_file | ||
5 | # | ||
6 | # Check available flexlm license managers. | ||
7 | # Use lmstat to check the status of the license server | ||
8 | # described by the license file given as argument. | ||
9 | # Check and interpret the output of lmstat | ||
10 | # and create returncodes and output. | ||
11 | # | ||
12 | # Contrary to the nagios concept, this script takes | ||
13 | # a file, not a hostname as an argument and returns | ||
14 | # the status of hosts and services described in that | ||
15 | # file. Use these hosts.cfg entries as an example | ||
16 | # | ||
17 | #host[anchor]=any host will do;some.address.com;;check-host-alive;3;120;24x7;1;1;1; | ||
18 | #service[anchor]=yodel;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yodel_lic | ||
19 | #service[anchor]=yeehaw;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yeehaw_lic | ||
20 | #command[check_flexlm]=/some/path/libexec/check_flexlm.pl $ARG1$ | ||
21 | # | ||
22 | # Notes: | ||
23 | # - you need the lmstat utility which comes with flexlm. | ||
24 | # - set the correct path in the variable $lmstat. | ||
25 | # | ||
26 | # initial version: 9-10-99 Ernst-Dieter Martin edmt@infineon.com | ||
27 | # | ||
28 | # License: GPL | ||
29 | # | ||
30 | |||
31 | BEGIN { | ||
32 | if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { | ||
33 | $runtimedir = $1; | ||
34 | $PROGNAME = $2; | ||
35 | } | ||
36 | } | ||
37 | |||
38 | use strict; | ||
39 | use Getopt::Long; | ||
40 | use vars qw($opt_V $opt_h $opt_F $verbose $PROGNAME); | ||
41 | use lib $main::runtimedir; | ||
42 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); | ||
43 | |||
44 | sub print_help (); | ||
45 | sub print_usage (); | ||
46 | |||
47 | $ENV{'PATH'}=''; | ||
48 | $ENV{'BASH_ENV'}=''; | ||
49 | $ENV{'ENV'}=''; | ||
50 | |||
51 | Getopt::Long::Configure('bundling'); | ||
52 | GetOptions | ||
53 | ("V" => \$opt_V, "version" => \$opt_V, | ||
54 | "h" => \$opt_h, "help" => \$opt_h, | ||
55 | "v" => \$verbose, "verbose" => \$verbose, | ||
56 | "F=s" => \$opt_F, "filename=s" => \$opt_F); | ||
57 | |||
58 | if ($opt_V) { | ||
59 | print_revision($PROGNAME,'$Revision$'); | ||
60 | exit $ERRORS{'OK'}; | ||
61 | } | ||
62 | |||
63 | if ($opt_h) {print_help(); exit $ERRORS{'OK'};} | ||
64 | |||
65 | # Just in case of problems, let's not hang Nagios | ||
66 | $SIG{'ALRM'} = sub { | ||
67 | print "No Answer from Client\n"; | ||
68 | exit 2; | ||
69 | }; | ||
70 | alarm($TIMEOUT); | ||
71 | |||
72 | my $lmstat = "/opt/lic/sw/cadadm/default/bin/lmstat"; | ||
73 | |||
74 | ($opt_F) || ($opt_F = shift) || usage("License file not specified\n"); | ||
75 | my $licfile = $1 if ($opt_F =~ /^(.*)$/); | ||
76 | ($licfile) || usage("Invalid filename: $opt_F\n"); | ||
77 | |||
78 | print "$licfile\n" if $verbose; | ||
79 | |||
80 | open CMD,"$lmstat -c $licfile |"; | ||
81 | |||
82 | my $serverup = 0; | ||
83 | my ($ls1,$ls2,$ls3,$lf1,$lf2,$lf3,$servers); | ||
84 | |||
85 | while ( <CMD> ) { | ||
86 | if ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*)/ ) { | ||
87 | $ls1 = $1; | ||
88 | $ls2 = $2; | ||
89 | $ls3 = $3; | ||
90 | $lf1 = $lf2 = $lf3 = 0; | ||
91 | $servers = 3; | ||
92 | } elsif ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*)/ ) { | ||
93 | $ls1 = $1; | ||
94 | $ls2 = $ls3 = ""; | ||
95 | $lf1 = $lf2 = $lf3 = 0; | ||
96 | $servers = 1; | ||
97 | } elsif ( / *$ls1: license server UP/ ) { | ||
98 | print "$ls1 UP, "; | ||
99 | $lf1 = 1 | ||
100 | } elsif ( / *$ls2: license server UP/ ) { | ||
101 | print "$ls2 UP, "; | ||
102 | $lf2 = 1 | ||
103 | } elsif ( / *$ls3: license server UP/ ) { | ||
104 | print "$ls3 UP, "; | ||
105 | $lf3 = 1 | ||
106 | } elsif ( / *([^:]*: UP .*)/ ) { | ||
107 | print " license server for $1\n"; | ||
108 | $serverup = 1; | ||
109 | } | ||
110 | } | ||
111 | if ( $serverup == 0 ) { | ||
112 | print " license server not running\n"; | ||
113 | exit 2; | ||
114 | } | ||
115 | |||
116 | exit $ERRORS{'OK'} if ( $servers == $lf1 + $lf2 + $lf3 ); | ||
117 | exit $ERRORS{'WARNING'} if ( $servers == 3 && $lf1 + $lf2 + $lf3 == 2 ); | ||
118 | exit $ERRORS{'CRITICAL'}; | ||
119 | |||
120 | |||
121 | sub print_usage () { | ||
122 | print "Usage: | ||
123 | $PROGNAME -F <filename> [--verbose] | ||
124 | $PROGNAME --help | ||
125 | $PROGNAME --version | ||
126 | "; | ||
127 | } | ||
128 | |||
129 | sub print_help () { | ||
130 | print_revision($PROGNAME,'$Revision$'); | ||
131 | print "Copyright (c) 2000 Ernst-Dieter Martin/Karl DeBisschop | ||
132 | |||
133 | Check available flexlm license managers | ||
134 | |||
135 | "; | ||
136 | print_usage(); | ||
137 | print " | ||
138 | -F, --filename=FILE | ||
139 | Name of license file | ||
140 | -v, --verbose | ||
141 | Print some extra debugging information (not advised for normal operation) | ||
142 | -V, --version | ||
143 | Show version and license information | ||
144 | -h, --help | ||
145 | Show this help screen | ||
146 | |||
147 | "; | ||
148 | support(); | ||
149 | } | ||
diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl new file mode 100755 index 00000000..e4c4bd02 --- /dev/null +++ b/plugins-scripts/check_ircd.pl | |||
@@ -0,0 +1,257 @@ | |||
1 | #!/usr/bin/perl -wT | ||
2 | |||
3 | # ----------------------------------------------------------------------------- | ||
4 | # File Name: check_ircd.pl | ||
5 | # | ||
6 | # Author: Richard Mayhew - South Africa | ||
7 | # | ||
8 | # Date: 1999/09/20 | ||
9 | # | ||
10 | # $Id$ | ||
11 | # | ||
12 | # Description: This script will check to see if an IRCD is running | ||
13 | # about how many users it has | ||
14 | # | ||
15 | # Email: netsaint@splash.co.za | ||
16 | # | ||
17 | # ----------------------------------------------------------------------------- | ||
18 | # Copyright 1999 (c) Richard Mayhew | ||
19 | # | ||
20 | # Credits go to Ethan Galstad for coding Nagios | ||
21 | # | ||
22 | # If any changes are made to this script, please mail me a copy of the | ||
23 | # changes :) | ||
24 | # | ||
25 | # Some code taken from Charlie Cook (check_disk.pl) | ||
26 | # | ||
27 | # License GPL | ||
28 | # | ||
29 | # ----------------------------------------------------------------------------- | ||
30 | # Date Author Reason | ||
31 | # ---- ------ ------ | ||
32 | # | ||
33 | # 1999/09/20 RM Creation | ||
34 | # | ||
35 | # 1999/09/20 TP Changed script to use strict, more secure by | ||
36 | # specifying $ENV variables. The bind command is | ||
37 | # still insecure through. Did most of my work | ||
38 | # with perl -wT and 'use strict' | ||
39 | # | ||
40 | # test using check_ircd.pl (irc-2.mit.edu|irc.erols.com|irc.core.com) | ||
41 | # | ||
42 | # ------------------------------------------------------------------[ Begin ]-- | ||
43 | |||
44 | BEGIN { | ||
45 | if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { | ||
46 | $runtimedir = $1; | ||
47 | $PROGNAME = $2; | ||
48 | } | ||
49 | } | ||
50 | |||
51 | # ----------------------------------------------------------------[ Require ]-- | ||
52 | |||
53 | require 5.004; | ||
54 | |||
55 | # -------------------------------------------------------------------[ Uses ]-- | ||
56 | |||
57 | use Socket; | ||
58 | use strict; | ||
59 | use Getopt::Long; | ||
60 | use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose); | ||
61 | use vars qw($PROGNAME); | ||
62 | use lib $main::runtimedir; | ||
63 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); | ||
64 | |||
65 | # ----------------------------------------------------[ Function Prototypes ]-- | ||
66 | |||
67 | sub print_help (); | ||
68 | sub print_usage (); | ||
69 | sub connection ($$$$); | ||
70 | sub bindRemote ($$$); | ||
71 | |||
72 | # -------------------------------------------------------------[ Enviroment ]-- | ||
73 | |||
74 | $ENV{PATH} = ""; | ||
75 | $ENV{ENV} = ""; | ||
76 | $ENV{BASH_ENV} = ""; | ||
77 | |||
78 | # -----------------------------------------------------------------[ Global ]-- | ||
79 | |||
80 | my $NICK="ircd$$"; | ||
81 | my $USER_INFO="monitor localhost localhost : "; | ||
82 | |||
83 | # -------------------------------------------------------------[ connection ]-- | ||
84 | sub connection ($$$$) | ||
85 | { | ||
86 | my ($in_remotehost,$in_users,$in_warn,$in_crit) = @_; | ||
87 | my $state; | ||
88 | my $answer; | ||
89 | |||
90 | print "connection(debug): users = $in_users\n" if $verbose; | ||
91 | $in_users =~ s/\ //g; | ||
92 | |||
93 | if ($in_users >= 0) { | ||
94 | |||
95 | if ($in_users > $in_crit) { | ||
96 | $state = "CRITICAL"; | ||
97 | $answer = "Critical Number Of Clients Connected : $in_users (Limit = $in_crit)\n"; | ||
98 | |||
99 | } elsif ($in_users > $in_warn) { | ||
100 | $state = "WARNING"; | ||
101 | $answer = "Warning Number Of Clients Connected : $in_users (Limit = $in_warn)\n"; | ||
102 | |||
103 | } else { | ||
104 | $state = "OK"; | ||
105 | $answer = "IRCD ok - Current Local Users: $in_users\n"; | ||
106 | } | ||
107 | |||
108 | } else { | ||
109 | $state = "UNKNOWN"; | ||
110 | $answer = "Server $in_remotehost has less than 0 users! Something is Really WRONG!\n"; | ||
111 | } | ||
112 | |||
113 | print ClientSocket "quit\n"; | ||
114 | print $answer; | ||
115 | exit $ERRORS{$state}; | ||
116 | } | ||
117 | |||
118 | # ------------------------------------------------------------[ print_usage ]-- | ||
119 | |||
120 | sub print_usage () { | ||
121 | print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>] [-p <port>]\n"; | ||
122 | } | ||
123 | |||
124 | # -------------------------------------------------------------[ print_help ]-- | ||
125 | |||
126 | sub print_help () | ||
127 | { | ||
128 | print_revision($PROGNAME,'$Revision$ '); | ||
129 | print "Copyright (c) 2000 Richard Mayhew/Karl DeBisschop | ||
130 | |||
131 | Perl Check IRCD plugin for Nagios | ||
132 | |||
133 | "; | ||
134 | print_usage(); | ||
135 | print " | ||
136 | -H, --hostname=HOST | ||
137 | Name or IP address of host to check | ||
138 | -w, --warning=INTEGER | ||
139 | Number of connected users which generates a warning state (Default: 50) | ||
140 | -c, --critical=INTEGER | ||
141 | Number of connected users which generates a critical state (Default: 100) | ||
142 | -p, --port=INTEGER | ||
143 | Port that the ircd daemon is running on <host> (Default: 6667) | ||
144 | -v, --verbose | ||
145 | Print extra debugging information | ||
146 | "; | ||
147 | } | ||
148 | |||
149 | # -------------------------------------------------------------[ bindRemote ]-- | ||
150 | |||
151 | sub bindRemote ($$$) | ||
152 | { | ||
153 | my ($in_remotehost, $in_remoteport, $in_hostname) = @_; | ||
154 | my $proto = getprotobyname('tcp'); | ||
155 | my $sockaddr; | ||
156 | my $this; | ||
157 | my $thisaddr = gethostbyname($in_hostname); | ||
158 | my $that; | ||
159 | my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost); | ||
160 | # ($name,$aliases,$type,$len,$thisaddr) = gethostbyname($in_hostname); | ||
161 | |||
162 | if (!socket(ClientSocket,AF_INET, SOCK_STREAM, $proto)) { | ||
163 | print "IRCD UNKNOWN: Could not start socket ($!)\n"; | ||
164 | exit $ERRORS{"UNKNOWN"}; | ||
165 | } | ||
166 | $sockaddr = 'S n a4 x8'; | ||
167 | $this = pack($sockaddr, AF_INET, 0, $thisaddr); | ||
168 | $that = pack($sockaddr, AF_INET, $in_remoteport, $thataddr); | ||
169 | if (!bind(ClientSocket, $this)) { | ||
170 | print "IRCD UNKNOWN: Could not bind socket ($!)\n"; | ||
171 | exit $ERRORS{"UNKNOWN"}; | ||
172 | } | ||
173 | if (!connect(ClientSocket, $that)) { | ||
174 | print "IRCD UNKNOWN: Could not connect socket ($!)\n"; | ||
175 | exit $ERRORS{"UNKNOWN"}; | ||
176 | } | ||
177 | select(ClientSocket); $| = 1; select(STDOUT); | ||
178 | return \*ClientSocket; | ||
179 | } | ||
180 | |||
181 | # ===================================================================[ MAIN ]== | ||
182 | |||
183 | MAIN: | ||
184 | { | ||
185 | my $hostname; | ||
186 | |||
187 | Getopt::Long::Configure('bundling'); | ||
188 | GetOptions | ||
189 | ("V" => \$opt_V, "version" => \$opt_V, | ||
190 | "h" => \$opt_h, "help" => \$opt_h, | ||
191 | "v" => \$verbose,"verbose" => \$verbose, | ||
192 | "t=i" => \$opt_t, "timeout=i" => \$opt_t, | ||
193 | "w=i" => \$opt_w, "warning=i" => \$opt_w, | ||
194 | "c=i" => \$opt_c, "critical=i" => \$opt_c, | ||
195 | "p=i" => \$opt_p, "port=i" => \$opt_p, | ||
196 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); | ||
197 | |||
198 | if ($opt_V) { | ||
199 | print_revision($PROGNAME,'$Revision$ '); | ||
200 | exit $ERRORS{'OK'}; | ||
201 | } | ||
202 | |||
203 | if ($opt_h) {print_help(); exit $ERRORS{'OK'};} | ||
204 | |||
205 | ($opt_H) || ($opt_H = shift) || usage("Host name/address not specified\n"); | ||
206 | my $remotehost = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/); | ||
207 | ($remotehost) || usage("Invalid host: $opt_H\n"); | ||
208 | |||
209 | ($opt_w) || ($opt_w = shift) || ($opt_w = 50); | ||
210 | my $warn = $1 if ($opt_w =~ /^([0-9]+)$/); | ||
211 | ($warn) || usage("Invalid warning threshold: $opt_w\n"); | ||
212 | |||
213 | ($opt_c) || ($opt_c = shift) || ($opt_c = 100); | ||
214 | my $crit = $1 if ($opt_c =~ /^([0-9]+)$/); | ||
215 | ($crit) || usage("Invalid critical threshold: $opt_c\n"); | ||
216 | |||
217 | ($opt_p) || ($opt_p = shift) || ($opt_p = 6667); | ||
218 | my $remoteport = $1 if ($opt_p =~ /^([0-9]+)$/); | ||
219 | ($remoteport) || usage("Invalid port: $opt_p\n"); | ||
220 | |||
221 | if ($opt_t && $opt_t =~ /^([0-9]+)$/) { $TIMEOUT = $1; } | ||
222 | |||
223 | # Just in case of problems, let's not hang Nagios | ||
224 | $SIG{'ALRM'} = sub { | ||
225 | print "Somthing is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n"; | ||
226 | exit $ERRORS{"UNKNOWN"}; | ||
227 | }; | ||
228 | |||
229 | alarm($TIMEOUT); | ||
230 | |||
231 | chomp($hostname = `/bin/hostname`); | ||
232 | $hostname = $1 if ($hostname =~ /([-.a-zA-Z0-9]+)/); | ||
233 | my ($name, $alias, $proto) = getprotobyname('tcp'); | ||
234 | print "MAIN(debug): hostname = $hostname\n" if $verbose; | ||
235 | |||
236 | print "MAIN(debug): binding to remote host: $remotehost -> $remoteport -> $hostname\n" if $verbose; | ||
237 | my $ClientSocket = &bindRemote($remotehost,$remoteport,$hostname); | ||
238 | |||
239 | print ClientSocket "NICK $NICK\nUSER $USER_INFO\n"; | ||
240 | |||
241 | while (<ClientSocket>) { | ||
242 | print "MAIN(debug): default var = $_\n" if $verbose; | ||
243 | |||
244 | # DALnet,LagNet,UnderNet etc. Require this! | ||
245 | # Replies with a PONG when presented with a PING query. | ||
246 | # If a server doesn't require it, it will be ignored. | ||
247 | |||
248 | if (m/^PING (.*)/) {print ClientSocket "PONG $1\n";} | ||
249 | |||
250 | alarm(0); | ||
251 | |||
252 | # Look for pattern in IRCD Output to gather Client Connections total. | ||
253 | connection($remotehost,$1,$warn,$crit) if (m/:I have\s+(\d+)/); | ||
254 | } | ||
255 | print "IRCD UNKNOWN: Unknown error - maybe could not authenticate\n"; | ||
256 | exit $ERRORS{"UNKNOWN"}; | ||
257 | } | ||
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh new file mode 100755 index 00000000..08e7fef6 --- /dev/null +++ b/plugins-scripts/check_log.sh | |||
@@ -0,0 +1,214 @@ | |||
1 | #! /bin/sh | ||
2 | # | ||
3 | # Log file pattern detector plugin for Nagios | ||
4 | # Written by Ethan Galstad (nagios@nagios.org) | ||
5 | # Last Modified: 07-31-1999 | ||
6 | # | ||
7 | # Usage: ./check_log <log_file> <old_log_file> <pattern> | ||
8 | # | ||
9 | # Description: | ||
10 | # | ||
11 | # This plugin will scan a log file (specified by the <log_file> option) | ||
12 | # for a specific pattern (specified by the <pattern> option). Successive | ||
13 | # calls to the plugin script will only report *new* pattern matches in the | ||
14 | # log file, since an copy of the log file from the previous run is saved | ||
15 | # to <old_log_file>. | ||
16 | # | ||
17 | # Output: | ||
18 | # | ||
19 | # On the first run of the plugin, it will return an OK state with a message | ||
20 | # of "Log check data initialized". On successive runs, it will return an OK | ||
21 | # state if *no* pattern matches have been found in the *difference* between the | ||
22 | # log file and the older copy of the log file. If the plugin detects any | ||
23 | # pattern matches in the log diff, it will return a CRITICAL state and print | ||
24 | # out a message is the following format: "(x) last_match", where "x" is the | ||
25 | # total number of pattern matches found in the file and "last_match" is the | ||
26 | # last entry in the log file which matches the pattern. | ||
27 | # | ||
28 | # Notes: | ||
29 | # | ||
30 | # If you use this plugin make sure to keep the following in mind: | ||
31 | # | ||
32 | # 1. The "max_attempts" value for the service should be 1, as this | ||
33 | # will prevent Nagios from retrying the service check (the | ||
34 | # next time the check is run it will not produce the same results). | ||
35 | # | ||
36 | # 2. The "notify_recovery" value for the service should be 0, so that | ||
37 | # Nagios does not notify you of "recoveries" for the check. Since | ||
38 | # pattern matches in the log file will only be reported once and not | ||
39 | # the next time, there will always be "recoveries" for the service, even | ||
40 | # though recoveries really don't apply to this type of check. | ||
41 | # | ||
42 | # 3. You *must* supply a different <old_file_log> for each service that | ||
43 | # you define to use this plugin script - even if the different services | ||
44 | # check the same <log_file> for pattern matches. This is necessary | ||
45 | # because of the way the script operates. | ||
46 | # | ||
47 | # Examples: | ||
48 | # | ||
49 | # Check for login failures in the syslog... | ||
50 | # | ||
51 | # check_log /var/log/messages ./check_log.badlogins.old "LOGIN FAILURE" | ||
52 | # | ||
53 | # Check for port scan alerts generated by Psionic's PortSentry software... | ||
54 | # | ||
55 | # check_log /var/log/message ./check_log.portscan.old "attackalert" | ||
56 | # | ||
57 | |||
58 | # Paths to commands used in this script. These | ||
59 | # may have to be modified to match your system setup. | ||
60 | |||
61 | PATH="" | ||
62 | |||
63 | ECHO="/bin/echo" | ||
64 | GREP="/bin/grep" | ||
65 | DIFF="/bin/diff" | ||
66 | TAIL="/bin/tail" | ||
67 | CAT="/bin/cat" | ||
68 | RM="/bin/rm" | ||
69 | |||
70 | PROGNAME=`/bin/basename $0` | ||
71 | PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'` | ||
72 | REVISION=`echo '$Revision$' | /bin/sed -e 's/[^0-9.]//g'` | ||
73 | |||
74 | . $PROGPATH/utils.sh | ||
75 | |||
76 | print_usage() { | ||
77 | echo "Usage: $PROGNAME -F logfile -O oldlog -q query" | ||
78 | echo "Usage: $PROGNAME --help" | ||
79 | echo "Usage: $PROGNAME --version" | ||
80 | } | ||
81 | |||
82 | print_help() { | ||
83 | print_revision $PROGNAME $REVISION | ||
84 | echo "" | ||
85 | print_usage | ||
86 | echo "" | ||
87 | echo "Log file pattern detector plugin for Nagios" | ||
88 | echo "" | ||
89 | support | ||
90 | } | ||
91 | |||
92 | # Make sure the correct number of command line | ||
93 | # arguments have been supplied | ||
94 | |||
95 | if [ $# -lt 1 ]; then | ||
96 | print_usage | ||
97 | exit $STATE_UNKNOWN | ||
98 | fi | ||
99 | |||
100 | # Grab the command line arguments | ||
101 | |||
102 | #logfile=$1 | ||
103 | #oldlog=$2 | ||
104 | #query=$3 | ||
105 | exitstatus=$STATE_WARNING #default | ||
106 | while test -n "$1"; do | ||
107 | case "$1" in | ||
108 | --help) | ||
109 | print_help | ||
110 | exit $STATE_OK | ||
111 | ;; | ||
112 | -h) | ||
113 | print_help | ||
114 | exit $STATE_OK | ||
115 | ;; | ||
116 | --version) | ||
117 | print_revision $PROGNAME $VERSION | ||
118 | exit $STATE_OK | ||
119 | ;; | ||
120 | -V) | ||
121 | print_revision $PROGNAME $VERSION | ||
122 | exit $STATE_OK | ||
123 | ;; | ||
124 | --filename) | ||
125 | logfile=$2 | ||
126 | shift | ||
127 | ;; | ||
128 | -F) | ||
129 | logfile=$2 | ||
130 | shift | ||
131 | ;; | ||
132 | --oldlog) | ||
133 | oldlog=$2 | ||
134 | shift | ||
135 | ;; | ||
136 | -O) | ||
137 | oldlog=$2 | ||
138 | shift | ||
139 | ;; | ||
140 | --query) | ||
141 | query=$2 | ||
142 | shift | ||
143 | ;; | ||
144 | -q) | ||
145 | query=$2 | ||
146 | shift | ||
147 | ;; | ||
148 | -x) | ||
149 | exitstatus=$2 | ||
150 | shift | ||
151 | ;; | ||
152 | --exitstatus) | ||
153 | exitstatus=$2 | ||
154 | shift | ||
155 | ;; | ||
156 | *) | ||
157 | echo "Unknown argument: $1" | ||
158 | print_usage | ||
159 | exit $STATE_UNKNOWN | ||
160 | ;; | ||
161 | esac | ||
162 | shift | ||
163 | done | ||
164 | |||
165 | # If the source log file doesn't exist, exit | ||
166 | |||
167 | if [ ! -e $logfile ]; then | ||
168 | $ECHO "Log check error: Log file $logfile does not exist!\n" | ||
169 | exit 2 | ||
170 | fi | ||
171 | |||
172 | # If the old log file doesn't exist, this must be the first time | ||
173 | # we're running this test, so copy the original log file over to | ||
174 | # the old diff file and exit | ||
175 | |||
176 | if [ ! -e $oldlog ]; then | ||
177 | $CAT $logfile > $oldlog | ||
178 | $ECHO "Log check data initialized...\n" | ||
179 | exit 0 | ||
180 | fi | ||
181 | |||
182 | # The old log file exists, so compare it to the original log now | ||
183 | |||
184 | # The temporary file that the script should use while | ||
185 | # processing the log file. | ||
186 | if [-x /bin/mktemp]; then | ||
187 | tempdiff="/bin/mktemp /tmp/check_log.XXXXXXXXXX" | ||
188 | else | ||
189 | tempdiff="/tmp/check_log.`/bin/date '+%H%M%S'`" | ||
190 | /bin/touch $tempdiff | ||
191 | chmod 600 $tempdiff | ||
192 | fi | ||
193 | |||
194 | $DIFF $logfile $oldlog > $tempdiff | ||
195 | |||
196 | # Count the number of matching log entries we have | ||
197 | count=`$GREP -c "$query" $tempdiff` | ||
198 | |||
199 | # Get the last matching entry in the diff file | ||
200 | lastentry=`$GREP "$query" $tempdiff | $TAIL --lines=1` | ||
201 | |||
202 | $RM -f $tempdiff | ||
203 | $CAT $logfile > $oldlog | ||
204 | |||
205 | if [ "$count" = "0" ]; then # no matches, exit with no error | ||
206 | $ECHO "Log check ok - 0 pattern matches found\n" | ||
207 | exitstatus=0 | ||
208 | else # Print total matche count and the last entry we found | ||
209 | $ECHO "($count) $lastentry" | ||
210 | fi | ||
211 | |||
212 | exit exitstatus | ||
213 | |||
214 | |||
diff --git a/plugins-scripts/check_netdns.pl b/plugins-scripts/check_netdns.pl new file mode 100755 index 00000000..4bf7bd76 --- /dev/null +++ b/plugins-scripts/check_netdns.pl | |||
@@ -0,0 +1,129 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | |||
3 | # Perl version of check_dns plugin which calls DNS directly instead of | ||
4 | # relying on nslookup (which has bugs) | ||
5 | # | ||
6 | # Copyright 2000, virCIO, LLP | ||
7 | # | ||
8 | # $Log$ | ||
9 | # Revision 1.1 2002/02/28 06:43:00 egalstad | ||
10 | # Initial revision | ||
11 | # | ||
12 | # Revision 1.1 2000/08/03 20:41:12 karldebisschop | ||
13 | # rename to avoid conflict when installing | ||
14 | # | ||
15 | # Revision 1.1 2000/08/03 19:27:08 karldebisschop | ||
16 | # use Net::DNS to check name server | ||
17 | # | ||
18 | # Revision 1.1 2000/07/20 19:09:13 cwg | ||
19 | # All the pieces needed to use my version of check_dns. | ||
20 | # | ||
21 | |||
22 | use Getopt::Long; | ||
23 | use Net::DNS; | ||
24 | |||
25 | Getopt::Long::Configure(`bundling`); | ||
26 | GetOptions("V" => $opt_V, "version" => $opt_V, | ||
27 | "h" => $opt_h, "help" => $opt_h, | ||
28 | "t=i" => $opt_t, "timeout=i" => $opt_t, | ||
29 | "s=s" => $opt_s, "server=s" => $opt_s, | ||
30 | "H=s" => $opt_H, "hostname=s" => $opt_H); | ||
31 | |||
32 | # -h means display verbose help screen | ||
33 | if($opt_h){ print_help(); exit 0; } | ||
34 | |||
35 | # -V means display version number | ||
36 | if ($opt_V) { print_version(); exit 0; } | ||
37 | |||
38 | # -H means host name | ||
39 | $opt_H = shift unless ($opt_H); | ||
40 | unless ($opt_H) { print_usage(); exit -1; } | ||
41 | if ($opt_H && | ||
42 | $opt_H =~ m/^([0-9]+.[0-9]+.[0-9]+.[0-9]+|[a-zA-Z][-a-zA-Z0]+(.[a-zA-Z][-a-zA-Z0]+)*)$/) | ||
43 | { | ||
44 | $host = $1; | ||
45 | } else { | ||
46 | print "$opt_H is not a valid host name"; | ||
47 | exit -1; | ||
48 | } | ||
49 | |||
50 | # -s means server name | ||
51 | $opt_s = shift unless ($opt_s); | ||
52 | if ($opt_s) { | ||
53 | if ($opt_s =~ m/^([0-9]+.[0-9]+.[0-9]+.[0-9]+|[a-zA-Z][-a-zA-Z0]+(.[a-zA-Z][-a-zA-Z0]+)*)$/) | ||
54 | { | ||
55 | $server = $1; | ||
56 | } else { | ||
57 | print "$opt_s is not a valid host name"; | ||
58 | exit -1; | ||
59 | } | ||
60 | } | ||
61 | |||
62 | # -t means timeout | ||
63 | my $timeout = 10 unless ($opt_t); | ||
64 | |||
65 | my $res = new Net::DNS::Resolver; | ||
66 | #$res->debug(1); | ||
67 | if ($server) { | ||
68 | $res->nameservers($server); | ||
69 | } | ||
70 | |||
71 | $res->tcp_timeout($timeout); | ||
72 | $SIG{ALRM} = &catch_alarm; | ||
73 | alarm($timeout); | ||
74 | |||
75 | $query = $res->query($host); | ||
76 | if ($query) { | ||
77 | my @answer = $query->answer; | ||
78 | if (@answer) { | ||
79 | print join(`/`, map { | ||
80 | $_->type . ` ` . $_->rdatastr; | ||
81 | } @answer); | ||
82 | exit 0; | ||
83 | } else { | ||
84 | print "empty answer"; | ||
85 | exit 2; | ||
86 | } | ||
87 | } | ||
88 | else { | ||
89 | print "query failed: ", $res->errorstring, ""; | ||
90 | exit 2; | ||
91 | } | ||
92 | |||
93 | sub catch_alarm { | ||
94 | print "query timed out"; | ||
95 | exit 2; | ||
96 | } | ||
97 | |||
98 | sub print_version () { | ||
99 | my $arg0 = $0; | ||
100 | chomp $arg0; | ||
101 | print "$arg0 version 0.1"; | ||
102 | } | ||
103 | sub print_help() { | ||
104 | print_version(); | ||
105 | print ""; | ||
106 | print "Check if a nameserver can resolve a given hostname."; | ||
107 | print ""; | ||
108 | print_usage(); | ||
109 | print ""; | ||
110 | print "-H, --hostname=HOST"; | ||
111 | print " The name or address you want to query"; | ||
112 | print "-s, --server=HOST"; | ||
113 | print " Optional DNS server you want to use for the lookup"; | ||
114 | print "-t, --timeout=INTEGER"; | ||
115 | print " Seconds before connection times out (default: 10)"; | ||
116 | print "-h, --help"; | ||
117 | print " Print detailed help"; | ||
118 | print "-V, --version"; | ||
119 | print " Print version numbers and license information"; | ||
120 | } | ||
121 | |||
122 | sub print_usage () { | ||
123 | my $arg0 = $0; | ||
124 | chomp $arg0; | ||
125 | print "$arg0 check_dns -H host [-s server] [-t timeout]"; | ||
126 | print "$arg0 [-h | --help]"; | ||
127 | print "$arg0 [-V | --version]"; | ||
128 | } | ||
129 | |||
diff --git a/plugins-scripts/check_nfs.pl b/plugins-scripts/check_nfs.pl new file mode 100755 index 00000000..040466d3 --- /dev/null +++ b/plugins-scripts/check_nfs.pl | |||
@@ -0,0 +1,48 @@ | |||
1 | #!/usr/local/bin/perl | ||
2 | # | ||
3 | # check_nfs plugin for nagios | ||
4 | # | ||
5 | # usage: | ||
6 | # check_nfs.pl server | ||
7 | # | ||
8 | # Check if a nfs server is registered and running | ||
9 | # using rpcinfo -T udp <arg1> 100003. | ||
10 | # 100003 is the rpc programmnumber for nfs. | ||
11 | # <arg1> is the server queried. | ||
12 | # | ||
13 | # | ||
14 | # Use these hosts.cfg entries as examples | ||
15 | # | ||
16 | #service[fs0]=NFS;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_nfs | ||
17 | #command[check_nfs]=/some/path/libexec/check_nfs.pl $HOSTADDRESS$ | ||
18 | # | ||
19 | # initial version: 9-13-99 Ernst-Dieter Martin edmt@infineon.com | ||
20 | # current status: looks like working | ||
21 | # | ||
22 | # | ||
23 | # Copyright Notice: Do as you please, credit me, but don't blame me | ||
24 | # | ||
25 | |||
26 | |||
27 | $server = shift; | ||
28 | |||
29 | |||
30 | open CMD,"/bin/rpcinfo -T udp $server 100003 |"; | ||
31 | |||
32 | $response = "nfs version "; | ||
33 | |||
34 | while ( <CMD> ) { | ||
35 | if ( /program 100003 version ([0-9]*) ready and waiting/ ) { | ||
36 | $response = $ response . "$1,"; | ||
37 | } | ||
38 | } | ||
39 | |||
40 | if ( $response eq "nfs version " ) { | ||
41 | print "rpcinfo: RPC: Program not registered\n"; | ||
42 | exit 2; | ||
43 | } | ||
44 | |||
45 | $response =~ s/,$//; | ||
46 | print "$response\n"; | ||
47 | |||
48 | exit 0; | ||
diff --git a/plugins-scripts/check_ntp.pl b/plugins-scripts/check_ntp.pl new file mode 100755 index 00000000..f3f6f78b --- /dev/null +++ b/plugins-scripts/check_ntp.pl | |||
@@ -0,0 +1,236 @@ | |||
1 | #! /usr/bin/perl -wT | ||
2 | |||
3 | # (c)1999 Ian Cass, Knowledge Matters Ltd. | ||
4 | # Read the GNU copyright stuff for all the legalese | ||
5 | # | ||
6 | # Check NTP time servers plugin. This plugin requires the ntpdate utility to | ||
7 | # be installed on the system, however since it's part of the ntp suite, you | ||
8 | # should already have it installed. | ||
9 | # | ||
10 | # Nothing clever done in this program - its a very simple bare basics hack to | ||
11 | # get the job done. | ||
12 | # | ||
13 | # Things to do... | ||
14 | # check @words[9] for time differences greater than +/- x secs & return a | ||
15 | # warning. | ||
16 | # | ||
17 | # (c) 1999 Mark Jewiss, Knowledge Matters Limited | ||
18 | # 22-9-1999, 12:45 | ||
19 | # | ||
20 | # Modified script to accept 2 parameters or set defaults. | ||
21 | # Now issues warning or critical alert is time difference is greater than the | ||
22 | # time passed. | ||
23 | # | ||
24 | # These changes have not been tested completely due to the unavailability of a | ||
25 | # server with the incorrect time. | ||
26 | # | ||
27 | # (c) 1999 Bo Kersey, VirCIO - Managed Server Solutions <bo@vircio.com> | ||
28 | # 22-10-99, 12:17 | ||
29 | # | ||
30 | # Modified the script to give useage if no parameters are input. | ||
31 | # | ||
32 | # Modified the script to check for negative as well as positive | ||
33 | # time differences. | ||
34 | # | ||
35 | # Modified the script to work with ntpdate 3-5.93e Wed Apr 14 20:23:03 EDT 1999 | ||
36 | # | ||
37 | # Modified the script to work with ntpdate's that return adjust or offset... | ||
38 | # | ||
39 | # | ||
40 | # Script modified 2000 June 01 by William Pietri <william@bianca.com> | ||
41 | # | ||
42 | # Modified script to handle weird cases: | ||
43 | # o NTP server doesn't respond (e.g., has died) | ||
44 | # o Server has correct time but isn't suitable synchronization | ||
45 | # source. This happens while starting up and if contact | ||
46 | # with master has been lost. | ||
47 | # | ||
48 | BEGIN { | ||
49 | if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { | ||
50 | $runtimedir = $1; | ||
51 | $PROGNAME = $2; | ||
52 | } | ||
53 | } | ||
54 | |||
55 | require 5.004; | ||
56 | use POSIX; | ||
57 | use strict; | ||
58 | use Getopt::Long; | ||
59 | use vars qw($opt_V $opt_h $opt_H $opt_w $opt_c $verbose $PROGNAME); | ||
60 | use lib $main::runtimedir; | ||
61 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | ||
62 | |||
63 | sub print_help (); | ||
64 | sub print_usage (); | ||
65 | |||
66 | $ENV{'PATH'}=''; | ||
67 | $ENV{'BASH_ENV'}=''; | ||
68 | $ENV{'ENV'}=''; | ||
69 | |||
70 | Getopt::Long::Configure('bundling'); | ||
71 | GetOptions | ||
72 | ("V" => \$opt_V, "version" => \$opt_V, | ||
73 | "h" => \$opt_h, "help" => \$opt_h, | ||
74 | "v" => \$verbose, "verbose" => \$verbose, | ||
75 | "w=s" => \$opt_w, "warning=s" => \$opt_w, | ||
76 | "c=s" => \$opt_c, "critical=s" => \$opt_c, | ||
77 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); | ||
78 | |||
79 | if ($opt_V) { | ||
80 | print_revision($PROGNAME,'$Revision$ '); | ||
81 | exit $ERRORS{'OK'}; | ||
82 | } | ||
83 | |||
84 | if ($opt_h) { | ||
85 | print_help(); | ||
86 | exit $ERRORS{'OK'}; | ||
87 | } | ||
88 | |||
89 | $opt_H = shift unless ($opt_H); | ||
90 | my $host = $1 if ($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]+)*)$/); | ||
91 | unless ($host) { | ||
92 | print_usage(); | ||
93 | exit $ERRORS{'UNKNOWN'}; | ||
94 | } | ||
95 | |||
96 | ($opt_w) || ($opt_w = shift) || ($opt_w = 60); | ||
97 | my $warning = $1 if ($opt_w =~ /([0-9]+)/); | ||
98 | |||
99 | ($opt_c) || ($opt_c = shift) || ($opt_c = 120); | ||
100 | my $critical = $1 if ($opt_c =~ /([0-9]+)/); | ||
101 | |||
102 | my $answer = undef; | ||
103 | my $offset = undef; | ||
104 | my $msg; # first line of output to print if format is invalid | ||
105 | |||
106 | my $state = $ERRORS{'UNKNOWN'}; | ||
107 | my $ntpdate_error = $ERRORS{'UNKNOWN'}; | ||
108 | my $dispersion_error = $ERRORS{'UNKNOWN'}; | ||
109 | |||
110 | my $key = undef; | ||
111 | |||
112 | # Just in case of problems, let's not hang Nagios | ||
113 | $SIG{'ALRM'} = sub { | ||
114 | print ("ERROR: No response from ntp server (alarm)\n"); | ||
115 | exit $ERRORS{"UNKNOWN"}; | ||
116 | }; | ||
117 | alarm($TIMEOUT); | ||
118 | |||
119 | |||
120 | ### | ||
121 | ### | ||
122 | ### First, check ntpdate | ||
123 | ### | ||
124 | ### | ||
125 | |||
126 | if (!open (NTPDATE, "/usr/local/sbin/ntpdate -q $host 2>&1 |")) { | ||
127 | print "Could not open ntpdate\n"; | ||
128 | exit $ERRORS{"UNKNOWN"}; | ||
129 | } | ||
130 | |||
131 | while (<NTPDATE>) { | ||
132 | print if ($verbose); | ||
133 | $msg = $_ unless ($msg); | ||
134 | if (/(offset|adjust)\s+([-.\d]+)/i) { | ||
135 | $offset = $2; | ||
136 | last; | ||
137 | } | ||
138 | } | ||
139 | |||
140 | # soak up remaining output; check for error | ||
141 | while (<NTPDATE>) { | ||
142 | if (/no server suitable for synchronization found/) { | ||
143 | $ntpdate_error = $ERRORS{"CRITICAL"}; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | close(NTPDATE); | ||
148 | |||
149 | # only declare an error if we also get a non-zero return code from ntpdate | ||
150 | $ntpdate_error = ($? >> 8) || $ntpdate_error; | ||
151 | |||
152 | ### | ||
153 | ### | ||
154 | ### Then scan xntpdc if it exists | ||
155 | ### | ||
156 | ### | ||
157 | |||
158 | if (#open(NTPDC,"/usr/sbin/ntpdc -c $host 2>&1 |") || | ||
159 | open(NTPDC,"/usr/sbin/xntpdc -c $host 2>&1 |") ) { | ||
160 | while (<NTPDC>) { | ||
161 | print if ($verbose); | ||
162 | if (/([^\s]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/) { | ||
163 | if ($8>15) { | ||
164 | $dispersion_error = $ERRORS{'CRITICAL'}; | ||
165 | } elsif ($8>5 && $dispersion_error<$ERRORS{'CRITICAL'}) { | ||
166 | $dispersion_error = $ERRORS{'WARNING'}; | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | close NTPDC; | ||
171 | } | ||
172 | |||
173 | # An offset of 0.000000 with an error is probably bogus. Actually, | ||
174 | # it's probably always bogus, but let's be paranoid here. | ||
175 | if ($ntpdate_error && $offset && ($offset == 0)) { undef $offset;} | ||
176 | |||
177 | if ($ntpdate_error > $ERRORS{'OK'}) { | ||
178 | $state = $ntpdate_error; | ||
179 | $answer = "Server for ntp probably down\n"; | ||
180 | if (defined($offset) && abs($offset) > $critical) { | ||
181 | $state = $ERRORS{'CRITICAL'}; | ||
182 | $answer = "Server Error and time difference $offset seconds greater than +/- $critical sec\n"; | ||
183 | } elsif (defined($offset) && abs($offset) > $warning) { | ||
184 | $answer = "Server error and time difference $offset seconds greater than +/- $warning sec\n"; | ||
185 | } | ||
186 | |||
187 | } elsif ($dispersion_error > $ERRORS{'OK'}) { | ||
188 | $state = $dispersion_error; | ||
189 | $answer = "Dispersion too high\n"; | ||
190 | if (defined($offset) && abs($offset) > $critical) { | ||
191 | $state = $ERRORS{'CRITICAL'}; | ||
192 | $answer = "Dispersion error and time difference $offset seconds greater than +/- $critical sec\n"; | ||
193 | } elsif (defined($offset) && abs($offset) > $warning) { | ||
194 | $answer = "Dispersion error and time difference $offset seconds greater than +/- $warning sec\n"; | ||
195 | } | ||
196 | |||
197 | } else { # no errors from ntpdate or xntpdc | ||
198 | if (defined $offset) { | ||
199 | if (abs($offset) > $critical) { | ||
200 | $state = $ERRORS{'CRITICAL'}; | ||
201 | $answer = "Time difference $offset seconds greater than +/- $critical sec\n"; | ||
202 | } elsif (abs($offset) > $warning) { | ||
203 | $state = $ERRORS{'WARNING'}; | ||
204 | $answer = "Time difference $offset seconds greater than +/- $warning sec\n"; | ||
205 | } elsif (abs($offset) <= $warning) { | ||
206 | $state = $ERRORS{'OK'}; | ||
207 | $answer = "Time difference $offset seconds\n"; | ||
208 | } | ||
209 | } else { # no offset defined | ||
210 | $state = $ERRORS{'UNKNOWN'}; | ||
211 | $answer = "Invalid format returned from ntpdate ($msg)\n"; | ||
212 | } | ||
213 | } | ||
214 | |||
215 | foreach $key (keys %ERRORS) { | ||
216 | if ($state==$ERRORS{$key}) { | ||
217 | print ("$key: $answer"); | ||
218 | last; | ||
219 | } | ||
220 | } | ||
221 | exit $state; | ||
222 | |||
223 | sub print_usage () { | ||
224 | print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>]\n"; | ||
225 | } | ||
226 | |||
227 | sub print_help () { | ||
228 | print_revision($PROGNAME,'$Revision$'); | ||
229 | print "Copyright (c) 2000 Bo Kersey/Karl DeBisschop\n"; | ||
230 | print "\n"; | ||
231 | print_usage(); | ||
232 | print "\n"; | ||
233 | print "<warn> = Clock offset in seconds at which a warning message will be generated.\n Defaults to 60.\n"; | ||
234 | print "<crit> = Clock offset in seconds at which a critical message will be generated.\n Defaults to 120.\n\n"; | ||
235 | support(); | ||
236 | } | ||
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh new file mode 100755 index 00000000..1a4d8ab6 --- /dev/null +++ b/plugins-scripts/check_oracle.sh | |||
@@ -0,0 +1,126 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # latigid010@yahoo.com | ||
4 | # 01/06/2000 | ||
5 | # | ||
6 | # This Nagios plugin was created to check remote or local TNS | ||
7 | # status and check local Database status. | ||
8 | # | ||
9 | # Add the following lines to your object config file (i.e. commands.cfg) | ||
10 | # command[check-tns]=/usr/local/nagios/libexec/check_ora 1 $ARG$ | ||
11 | # command[check-oradb]=/usr/local/nagios/libexec/check_ora 2 $ARG$ | ||
12 | # | ||
13 | # | ||
14 | # Usage: | ||
15 | # To check TNS Status: ./check_ora 1 <Oracle Sid or Hostname/IP address> | ||
16 | # To Check local database: ./check_ora 2 <ORACLE_SID> | ||
17 | # | ||
18 | # I have the script checking for the Oracle PMON process and | ||
19 | # the sgadefORACLE_SID.dbf file. | ||
20 | # | ||
21 | # | ||
22 | # If you have any problems check that you have the $ORACLE_HOME | ||
23 | # enviroment variable set, have $ORACLE_HOME/bin in your PATH, and | ||
24 | # dont forget about your tnsnames.ora file. when checking Local | ||
25 | # Database status your ORACLE_SID is case sensitive. | ||
26 | # | ||
27 | |||
28 | PROGNAME=`basename $0` | ||
29 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | ||
30 | REVISION=`echo '$Revision$' | sed -e 's/[^0-9.]//g'` | ||
31 | |||
32 | . $PROGPATH/utils.sh | ||
33 | |||
34 | |||
35 | print_usage() { | ||
36 | echo "Usage:" | ||
37 | echo " $PROGNAME --tns <Oracle Sid or Hostname/IP address>" | ||
38 | echo " $PROGNAME --db <ORACLE_SID>" | ||
39 | echo " $PROGNAME --help" | ||
40 | echo " $PROGNAME --version" | ||
41 | } | ||
42 | |||
43 | print_help() { | ||
44 | print_revision $PROGNAME $REVISION | ||
45 | echo "" | ||
46 | print_usage | ||
47 | echo "" | ||
48 | echo "Check remote or local TNS status and check local Database status" | ||
49 | echo "" | ||
50 | echo "--tns=SID/IP Address" | ||
51 | echo " Check remote TNS server" | ||
52 | echo "--db=SID" | ||
53 | echo " Check local database (search /bin/ps for PMON process and check" | ||
54 | echo " filesystem for sgadefORACLE_SID.dbf" | ||
55 | echo "--help" | ||
56 | echo " Print this help screen" | ||
57 | echo "--version" | ||
58 | echo " Print version and license information" | ||
59 | echo "" | ||
60 | echo "If the plugin doesn't work, check that the $ORACLE_HOME environment" | ||
61 | echo "variable is set, that $ORACLE_HOME/bin is in your PATH, and the" | ||
62 | echo "tnsnames.ora file is locatable and is properly configured." | ||
63 | echo "" | ||
64 | echo "When checking Local Database status your ORACLE_SID is case sensitive." | ||
65 | echo "" | ||
66 | support | ||
67 | } | ||
68 | |||
69 | case "$1" in | ||
70 | 1) | ||
71 | cmd='--tns' | ||
72 | ;; | ||
73 | 2) | ||
74 | cmd='--db' | ||
75 | ;; | ||
76 | *) | ||
77 | cmd="$1" | ||
78 | ;; | ||
79 | esac | ||
80 | |||
81 | case "$cmd" in | ||
82 | --tns) | ||
83 | export tnschk=` tnsping $2` | ||
84 | export tnschk2=` echo $tnschk | grep -c OK` | ||
85 | export tnschk3=` echo $tnschk | cut -d\( -f7 | sed y/\)/" "/` | ||
86 | if [ ${tnschk2} -eq 1 ] ; then | ||
87 | echo "OK - reply time ${tnschk3} from $2" | ||
88 | exit 0 | ||
89 | else | ||
90 | echo "No TNS Listener on $2" | ||
91 | exit $STATE_CRITICAL | ||
92 | fi | ||
93 | ;; | ||
94 | --db) | ||
95 | export pmonchk=`ps -ef | grep -v grep | grep ${2} | grep -c pmon` | ||
96 | if [ -e $ORACLE_HOME/dbs/sga*${2}* ] ; then | ||
97 | if [ ${pmonchk} -eq 1 ] ; then | ||
98 | export utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55` | ||
99 | echo "${2} OK - running since ${utime}" | ||
100 | exit $STATE_OK | ||
101 | fi | ||
102 | else | ||
103 | echo "${2} Database is DOWN" | ||
104 | exit $STATE_CRITICAL | ||
105 | fi | ||
106 | ;; | ||
107 | --help) | ||
108 | print_help | ||
109 | exit $STATE_OK | ||
110 | ;; | ||
111 | -h) | ||
112 | print_help | ||
113 | exit $STATE_OK | ||
114 | ;; | ||
115 | --version) | ||
116 | print_revision $PLUGIN $REVISION | ||
117 | exit $STATE_OK | ||
118 | ;; | ||
119 | -V) | ||
120 | print_revision $PLUGIN $REVISION | ||
121 | exit $STATE_OK | ||
122 | ;; | ||
123 | *) | ||
124 | print_usage | ||
125 | exit $STATE_UNKNOWN | ||
126 | esac | ||
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 | # | ||
21 | BEGIN { | ||
22 | if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { | ||
23 | $runtimedir = $1; | ||
24 | $PROGNAME = $2; | ||
25 | } | ||
26 | } | ||
27 | |||
28 | use strict; | ||
29 | use lib $main::runtimedir; | ||
30 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | ||
31 | use vars qw($PROGNAME); | ||
32 | my ($verbose,@proto,%prognum,$host,$response,$prognum,$port,$cmd); | ||
33 | my ($array_ref,$test,$element,@progkeys,$proto,$a,$b); | ||
34 | my ($opt_V,$opt_h,$opt_C,$opt_p,$opt_H); | ||
35 | $opt_V = $opt_h = $opt_C = $opt_p = $opt_H = ''; | ||
36 | |||
37 | sub print_help (); | ||
38 | sub print_usage (); | ||
39 | sub 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 | |||
51 | use Getopt::Long; | ||
52 | Getopt::Long::Configure('bundling'); | ||
53 | GetOptions | ||
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 | ||
61 | if ($opt_h) { print_help(); exit 0; } | ||
62 | |||
63 | # -V means display version number | ||
64 | if ($opt_V) { print_revision($PROGNAME,'$Revision$ '); exit 0; } | ||
65 | |||
66 | # -H means host name | ||
67 | $opt_H = shift unless ($opt_H); | ||
68 | unless ($opt_H) { print_usage(); exit -1; } | ||
69 | if($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 | |||
76 | while (<DATA>) { | ||
77 | ($a,$b) = split; | ||
78 | $prognum{$a} = $b; | ||
79 | } | ||
80 | close DATA; | ||
81 | |||
82 | # -C means command name or number | ||
83 | $opt_C = shift unless ($opt_C); | ||
84 | unless ($opt_C) { print_usage(); exit -1; } | ||
85 | @progkeys = keys %prognum; | ||
86 | if ($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 | ||
98 | if($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 |"; | ||
107 | print "$cmd\n" if ($verbose); | ||
108 | open CMD, $cmd; | ||
109 | |||
110 | while ( <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 | |||
119 | print "RPC CRITICAL: Program $opt_C not registered\n"; | ||
120 | exit 2; | ||
121 | |||
122 | |||
123 | |||
124 | sub 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 | |||
138 | sub 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 | |||
144 | sub 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__ | ||
157 | portmapper 100000 | ||
158 | portmap 100000 | ||
159 | sunrpc 100000 | ||
160 | rpcbind 100000 | ||
161 | rstatd 100001 | ||
162 | rstat 100001 | ||
163 | rup 100001 | ||
164 | perfmeter 100001 | ||
165 | rstat_svc 100001 | ||
166 | rusersd 100002 | ||
167 | rusers 100002 | ||
168 | nfs 100003 | ||
169 | nfsprog 100003 | ||
170 | ypserv 100004 | ||
171 | ypprog 100004 | ||
172 | mountd 100005 | ||
173 | mount 100005 | ||
174 | showmount 100005 | ||
175 | ypbind 100007 | ||
176 | walld 100008 | ||
177 | rwall 100008 | ||
178 | shutdown 100008 | ||
179 | yppasswdd 100009 | ||
180 | yppasswd 100009 | ||
181 | etherstatd 100010 | ||
182 | etherstat 100010 | ||
183 | rquotad 100011 | ||
184 | rquotaprog 100011 | ||
185 | quota 100011 | ||
186 | rquota 100011 | ||
187 | sprayd 100012 | ||
188 | spray 100012 | ||
189 | 3270_mapper 100013 | ||
190 | rje_mapper 100014 | ||
191 | selection_svc 100015 | ||
192 | selnsvc 100015 | ||
193 | database_svc 100016 | ||
194 | rexd 100017 | ||
195 | rex 100017 | ||
196 | alis 100018 | ||
197 | sched 100019 | ||
198 | llockmgr 100020 | ||
199 | nlockmgr 100021 | ||
200 | x25_inr 100022 | ||
201 | statmon 100023 | ||
202 | status 100024 | ||
203 | bootparam 100026 | ||
204 | ypupdated 100028 | ||
205 | ypupdate 100028 | ||
206 | keyserv 100029 | ||
207 | keyserver 100029 | ||
208 | sunlink_mapper 100033 | ||
209 | tfsd 100037 | ||
210 | nsed 100038 | ||
211 | nsemntd 100039 | ||
212 | showfhd 100043 | ||
213 | showfh 100043 | ||
214 | ioadmd 100055 | ||
215 | rpc.ioadmd 100055 | ||
216 | NETlicense 100062 | ||
217 | sunisamd 100065 | ||
218 | debug_svc 100066 | ||
219 | dbsrv 100066 | ||
220 | ypxfrd 100069 | ||
221 | rpc.ypxfrd 100069 | ||
222 | bugtraqd 100071 | ||
223 | kerbd 100078 | ||
224 | event 100101 | ||
225 | na.event 100101 | ||
226 | logger 100102 | ||
227 | na.logger 100102 | ||
228 | sync 100104 | ||
229 | na.sync 100104 | ||
230 | hostperf 100107 | ||
231 | na.hostperf 100107 | ||
232 | activity 100109 | ||
233 | na.activity 100109 | ||
234 | hostmem 100112 | ||
235 | na.hostmem 100112 | ||
236 | sample 100113 | ||
237 | na.sample 100113 | ||
238 | x25 100114 | ||
239 | na.x25 100114 | ||
240 | ping 100115 | ||
241 | na.ping 100115 | ||
242 | rpcnfs 100116 | ||
243 | na.rpcnfs 100116 | ||
244 | hostif 100117 | ||
245 | na.hostif 100117 | ||
246 | etherif 100118 | ||
247 | na.etherif 100118 | ||
248 | iproutes 100120 | ||
249 | na.iproutes 100120 | ||
250 | layers 100121 | ||
251 | na.layers 100121 | ||
252 | snmp 100122 | ||
253 | na.snmp 100122 | ||
254 | snmp-cmc 100122 | ||
255 | snmp-synoptics 100122 | ||
256 | snmp-unisys 100122 | ||
257 | snmp-utk 100122 | ||
258 | traffic 100123 | ||
259 | na.traffic 100123 | ||
260 | nfs_acl 100227 | ||
261 | sadmind 100232 | ||
262 | nisd 100300 | ||
263 | rpc.nisd 100300 | ||
264 | nispasswd 100303 | ||
265 | rpc.nispasswdd 100303 | ||
266 | ufsd 100233 | ||
267 | ufsd 100233 | ||
268 | pcnfsd 150001 | ||
269 | pcnfs 150001 | ||
270 | amd 300019 | ||
271 | amq 300019 | ||
272 | bwnfsd 545580417 | ||
273 | fypxfrd 600100069 | ||
274 | freebsd-ypxfrd 600100069 | ||
diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh new file mode 100755 index 00000000..011aa709 --- /dev/null +++ b/plugins-scripts/check_sensors.sh | |||
@@ -0,0 +1,65 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin | ||
4 | |||
5 | PROGNAME=`basename $0` | ||
6 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | ||
7 | REVISION=`echo '$Revision$' | sed -e 's/[^0-9.]//g'` | ||
8 | |||
9 | . $PROGPATH/utils.sh | ||
10 | |||
11 | |||
12 | print_usage() { | ||
13 | echo "Usage: $PROGNAME" | ||
14 | } | ||
15 | |||
16 | print_help() { | ||
17 | print_revision $PROGNAME $REVISION | ||
18 | echo "" | ||
19 | print_usage | ||
20 | echo "" | ||
21 | echo "This plugin checks hardware status using the lm_sensors package." | ||
22 | echo "" | ||
23 | support | ||
24 | exit 0 | ||
25 | } | ||
26 | |||
27 | case "$1" in | ||
28 | --help) | ||
29 | print_help | ||
30 | exit 0 | ||
31 | ;; | ||
32 | -h) | ||
33 | print_help | ||
34 | exit 0 | ||
35 | ;; | ||
36 | --version) | ||
37 | print_revision $PROGNAME $REVISION | ||
38 | exit 0 | ||
39 | ;; | ||
40 | -V) | ||
41 | print_revision $PROGNAME $REVISION | ||
42 | exit 0 | ||
43 | ;; | ||
44 | *) | ||
45 | sensordata=`sensors 2>&1` | ||
46 | status=$? | ||
47 | if test "$1" = "-v" -o "$1" = "--verbose"; then | ||
48 | echo ${sensordata} | ||
49 | fi | ||
50 | if test ${status} -eq 127; then | ||
51 | echo "SENSORS UNKNOWN - command not found (did you install lmsensors?)" | ||
52 | exit -1 | ||
53 | elif test ${status} -ne 0 ; then | ||
54 | echo "WARNING - sensors returned state $status" | ||
55 | exit 1 | ||
56 | fi | ||
57 | if echo ${sensordata} | egrep ALARM > /dev/null; then | ||
58 | echo SENSOR CRITICAL - Sensor alarm detected! | ||
59 | exit 2 | ||
60 | else | ||
61 | echo sensor ok | ||
62 | exit 0 | ||
63 | fi | ||
64 | ;; | ||
65 | esac | ||
diff --git a/plugins-scripts/check_wave.pl b/plugins-scripts/check_wave.pl new file mode 100755 index 00000000..c6e6c662 --- /dev/null +++ b/plugins-scripts/check_wave.pl | |||
@@ -0,0 +1,129 @@ | |||
1 | #! /usr/bin/perl -wT | ||
2 | # | ||
3 | # $Id$ | ||
4 | |||
5 | |||
6 | BEGIN { | ||
7 | if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { | ||
8 | $runtimedir = $1; | ||
9 | $PROGNAME = $2; | ||
10 | } | ||
11 | } | ||
12 | |||
13 | use strict; | ||
14 | use lib $main::runtimedir; | ||
15 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | ||
16 | use vars qw($PROGNAME); | ||
17 | use Getopt::Long; | ||
18 | use vars qw($opt_V $opt_h $verbose $opt_w $opt_c $opt_H); | ||
19 | my (@test, $low1, $med1, $high1, $snr, $low2, $med2, $high2); | ||
20 | my ($low, $med, $high, $lowavg, $medavg, $highavg, $tot, $ss); | ||
21 | |||
22 | sub print_help (); | ||
23 | sub print_usage (); | ||
24 | |||
25 | $ENV{'PATH'}=''; | ||
26 | $ENV{'BASH_ENV'}=''; | ||
27 | $ENV{'ENV'}=''; | ||
28 | |||
29 | Getopt::Long::Configure('bundling'); | ||
30 | GetOptions | ||
31 | ("V" => \$opt_V, "version" => \$opt_V, | ||
32 | "h" => \$opt_h, "help" => \$opt_h, | ||
33 | "v" => \$verbose, "verbose" => \$verbose, | ||
34 | "w=s" => \$opt_w, "warning=s" => \$opt_w, | ||
35 | "c=s" => \$opt_c, "critical=s" => \$opt_c, | ||
36 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); | ||
37 | |||
38 | if ($opt_V) { | ||
39 | print_revision($PROGNAME,'$Revision$'); #' | ||
40 | exit $ERRORS{'OK'}; | ||
41 | } | ||
42 | |||
43 | if ($opt_h) { | ||
44 | print_help(); | ||
45 | exit $ERRORS{'OK'}; | ||
46 | } | ||
47 | |||
48 | $opt_H = shift unless ($opt_H); | ||
49 | print_usage() unless ($opt_H); | ||
50 | my $host = $1 if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0]+(\.[a-zA-Z][-a-zA-Z0]+)*)$/); | ||
51 | print_usage() unless ($host); | ||
52 | |||
53 | ($opt_c) || ($opt_c = shift) || ($opt_c = 120); | ||
54 | my $critical = $1 if ($opt_c =~ /([0-9]+)/); | ||
55 | |||
56 | ($opt_w) || ($opt_w = shift) || ($opt_w = 60); | ||
57 | my $warning = $1 if ($opt_w =~ /([0-9]+)/); | ||
58 | |||
59 | $low1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`; | ||
60 | @test = split(/ /,$low1); | ||
61 | $low1 = $test[2]; | ||
62 | |||
63 | $med1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`; | ||
64 | @test = split(/ /,$med1); | ||
65 | $med1 = $test[2]; | ||
66 | |||
67 | $high1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`; | ||
68 | @test = split(/ /,$high1); | ||
69 | $high1 = $test[2]; | ||
70 | |||
71 | sleep(2); | ||
72 | |||
73 | $snr = `snmpget $host public .1.3.6.1.4.1.762.2.5.2.1.17.1`; | ||
74 | @test = split(/ /,$snr); | ||
75 | $snr = $test[2]; | ||
76 | $snr = int($snr*25); | ||
77 | |||
78 | $low2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`; | ||
79 | @test = split(/ /,$low2); | ||
80 | $low2 = $test[2]; | ||
81 | |||
82 | $med2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`; | ||
83 | @test = split(/ /,$med2); | ||
84 | $med2 = $test[2]; | ||
85 | |||
86 | $high2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`; | ||
87 | @test = split(/ /,$high2); | ||
88 | $high2 = $test[2]; | ||
89 | |||
90 | $low = $low2 - $low1; | ||
91 | $med = $med2 - $med1; | ||
92 | $high = $high2 - $high1; | ||
93 | |||
94 | $tot = $low + $med + $high; | ||
95 | |||
96 | if ($tot==0) { | ||
97 | $ss = 0; | ||
98 | } else { | ||
99 | $lowavg = $low / $tot; | ||
100 | $medavg = $med / $tot; | ||
101 | $highavg = $high / $tot; | ||
102 | $ss = ($medavg*50) + ($highavg*100); | ||
103 | } | ||
104 | |||
105 | printf("Signal Strength at: %3.0f%, SNR at $snr%",$ss); | ||
106 | |||
107 | if ($ss<$critical) { | ||
108 | exit(2); | ||
109 | } elsif ($ss<$warning) { | ||
110 | exit(1); | ||
111 | } else { | ||
112 | exit(0); | ||
113 | } | ||
114 | |||
115 | |||
116 | sub print_usage () { | ||
117 | print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>]\n"; | ||
118 | } | ||
119 | |||
120 | sub print_help () { | ||
121 | print_revision($PROGNAME,'$Revision$'); | ||
122 | print "Copyright (c) 2000 Jeffery Blank/Karl DeBisschop\n"; | ||
123 | print "\n"; | ||
124 | print_usage(); | ||
125 | print "\n"; | ||
126 | print "<warn> = Signal strength at which a warning message will be generated.\n"; | ||
127 | print "<crit> = Signal strength at which a critical message will be generated.\n\n"; | ||
128 | support(); | ||
129 | } | ||
diff --git a/plugins-scripts/subst.in b/plugins-scripts/subst.in new file mode 100644 index 00000000..cc0fd1b6 --- /dev/null +++ b/plugins-scripts/subst.in | |||
@@ -0,0 +1,56 @@ | |||
1 | #!/usr/bin/awk | ||
2 | |||
3 | function which(c,path) { | ||
4 | cmd = "test -x " c; | ||
5 | |||
6 | if (system(cmd)==0) { | ||
7 | return c; | ||
8 | } | ||
9 | |||
10 | sub(/\/.*\//,"",c); | ||
11 | for (dir in path) { | ||
12 | cmd = "test -x " path[dir] "/" c; | ||
13 | if (system(cmd)==0) { | ||
14 | return path[dir] "/" c; | ||
15 | } | ||
16 | } | ||
17 | |||
18 | |||
19 | return c; | ||
20 | } | ||
21 | |||
22 | BEGIN { | ||
23 | split(ENVIRON["PATH"] ":/sbin:/usr/sbin",path,/:/); | ||
24 | } | ||
25 | |||
26 | # scripting language (first line) | ||
27 | |||
28 | /^#! ?\/.*\/python/ {sub(/^#! ?\/.*\/python/,"#! @PYTHON@");} | ||
29 | /^#! ?\/.*\/perl/ {sub(/^#! ?\/.*\/perl/,"#! @PERL@");} | ||
30 | /^#! ?\/.*\/[a-z]{0,2}awk/ {sub(/^#! ?\/.*\/[a-z]{0,2}awk/,"#! @AWK@");} | ||
31 | /^#! ?\/.*\/sh/ {sub(/^#! ?\/.*\/sh/,"#! @SHELL@");} | ||
32 | |||
33 | # Trusted path mechanism (deprecated) | ||
34 | |||
35 | /^[ \t]*\$ENV[ \t]*\{[ \t'"]*PATH[ \t"']*\}[ \t]*=/ { | ||
36 | sub(/\=[ \t]*['"][^"']+["']/,"='@trusted_path@' # autoconf-derived"); | ||
37 | } | ||
38 | |||
39 | /^[\t ]*(export[\t ]*)?PATH[\t ]*=['"]+.+["']$/ { | ||
40 | sub(/\=.*$/,"='@trusted_path@' # autoconf-derived"); | ||
41 | } | ||
42 | |||
43 | # Specific programs | ||
44 | |||
45 | # | ||
46 | /^[^#]/ && /(\/.*)?\/(bin|sbin|lib|libexec)\// { | ||
47 | match($0,/(\/.*)?\/(bin|sbin|lib|libexec)\/[-_a-zA-Z0-9]+/); | ||
48 | start=RSTART+RLENGTH; | ||
49 | c=substr($0,RSTART,RLENGTH); | ||
50 | sub(c,which(c,path)); | ||
51 | } | ||
52 | |||
53 | { | ||
54 | print; | ||
55 | } | ||
56 | |||
diff --git a/plugins-scripts/t/check_rpc.t b/plugins-scripts/t/check_rpc.t new file mode 100644 index 00000000..afcb867c --- /dev/null +++ b/plugins-scripts/t/check_rpc.t | |||
@@ -0,0 +1,19 @@ | |||
1 | use strict; | ||
2 | use Test; | ||
3 | use vars qw($tests); | ||
4 | |||
5 | BEGIN {$tests = 2; plan tests => $tests} | ||
6 | |||
7 | my $null = ''; | ||
8 | my $cmd; | ||
9 | my $str; | ||
10 | my $t=0; | ||
11 | |||
12 | $cmd = "./check_rpc -V"; | ||
13 | $str = `$cmd`; | ||
14 | $t += ok $?>>8,0; | ||
15 | print "Test was: $cmd\n" if ($?); | ||
16 | $t += ok $str, '/^check_rpc/'; | ||
17 | |||
18 | exit(0) if defined($Test::Harness::VERSION); | ||
19 | exit($tests - $t); | ||
diff --git a/plugins-scripts/utils.pm.in b/plugins-scripts/utils.pm.in new file mode 100644 index 00000000..361bfe99 --- /dev/null +++ b/plugins-scripts/utils.pm.in | |||
@@ -0,0 +1,38 @@ | |||
1 | package utils; | ||
2 | |||
3 | require Exporter; | ||
4 | @ISA = qw(Exporter); | ||
5 | @EXPORT_OK = qw($TIMEOUT %ERRORS &print_revision &support &usage); | ||
6 | |||
7 | #use strict; | ||
8 | #use vars($TIMEOUT %ERRORS); | ||
9 | sub print_revision ($$); | ||
10 | sub usage; | ||
11 | sub support(); | ||
12 | |||
13 | $TIMEOUT = 15; | ||
14 | %ERRORS=('UNKNOWN'=>-1,'OK'=>0,'WARNING'=>1,'CRITICAL'=>2); | ||
15 | |||
16 | sub print_revision ($$) { | ||
17 | my $commandName = shift; | ||
18 | my $pluginRevision = shift; | ||
19 | $pluginRevision =~ s/^\$Revision: //; | ||
20 | $pluginRevision =~ s/ \$\s*$//; | ||
21 | print "$commandName (@PACKAGE@ @VERSION@) $pluginRevision\n"; | ||
22 | print "@WARRANTY@"; | ||
23 | } | ||
24 | |||
25 | sub support () { | ||
26 | my $support='@SUPPORT@'; | ||
27 | $support =~ s/@/\@/g; | ||
28 | $support =~ s/\\n/\n/g; | ||
29 | print $support; | ||
30 | } | ||
31 | |||
32 | sub usage { | ||
33 | my $format=shift; | ||
34 | printf($format,@_); | ||
35 | exit $ERRORS{'UNKNOWN'}; | ||
36 | } | ||
37 | |||
38 | 1; | ||
diff --git a/plugins-scripts/utils.sh.in b/plugins-scripts/utils.sh.in new file mode 100644 index 00000000..1e835e67 --- /dev/null +++ b/plugins-scripts/utils.sh.in | |||
@@ -0,0 +1,22 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | STATE_DEPENDENT=-2 | ||
4 | STATE_UNKNOWN=-1 | ||
5 | STATE_OK=0 | ||
6 | STATE_WARNING=1 | ||
7 | STATE_CRITICAL=2 | ||
8 | |||
9 | if test -x /usr/bin/printf; then | ||
10 | ECHO=/usr/bin/printf | ||
11 | else | ||
12 | ECHO=echo | ||
13 | fi | ||
14 | |||
15 | print_revision() { | ||
16 | echo "$1 (@PACKAGE@ @VERSION@) $2" | ||
17 | $ECHO "@WARRANTY@" | /bin/sed -e 's/\n/ /g' | ||
18 | } | ||
19 | |||
20 | support() { | ||
21 | $ECHO "@SUPPORT@" | /bin/sed -e 's/\n/ /g' | ||
22 | } \ No newline at end of file | ||