ApacheStats 0.6 (PHP Script Server Version)

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

User avatar
mahuani
Cacti User
Posts: 72
Joined: Tue Nov 01, 2005 2:10 pm
Location: Lafayette, LA
Contact:

Post by mahuani »

This is probably a given, but did you try to rebuild your poller cache?
cray74
Posts: 4
Joined: Fri Dec 01, 2006 4:46 am

Post by cray74 »

yes, just did it again (via the interface) - no dice :-(.
mvam
Cacti User
Posts: 87
Joined: Wed Jun 01, 2005 2:00 pm
Location: Seattle

Post by mvam »

this is what i get

Fatal error: Call to undefined function curl_init() in /scripts/ss_apache_stats.php on line 52
knobdy
Cacti User
Posts: 495
Joined: Wed Sep 28, 2005 1:39 pm

Post by knobdy »

If I run the command from the command line:

Code: Select all

php5 /usr/share/cacti/scripts/ss_apache_stats.php localhost
I get nothing - just returns to the command prompt. If I go to the script server:

Code: Select all

02n:/etc/apache2 # php5 /usr/share/cacti/script_server.php
PHP Script Server has Started - Parent is cmd
/usr/share/cacti/scripts/ss_apache_stats.php ss_apache_stats localhost
02n:/etc/apache2 #
Same thing.

If I just go to the site http://localhost/server-status I do get a response, as does http://localhost/server-status?auto...

Any thoughts?

:UPDATE:
Here's the results of a polling with debug on - not much to go on (can someone who has this working show their logs?):

Code: Select all

12/12/2006 01:10:02 PM - PHPSVR: Poller[0] DEBUG: INC: '/usr/share/cacti/scripts/ss_apache_stats.php' FUNC: 'ss_apache_stats' PARMS: '127.0.0.1'
12/12/2006 01:10:02 PM - CMDPHP: Poller[0] Host[1] DS[5684] SERVER: /usr/share/cacti/scripts/ss_apache_stats.php ss_apache_stats 127.0.0.1, output: U
12/12/2006 01:10:02 PM - CMDPHP: Poller[0] Host[1] DS[5685] SERVER: /usr/share/cacti/scripts/ss_apache_stats.php ss_apache_stats 127.0.0.1, output: U
12/12/2006 01:10:02 PM - CMDPHP: Poller[0] Host[1] DS[5686] SERVER: /usr/share/cacti/scripts/ss_apache_stats.php ss_apache_stats 127.0.0.1, output: U
12/12/2006 01:10:02 PM - CMDPHP: Poller[0] Host[1] DS[5687] SERVER: /usr/share/cacti/scripts/ss_apache_stats.php ss_apache_stats 127.0.0.1, output: U
12/12/2006 01:10:02 PM - CMDPHP: Poller[0] Host[1] DS[5688] SERVER: /usr/share/cacti/scripts/ss_apache_stats.php ss_apache_stats 127.0.0.1, output: U
12/12/2006 01:10:02 PM - CMDPHP: Poller[0] Host[1] DS[5689] SERVER: /usr/share/cacti/scripts/ss_apache_stats.php ss_apache_stats 127.0.0.1, output: U
12/12/2006 01:10:02 PM - CMDPHP: Poller[0] Host[1] DS[5690] SERVER: /usr/share/cacti/scripts/ss_apache_stats.php ss_apache_stats 127.0.0.1, output: U
12/12/2006 01:10:27 PM - POLLER: Poller[0] CACTI2RRD: /usr/bin/rrdtool update /usr/share/cacti/rra/localhost_apache_idle_workers_5684.rrd --template  1165950602:U
12/12/2006 01:10:27 PM - POLLER: Poller[0] CACTI2RRD: /usr/bin/rrdtool update /usr/share/cacti/rra/localhost_apache_idle_workers_5685.rrd --template  1165950602:U
12/12/2006 01:10:27 PM - POLLER: Poller[0] CACTI2RRD: /usr/bin/rrdtool update /usr/share/cacti/rra/localhost_apache_idle_workers_5686.rrd --template  1165950602:U
12/12/2006 01:10:27 PM - POLLER: Poller[0] CACTI2RRD: /usr/bin/rrdtool update /usr/share/cacti/rra/localhost_apache_idle_workers_5687.rrd --template  1165950602:U
12/12/2006 01:10:27 PM - POLLER: Poller[0] CACTI2RRD: /usr/bin/rrdtool update /usr/share/cacti/rra/localhost_apache_idle_workers_5688.rrd --template  1165950602:U
12/12/2006 01:10:27 PM - POLLER: Poller[0] CACTI2RRD: /usr/bin/rrdtool update /usr/share/cacti/rra/localhost_apache_idle_workers_5689.rrd --template  1165950602:U
12/12/2006 01:10:27 PM - POLLER: Poller[0] CACTI2RRD: /usr/bin/rrdtool update /usr/share/cacti/rra/localhost_apache_idle_workers_5690.rrd --template  1165950602:U
miclaro
Posts: 2
Joined: Tue Dec 12, 2006 4:24 pm

improvements

Post by miclaro »

Hi, I just looked at this script and found it great. I'm new to cacti and it was a little dificult to install, but its all ok.

I'm an experienced php programmer so I improved the code a bit, so it's not php5 dependent.

any comments are wellcomed.
Attachments
ss_apache_stats.zip
imrpoved php script
(1.32 KiB) Downloaded 889 times
knobdy
Cacti User
Posts: 495
Joined: Wed Sep 28, 2005 1:39 pm

Post by knobdy »

Might be too early but it looks as though your update has fixed my issue - its returning something anyway...to be continued...and THANKS!

:UPDATE:

It does work now, but I have an issue. It seems the numbers being reported are a bit high - but maybe I'm not reading it correctly? For one, this is our Cacti server that its monitoring and there are, at most, 5-10 people that look at it and only myself at this time, yet it shows 300 "m" hits/sec. The CPU load I don't understand either...
Attachments
apache_stats1.JPG
apache_stats1.JPG (92.68 KiB) Viewed 14123 times
mlanghorst
Posts: 8
Joined: Fri Dec 08, 2006 7:17 pm

Post by mlanghorst »

The "m" means micro I beleive. So it's showing less than 1, one of the semi-issues with auto-scaling, can be confusing to people when the data is so small.
mlanghorst
Posts: 8
Joined: Fri Dec 08, 2006 7:17 pm

Post by mlanghorst »

I've switched to the php posted by miclaro as I'm still on php4 and I was getting the same curl_init issues. The script seems to be reporting back properly, the server I'm testing it on has almost no traffic right now. But I'm still seeing NAN's in the rrdtool graphs.

The output of the php looks ok to me:

12/12/2006 05:25:52 PM - POLLER: Poller[0] Parsed MULTI output field 'apache_total_kbytes:13' [map apache_total_kbytes->apache_total_kbytes]
12/12/2006 05:25:52 PM - POLLER: Poller[0] Parsed MULTI output field 'apache_busy_workers:1' [map apache_busy_workers->apache_busy_workers]
12/12/2006 05:25:52 PM - POLLER: Poller[0] Parsed MULTI output field 'apache_idle_workers:7' [map apache_idle_workers->apache_idle_workers]
12/12/2006 05:25:52 PM - POLLER: Poller[0] Parsed MULTI output field 'thread_W:256' [map thread_W->thread_W]
12/12/2006 05:25:52 PM - POLLER: Poller[0] Parsed MULTI output field 'threadS:0' [map threadS->threadS]
12/12/2006 05:25:52 PM - POLLER: Poller[0] Parsed MULTI output field 'threadR:0' [map threadR->threadR]
12/12/2006 05:25:52 PM - POLLER: Poller[0] Parsed MULTI output field 'threadW:0' [map threadW->threadW]
12/12/2006 05:25:52 PM - POLLER: Poller[0] Parsed MULTI output field 'threadK:0' [map threadK->threadK]
12/12/2006 05:25:52 PM - POLLER: Poller[0] Parsed MULTI output field 'threadD:0' [map threadD->threadD]
12/12/2006 05:25:52 PM - POLLER: Poller[0] Parsed MULTI output field 'threadC:0' [map threadC->threadC]
12/12/2006 05:25:52 PM - POLLER: Poller[0] Parsed MULTI output field 'threadL:0' [map threadL->threadL]
12/12/2006 05:25:52 PM - POLLER: Poller[0] Parsed MULTI output field 'threadG:0' [map threadG->threadG]
12/12/2006 05:25:52 PM - POLLER: Poller[0] Parsed MULTI output field 'threadI:0' [map threadI->threadI]
12/12/2006 05:25:52 PM - POLLER: Poller[0] Parsed MULTI output field 'thread_O:0' [map thread_O->thread_O]
12/12/2006 05:25:52 PM - POLLER: Poller[0] CACTI2RRD: /usr/local/bin/rrdtool update /app/web/htdocs/cacti-0.8.6i/rra/pss_web_server_apache_idle_workers_2057.rrd --template apache_total_hits:apache_total_kbytes:apache_busy_workers:apache_idle_workers:thread_W:threadS:threadR:threadW:threadK:threadD:threadC:threadL:threadG:threadI:thread_O 1165973145:28:11:1:7:256:0:0:0:0:0:0:0:0:0:0

But running rrdtool info against one of the rrd files, there's definitely something wrong:

Attached rrdtool info as file due to size of output.
Attachments
rrdinfo.txt
output from "rrdtool info" on rrd file used for failing graph.
(24.28 KiB) Downloaded 491 times
mlanghorst
Posts: 8
Joined: Fri Dec 08, 2006 7:17 pm

Post by mlanghorst »

Running this on FC6 seems to get nothing back:

[root@fedora Desktop]# php ss_apache_stats.php fedora
thread_W:0 threadS:0 threadR:0 threadW:0 threadK:0 threadD:0 threadC:0 threadL:0 threadG:0 threadI:0 thread_O:0

The output from server-status?auto seems fine:

Total Accesses: 5098
Total kBytes: 17808
CPULoad: 73.4284
Uptime: 978
ReqPerSec: 5.21268
BytesPerSec: 18645.6
BytesPerReq: 3576.97
BusyWorkers: 1
IdleWorkers: 16
Scoreboard: __W______________........

(truncated the ......'s) Though the cpuload seems to take a LONG time to come back down after high load.
miclaro
Posts: 2
Joined: Tue Dec 12, 2006 4:24 pm

Re: improvements

Post by miclaro »

miclaro wrote:Hi, I just looked at this script and found it great. I'm new to cacti and it was a little dificult to install, but its all ok.

I'm an experienced php programmer so I improved the code a bit, so it's not php5 dependent.

any comments are wellcomed.

fixed a bug in line 86, sorry for the typo.
Attachments
ss_apache_stats.zip
(1.32 KiB) Downloaded 1074 times
ljube
Posts: 1
Joined: Wed Dec 13, 2006 9:26 am

Post by ljube »

Very nice peace of software, I had some problems installing it, so I want to post how I got it working for me.
- Frst the XML didn't upload at all and I changed the max_execution_time to 180 and it uploaded without problem
- After that, I tried with cmd.php and cactid, but I was getting no graphs
- I turned on debug and saw that the connection to the script server is broken.
- I tried php ss_apache_stats.php <my_webserver_hostname> and I got error that curl_init function could not load
- I recompiled php with curl support and now everything is working fine
mvam
Cacti User
Posts: 87
Joined: Wed Jun 01, 2005 2:00 pm
Location: Seattle

Post by mvam »

finally got curl support installed. wow what a mess, thanks Debian. after forced upgrade to apache 2.2 this script is working. slow.. but working.
jobu
Posts: 12
Joined: Mon Nov 13, 2006 5:32 pm

Post by jobu »

When I run the script from CLI and thru script_server.php manually I get values, but I am still getting NaN on the graphs. My graph temple is below and looks correct. Any ideas?

/usr/local/rrdtool-1.2.15/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-30 \
--title="Web Server - Apache Statistics - Hits / s" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="Hits/sec" \
--slope-mode \
DEF:a="/var/www/cacti/rra/web_server_apache_idle_workers_95.rrd":apache_total_hits:AVERAGE \
AREA:a#AAABA1:"Hits/sec" \
GPRINT:a:LAST:"Current\:%8.2lf %s" \
GPRINT:a:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" \
mvam
Cacti User
Posts: 87
Joined: Wed Jun 01, 2005 2:00 pm
Location: Seattle

Post by mvam »

so it only seems to work from the CLI. when run from the poller i get:

12/13/2006 11:57:21 AM - PHPSVR: Poller[0] WARNING: Function does not exist
12/13/2006 11:57:21 AM - PHPSVR: Poller[0] WARNING: PHP Script File to be included, does not exist
User avatar
mahuani
Cacti User
Posts: 72
Joined: Tue Nov 01, 2005 2:10 pm
Location: Lafayette, LA
Contact:

Post by mahuani »

I'm gonna upload the modified script miclaro posted to the OP in a few minutes. It seems as though most people are having trouble with cURL.

As for it still not working for some people, I' m still trying to figure that out. I'm running it on CentOS 4.3 (Apache 2.0.52) and Gentoo (Apache 2.0.58 ) and it is working on both of those.

For those people who aren't getting anything back, CLI or otherwise.
Make sure you have loaded that proper modules in Apache, mod_status I think. Turn ExtendedStatus on and set the allow/deny policy if you so desire.

Code: Select all

     LoadModule status_module         modules/mod_status.so
     ExtendedStatus On
     <Location /server-status>
          SetHandler server-status
          Order deny,allow
          Deny from all
          Allow from localhost
     </Location>
Don't worry about fooling with the script until you get the server-status working within Apache. Use a text based browser if you have to.

Code: Select all

 http://localhost/server-status?auto 
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest