tan.darell has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Can anyone help me? My problem is this, I have here a Network Monitoring tool (SolarWinds APM) that should monitor the Apache (httpd) 2.0 on CentOS 4.3, at first, It doesn't run, but when I add "localhost" on command line "perl ${SCRIPT}" it becomes "perl ${SCRIPT} localhost", it works on our linux box, when I tried to configure it on other linux box, "Testing on node localhost.localdomain: failed with 'undefined' status, invalid script return code: 9" was the error, when I remove the localhost that I add on the command line, the error is "Testing on node localhost.localdomain: failed with 'undefined' status, Script execution failed, input string was not in a correct format".

OS: CentOS 4.3

Apache version: 2.0

Monitoring tool: SolarWinds APM 4.0.1

Here's the sample script:

command line: perl ${SCRIPT}

Script:

#!/usr/bin/perl

#

#

# Copyright ?? 1999-2008 SolarWinds, Inc. All Rights Reserved.

#

#

use LWP::UserAgent;

if (@ARGV[0] =~ /\bhelp\b/)

{

print "ServerKBytesPerRequest.pl StatusURL\n";

print "StatusURL - url to apache server status (ex. www.mysite.com/server-status ) \n";

exit 1;

}

# Get hostname and trim newline

$localhost = `hostname`;

$localhost =~ s/\s*$//g;

$hostname = shift || "localhost"; # $localhost

$url = "$hostname/server-status?auto&match=www&errors=0";

# Create a user agent object

$ua = new LWP::UserAgent;

$ua->agent("AgentName/0.1 " . $ua->agent);

# Create a request

my $req = new HTTP::Request GET => "http://$url";

#print "http://$url\n";

$req->content_type("application/x-www-form-urlencoded");

$req->content("match=www&errors=0");

# Pass request to the user agent and get a response back

my $res = $ua->request($req);

my $val ="";

# Check the outcome of the response

if ($res->is_success) {

#print $res->content;

$content = $res->content;

while ( $content =~ /BytesPerReq:\s(\d*)/g ){

$val = sprintf("%.2f",$1 / 1024);

print "Message: Traffic at host \"$hostname\": $val\n";

print "Statistic: $val\n";

exit 0;

}

} else {

print "Message: unable access to $hostname\n";

print "Statistic: 0\n";

exit 1;

}

  • Comment on Testing on node localhost.localdomain: failed with "Undefined" status, Invalid script return code: 9

Replies are listed 'Best First'.
Re: Testing on node localhost.localdomain: failed with "Undefined" status, Invalid script return code: 9
by Mr. Muskrat (Canon) on May 09, 2011 at 19:39 UTC
Re: Testing on node localhost.localdomain: failed with "Undefined" status, Invalid script return code: 9
by Anonymous Monk on May 07, 2011 at 02:51 UTC
    How is the code you posted related to the error message you posted?
      Hi, The code I posted was the original template of the said monitoring tool, its just when I tested that on my linux box, it works, but when I use that on other linux box with the same version, it generates error message.

        So I would start investigating the differences between the two machines.

        You don't show us any code that produces the error message. If you assume that there is an error in your script, you will tell us what error message your script produces, and also what the script is supposed to do. If you assume that there is an error in your monitoring tool, you will need to show us that code instead of the other code.