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;

}


In reply to Testing on node localhost.localdomain: failed with "Undefined" status, Invalid script return code: 9 by tan.darell

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.