Check scripts in perl

"Stefan Sonnenberg-Carstens" <[email protected]>
Newsgroups gmane.network.netsaint.user
Message-ID <[email protected]>
Hi list,
we created several check scripts in perl, which do nothing more than print a status line, followed by a '\n' and exit with the appropriate exit code , e.g. exit(0) for example.
If the script has 3 lines it works, but if we include if's and while's and stuff, it doesn't.
We looked at the plugin developers guidlines and found nothing, we hadn't mentioned before.

The same Skript in Python works !!!

Here the example in Perl :

#!/usr/bin/perl

if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
#       $runtimedir = $1;
        $PROGNAME = $2;
}

use Getopt::Long;
use utils qw(%ERRORS &print_revision &support &usage);

sub print_version ();
sub print_help ();

delete @ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};


Getopt::Long::Configure('bundling', 'no_ignore_case');
GetOptions
    ("V|version"    => \&version,
     "h|help"       => \&help );

if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
        #$runtimedir = $1;
        $PROGNAME = $2;
}



        $threshhold = 25;
        open(FILE,"/usr/bin/snmpget 192.168.8.115 public .enterprises.2012.1.1.1.4.2.0 |");
        $a = <FILE>;
        close(FILE);
        @temp_raw = split("=",$a);
        chomp $temp_raw[1];

        $celsius = ($temp_raw[1]-32)*0.555;

        if($celsius > $threshhold) {
                print stdout "SERVER ROOM TO HOT : $celsius degrees\r\n";
                $temperr=-1;
        } else {
                print stdout "Temp ok : $celsius degrees\r\n";
                $temperr=0;
        }

exit $ERRORS{'CRITICAL'} if ($temperr < 0);
exit $ERRORS{'OK'};

sub version () {
        print_revision($PROGNAME,'$Revision: 1.0.0.0 $ ');
        exit $ERRORS{'OK'};
}

sub help () {
        print "check_temperature";
        exit $ERRORS{'OK'};
}

And here the (almost) same thing in Python :

#!/usr/bin/python
import commands
import sys
import string

temp = commands.getoutput("/usr/bin/snmpget 192.168.8.115 public .enterprises.2012.1.1.1.4.2.0");
val = string.split(temp,"=")
celsius = (string.atof(val[1][1:])-32.0)*0.555
if celsius < 25:
        print "Temperatur : " , celsius , "Grad Celsius"
        sys.exit(0)
else:
        print "Temperatur : " , celsius , "Grad Celsius"
        sys.exit(1)


By the way : we have a CCS10 (Schroff monitoring device).
NetSaint runs on SuSE 8.0 with the pre-compiled rpm's and perl 5.6.1.


Any Ideas ?


Thx in advance !
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.