Trying to apply the SAM Apache Template to a server running RHEL 7 and Apache 2.4. This worked perfectly while running Apache 2.2, but when I run this on 2.4, SAM displays an error: "Can't identify dynamic column definitions from script output."
Any idea what this means? I've already checked that port 22 is open, Perl is enabled and I can get to the /server-status page successfully. Has this been tested on 2.4 yet? I'll put the Perl code below ( I only made 1 change which was to adjust the port number....we have 3 instances of Apache on this server, but none of them seem to work with this Template - all 3 ports were successful while this was 2.2 though).
#!/usr/bin/perl
#
#
# Copyright ¿ 1999-2008 SolarWinds, Inc. All Rights Reserved.
#
#
use LWP::UserAgent;
if (@ARGV[0] =~ /\bhelp\b/)
{
print "ServerUptime.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:82/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 =~ /Uptime:\s(\d+)/ig){
$hour = sprintf("%d",$1 / 3600);
$min = sprintf("%d",($1-$hour*3600)/60);
$sec = sprintf("%d",($1-$hour*3600-$min*60));
$sut = "${hour}h ${min}m ${sec}s";
print "Message: Server Uptime at host \"$hostname\" $sut\n";
print "statistic: $1\n";
exit 0;
}
} else {
print "Message: unable access to $hostname\n";
print "Statistic: 0\n";
exit 1;
}