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
Command line: perl ${SCRIPT}
perl ${SCRIPT} - Testing on node localhost.localdomain: failed with 'undefined' status, script execution failed, input string was not in a correct format. - this is the error on this command line.
perl ${SCRIPT} localhost - Testing on node localhost.localdomain: failed with 'undefined' status, invalid script return code: 9 - this is the error when I add localhost on perl ${SCRIPT} command line.
sample script from APM template for Apache:
#!/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;
}