Code

tools/distclean: use git-clean when possible
[nagiosplug.git] / plugins-scripts / check_rpc.pl
index b9ca2799a8619e7d57e13b5eb8899d20d7a08d3d..d2701e95075db6c2af19f676614b34b1148a10b5 100755 (executable)
 #
 # initial version: 3 May 2000 by Truongchinh Nguyen and Karl DeBisschop
 # Modified May 2002 Subhendu Ghosh - support for ePN and patches
-# current status: $Revision$
 #
 # Copyright Notice: GPL
-# $Id$
 #
 
 use strict;
@@ -38,12 +36,13 @@ sub print_help ();
 sub print_usage ();
 sub in ($$);
 
-$ENV{'BASH_ENV'}=''; 
+$ENV{'BASH_ENV'}='';
 $ENV{'ENV'}='';
 $ENV{'PATH'}='';
+$ENV{'LC_ALL'}='C';
 
 #Initialise protocol for each progname number
-# 'u' for UDP, 't' for TCP 
+# 'u' for UDP, 't' for TCP
 $proto[10003]='u';
 $proto[10004]='u';
 $proto[10007]='u';
@@ -51,24 +50,24 @@ $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'}; }
 
 # -V means display version number
-if ($opt_V) { 
-       print_revision($PROGNAME,'$Revision$ '); 
-       exit $ERRORS{'OK'}; 
+if ($opt_V) {
+       print_revision($PROGNAME,'@NP_VERSION@');
+       exit $ERRORS{'OK'};
 }
 
 # Hash containing all RPC program names and numbers
@@ -274,7 +273,7 @@ if (defined $opt_c ) {
                }else{
                        print "Version $vers is not an integer\n" if $verbose;
                }
-       
+
        }
 }else{
        get_rpcinfo();
@@ -310,10 +309,10 @@ sub get_rpcinfo {
        while ( $line = <CMD> ) {
                printf "$line " if $verbose;
                chomp $line;
-       
+
        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;
        }
 
@@ -335,7 +334,7 @@ sub get_rpcinfo {
 
 
 sub print_help() {
-       print_revision($PROGNAME,'$Revision$ ');
+       print_revision($PROGNAME,'@NP_VERSION@');
        print "Copyright (c) 2002 Karl DeBisschop/Truongchinh Nguyen/Subhendu Ghosh\n";
        print "\n";
        print "Check if a rpc service is registered and running using\n";