Code

Added -A/--dig-arguments to check_dig (#1889453/#1874041)
[nagiosplug.git] / plugins-scripts / check_rpc.pl
index 623d6ab22945dc0234d74df167d047660ed21d55..20c204dee7de93960a72d083bf7bdec6bc429e6f 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/local/bin/perl -w
+#!/usr/local/bin/perl -w
 #
 # check_rpc plugin for nagios
 #
@@ -29,8 +29,8 @@ my ($verbose,@proto,%prognum,$host,$response,$prognum,$port,$cmd,$progver,$state
 my ($array_ref,$test,$element,@progkeys,$proto,$a,$b);
 my ($opt_V,$opt_h,$opt_C,$opt_p,$opt_H,$opt_c,$opt_u,$opt_t);
 my ($line, @progvers, $response2,$response3);
-$opt_V = $opt_h = $opt_C = $opt_p = $opt_H = $opt_c = $opt_u = $opt_t ='';
-$state = 'OK';
+$opt_V = $opt_h = $opt_C = $opt_p = $opt_H =  $opt_u = $opt_t ='';
+$state = 'UNKNOWN';
 $progver = $response=$response2= $response3 ='';
 
 $PROGNAME = "check_rpc";
@@ -41,6 +41,7 @@ sub in ($$);
 $ENV{'BASH_ENV'}=''; 
 $ENV{'ENV'}='';
 $ENV{'PATH'}='';
+$ENV{'LC_ALL'}='C';
 
 #Initialise protocol for each progname number
 # 'u' for UDP, 't' for TCP 
@@ -51,16 +52,16 @@ $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,
-          "c=s" => \$opt_c, "progver=s"  => \$opt_c,
-          "v+"   => \$verbose, "verbose+"  => \$verbose,
-          "u"   => \$opt_u,  "udp"       => \$opt_u,
-          "t"   => \$opt_t,  "tcp"       => \$opt_t
-          );
+       "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,
+       "c=s" => \$opt_c,   "progver=s"  => \$opt_c,
+       "v+"  => \$verbose, "verbose+"   => \$verbose,
+       "u"   => \$opt_u,   "udp"        => \$opt_u,
+       "t"   => \$opt_t,   "tcp"        => \$opt_t
+);
 
 # -h means display verbose help screen
 if ($opt_h) { print_help(); exit $ERRORS{'OK'}; }
@@ -68,7 +69,7 @@ if ($opt_h) { print_help(); exit $ERRORS{'OK'}; }
 # -V means display version number
 if ($opt_V) { 
        print_revision($PROGNAME,'$Revision$ '); 
-       exit $ERRORS{'Ok'}; 
+       exit $ERRORS{'OK'}; 
 }
 
 # Hash containing all RPC program names and numbers
@@ -313,7 +314,7 @@ sub get_rpcinfo {
        
        if ( $line =~ /program $prognum version ([0-9]*) ready and waiting/ ) {
                        $response .= " version $1";
-                       $state = 'OK' unless $state ne 'OK';
+                       $state = 'OK' unless $state ne 'UNKNOWN';
                        print "1:$response \n" if $verbose;
        }