From becc0f34e60500798bd15bf5af6e4b8c52707d0a Mon Sep 17 00:00:00 2001 From: Subhendu Ghosh Date: Thu, 2 May 2002 16:43:29 +0000 Subject: fix for embedded perl git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@21 f882894a-f735-0410-b71e-b25c423dba1c diff --git a/plugins-scripts/check_breeze.pl b/plugins-scripts/check_breeze.pl index 79e36be..bd73f42 100755 --- a/plugins-scripts/check_breeze.pl +++ b/plugins-scripts/check_breeze.pl @@ -1,16 +1,11 @@ #! /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 FindBin; +use lib "$FindBin::Bin" ; use utils qw(%ERRORS &print_revision &support &usage); sub print_help (); @@ -26,7 +21,8 @@ GetOptions "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); + "H=s" => \$opt_H, "hostname=s" => \$opt_H, + "C=s" => \$opt_C, "community=s" => \$opt_C); if ($opt_V) { print_revision($PROGNAME,'$Revision$'); @@ -35,20 +31,22 @@ if ($opt_V) { if ($opt_h) {print_help(); exit $ERRORS{'OK'};} -($opt_H) || ($opt_H = shift) || usage("Host name/address not specified\n"); +($opt_H) || 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"); +($opt_w) || 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"); +($opt_c) || 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"); +($opt_C) || ($opt_C = "public") ; + my $sig=0; -$sig = `/usr/bin/snmpget $host public .1.3.6.1.4.1.710.3.2.3.1.3.0`; +$sig = `/usr/bin/snmpget $host $opt_C .1.3.6.1.4.1.710.3.2.3.1.3.0`; my @test=split(/ /,$sig); $sig=$test[2]; $sig=int($sig); @@ -62,7 +60,7 @@ exit $ERRORS{'OK'}; sub print_usage () { - print "Usage: $PROGNAME -H -w -c \n"; + print "Usage: $PROGNAME -H [-C community] -w -c \n"; } sub print_help () { @@ -76,6 +74,8 @@ This plugin reports the signal strength of a Breezecom wireless equipment print " -H, --hostname=HOST Name or IP address of host to check +-C, --community=community + SNMPv1 community (default public) -w, --warning=INTEGER Percentage strength below which a WARNING status will result -c, --critical=INTEGER diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl index d1b0b3d..9a66ed5 100755 --- a/plugins-scripts/check_disk_smb.pl +++ b/plugins-scripts/check_disk_smb.pl @@ -14,13 +14,10 @@ # 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; - } -} +# 2-May-2002 - SGhosh fix for embedded perl +# +# $Id$ +# require 5.004; use POSIX; @@ -28,7 +25,8 @@ 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 FindBin; +use lib "$FindBin::Bin"; use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); sub print_help (); diff --git a/plugins-scripts/check_flexlm.pl b/plugins-scripts/check_flexlm.pl index 1d26b7c..595a0b3 100755 --- a/plugins-scripts/check_flexlm.pl +++ b/plugins-scripts/check_flexlm.pl @@ -26,19 +26,15 @@ # initial version: 9-10-99 Ernst-Dieter Martin edmt@infineon.com # # License: GPL +# $Id$ # -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 FindBin ; +use lib "$FindBin::Bin"; use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); sub print_help (); diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl index e4c4bd0..098a8e7 100755 --- a/plugins-scripts/check_ircd.pl +++ b/plugins-scripts/check_ircd.pl @@ -38,15 +38,8 @@ # with perl -wT and 'use strict' # # test using check_ircd.pl (irc-2.mit.edu|irc.erols.com|irc.core.com) +# 2002/05/02 SG Fixed for Embedded Perl # -# ------------------------------------------------------------------[ Begin ]-- - -BEGIN { - if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { - $runtimedir = $1; - $PROGNAME = $2; - } -} # ----------------------------------------------------------------[ Require ]-- @@ -59,7 +52,8 @@ 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 FindBin; +use lib "$FindBin::Bin"; use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); # ----------------------------------------------------[ Function Prototypes ]-- diff --git a/plugins-scripts/check_netdns.pl b/plugins-scripts/check_netdns.pl index 4bf7bd7..65ad7be 100755 --- a/plugins-scripts/check_netdns.pl +++ b/plugins-scripts/check_netdns.pl @@ -6,8 +6,11 @@ # Copyright 2000, virCIO, LLP # # $Log$ -# Revision 1.1 2002/02/28 06:43:00 egalstad -# Initial revision +# Revision 1.2 2002/05/02 16:43:29 sghosh +# fix for embedded perl +# +# Revision 1.1.1.1 2002/02/28 06:43:00 egalstad +# Initial import of existing plugin code # # Revision 1.1 2000/08/03 20:41:12 karldebisschop # rename to avoid conflict when installing @@ -18,11 +21,15 @@ # 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; +use Findbin; +use lib "$FindBin::Bin"; +use utils ; - Getopt::Long::Configure(`bundling`); +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, diff --git a/plugins-scripts/check_ntp.pl b/plugins-scripts/check_ntp.pl index f3f6f78..918ad50 100755 --- a/plugins-scripts/check_ntp.pl +++ b/plugins-scripts/check_ntp.pl @@ -7,6 +7,8 @@ # be installed on the system, however since it's part of the ntp suite, you # should already have it installed. # +# $Id$ +# # Nothing clever done in this program - its a very simple bare basics hack to # get the job done. # @@ -45,19 +47,17 @@ # source. This happens while starting up and if contact # with master has been lost. # -BEGIN { - if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { - $runtimedir = $1; - $PROGNAME = $2; - } -} +# Modifed to run under Embedded Perl - patch from Douglas Warner +# + 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 FindBin; +use lib "$FindBin::Bin"; use utils qw($TIMEOUT %ERRORS &print_revision &support); sub print_help (); diff --git a/plugins-scripts/check_rpc.pl b/plugins-scripts/check_rpc.pl index 51901ac..2e25f41 100755 --- a/plugins-scripts/check_rpc.pl +++ b/plugins-scripts/check_rpc.pl @@ -18,15 +18,11 @@ # # Copyright Notice: GPL # -BEGIN { - if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { - $runtimedir = $1; - $PROGNAME = $2; - } -} + use strict; -use lib $main::runtimedir; +use FindBin; +use lib "$FindBin::Bin"; use utils qw($TIMEOUT %ERRORS &print_revision &support); use vars qw($PROGNAME); my ($verbose,@proto,%prognum,$host,$response,$prognum,$port,$cmd); diff --git a/plugins-scripts/check_wave.pl b/plugins-scripts/check_wave.pl index c6e6c66..6d58e4f 100755 --- a/plugins-scripts/check_wave.pl +++ b/plugins-scripts/check_wave.pl @@ -3,15 +3,9 @@ # $Id$ -BEGIN { - if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { - $runtimedir = $1; - $PROGNAME = $2; - } -} - use strict; -use lib $main::runtimedir; +use FindBin; +use lib "$Findbin::Bin"; use utils qw($TIMEOUT %ERRORS &print_revision &support); use vars qw($PROGNAME); use Getopt::Long; -- cgit v0.10-9-g596f