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