Shivaramakrishnan has asked for the wisdom of the Perl Monks concerning the following question:
Hello, I am fairly new to perl programming.I am using a perl script to monitor apache web server.
I wanted to use the same script for monitoring http/https sites.Currently the script works great for any http site. I am not able to get it working for https sites.Below my code and apache2 settings on my remote server.
#!/usr/bin/perl use LWP::Simple; use strict; my($url)="http://10.28.128.138/server-status?auto"; my($server_status)=get($url); my($total_accesses,$total_kbytes,$cpuload,$uptime, $reqpersec,$bytespe +rsec,$bytesperreq,$busyworkers, $idleworkers,$totalworkers); if (! $server_status) { print "Can't access $url\nCheck apache configuration\n\n"; exit(1); } # $total_accesses = $1 if ($server_status =~ /Total\ Accesses:\ ([\d|\.] ++)/ig)||0; $total_kbytes = $1 if ($server_status =~ /Total\ kBytes:\ ([\d|\.]+)/g +i); $cpuload = $1 if ($server_status =~ /CPULoad:\ ([\d|\.]+)/gi); $uptime = $1 if ($server_status =~ /Uptime:\ ([\d|\.]+)/gi); $reqpersec = $1 if ($server_status =~ /ReqPerSec:\ ([\d|\.]+)/gi); $bytespersec = $1 if ($server_status =~ /BytesPerSec:\ ([\d|\.]+)/gi); $bytesperreq = $1 if ($server_status =~ /BytesPerReq:\ ([\d|\.]+)/gi); $busyworkers = $1 if ($server_status =~ /BusyWorkers:\ ([\d|\.]+)/gi); $idleworkers = $1 if ($server_status =~ /IdleWorkers:\ ([\d|\.]+)/gi); $totalworkers = $busyworkers + $idleworkers; # #printf "TotalAccess %i:Total_kbytes %i:CPU-Load %.2f:reqpersec %.2f:b +ytespersec %.2f:bytesperreq %.2f:busyworkers %i:idleworkers %i:totalw +orkers %i\n",$total_accesses,$total_kbytes,$cpuload,$reqpersec,$bytes +persec,$bytesperreq,$busyworkers,$idleworkers,$totalworkers; print "busyworkers:$busyworkers bytesperreq:$bytesperreq bytespersec:$ +bytespersec CPULoad:$cpuload idleworkers:$idleworkers reqpersec:$reqp +ersec TotalAccess:$total_accesses totalworkers:$totalworkers Total_kb +ytes:$total_kbytes \n"; exit(0);
ExtendedStatus On <Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from 10.28.128.180 </Location>
Output
busyworkers:1 bytesperreq:1202.99 bytespersec:4.01738 CPULoad:5.52999 idleworkers:49 reqpersec:.0033395 TotalAccess:1087 totalworkers:50 Total_kbytes:1277
But when I change the url
my($url)="https://10.28.128.138/server-status?auto";
root@cacti-host:/var/www/cacti/scripts# ./check_apache.pl
Can't access https://10.28.128.138/server-status?auto
Check apache configuration
I wanted to know what needs to be changed in my script/apache2 settings to get it working for any https sites.Can anyone please help !!!I am trying to get it working from past two days with no luck still.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Apache statistics with perl
by Corion (Patriarch) on Apr 08, 2013 at 14:32 UTC | |
|
Re: Apache statistics with perl
by aitap (Curate) on Apr 08, 2013 at 16:07 UTC | |
|
Re: Apache statistics with perl
by hbm (Hermit) on Apr 08, 2013 at 15:03 UTC |