ApacheStats 0.6 (PHP Script Server Version)

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

Moderators: Moderators, Developers

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

ApacheStats 0.6 (PHP Script Server Version)

#1 Post by mahuani » Wed Nov 22, 2006 6:43 pm

This is an update to the the popular apachestats script by Rolf Poser. I promised The Witness i would convert the perl script to a SS version (php), so here is is. I'm still in the process of learning PHP, so if anyone has any suggestions, comments, etc.. the are most welcome.

Here is I believe the latest thread on the original script
http://forums.cacti.net/viewtopic.php?t=9861


There is a host template for a 5 min poller and a 30 sec poller in the zip file.

Fixed the PHP4 problem. So the script SHOULD work on both PHP4 and PHP5. I've tested on my servers but anyone who is willing to test it out please let me know of any problems.

Here are some screenshots.
Image
Image
Image
Image
Image
Image
Image
Attachments
ss_apache_stats.zip
This version doesn't use cURL, so if you don't have it compiled into PHP use this version. This .zip file doesn't contain the host template, script only.
(1.32 KiB) Downloaded 4035 times
SS_Apache_Stats.zip
ApacheStats 0.64. This version uses cURL so if you know you have it compiled into PHP use this version.
(23.56 KiB) Downloaded 6440 times
Last edited by mahuani on Sun Dec 17, 2006 4:55 pm, edited 6 times in total.

User avatar
TheWitness
Developer
Posts: 14855
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

#2 Post by TheWitness » Wed Nov 22, 2006 7:38 pm

Very Nice!!!

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

Phyo
Posts: 1
Joined: Wed Nov 22, 2006 10:49 pm

#3 Post by Phyo » Wed Nov 22, 2006 10:51 pm

Cannot Import XML file. It saids XML parse error.

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

#4 Post by mahuani » Wed Nov 22, 2006 11:45 pm

Hum... I'm getting the same thing. I thought it might be because I changed the 30 second template to a 5 min template, but I get the parse error when I export it, then immediately try to re-import it. I'll try to look at it tonight, but I might not get any real time untill Friday morning.

:x

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

#5 Post by mahuani » Thu Nov 23, 2006 12:00 am

Ok, I think I fixed it. I uploaded a new version to the intital post. Try to download it again.

xmtx
Posts: 4
Joined: Fri Nov 17, 2006 11:09 am

#6 Post by xmtx » Thu Nov 23, 2006 8:13 am

im getting the same error with your "new" version: Error: XML parse error.

xmtx
Posts: 4
Joined: Fri Nov 17, 2006 11:09 am

#7 Post by xmtx » Thu Nov 23, 2006 8:20 am

well if you are using Cacti - 0.8.6i i've found my failure...i'm using 0.8.6g :(

damn this script looks so nice...

marcmo
Posts: 27
Joined: Wed Sep 21, 2005 3:39 pm

#8 Post by marcmo » Fri Nov 24, 2006 9:48 am

I also noticed a few instances of rrd_heartbead instead of rrd_heartbeat in the 5min xml file. Once I fixed these it imported fine.

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

#9 Post by mahuani » Sun Nov 26, 2006 12:43 am

Yea, the import worked for me because I was using the 30 second template. I've fixed the five minute template, rrd_heartbead -> rrd_heartbeat, problem. New version on OP.

Is anyone having problems with the script itself?

User avatar
Pumpi
Cacti User
Posts: 256
Joined: Wed Jan 14, 2004 3:23 am
Location: Germany

#10 Post by Pumpi » Mon Nov 27, 2006 4:27 am

mahuani,

it will be nice that you can share a version for PHP 4.x.

Pumpi

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

#11 Post by mahuani » Tue Nov 28, 2006 2:34 am

The script should work with PHP4 and PHP5 now. I've updated the zip file so everyone can test away. It is working on one of my boxes, but since I'm not at work I'll wait till tomorrow to fully deploy it.

If anyone has any problems with it please let me know.

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

#12 Post by mahuani » Tue Nov 28, 2006 3:06 pm

That change I made last night had one small minor mistake in it :(. It has been fixed. I have it running in my PHP4 environment now, and it seems to be doing fine.

cray74
Posts: 4
Joined: Fri Dec 01, 2006 4:46 am

empty graphs

#13 Post by cray74 » Fri Dec 01, 2006 5:17 am

Hi!

Accidentally posted my question as a new topic:

[http://forums.cacti.net/viewtopic.php?t=18203]

Any help would be appreciated.

P.S: how can I contact a moderator to move my posting to this thread?[/url]

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

#14 Post by mahuani » Mon Dec 04, 2006 9:48 pm

What happens if you run the script from the script server on the command line?

See the documentation [Testing your Script in the Script Server]

Code: Select all


Testing Your Script in the Script Server

To test your script in the script server, simply follow the instructions below. When you have finished you testing, simply type "quit" <cr< at the Script Server command line to exit the script server.

   1. Start the script server - You can do this by typing the following command:

      shell> php <path_cacti>/script_server.php

      NOTE: Due to a bug in Windows implementation of PHP, you must type the full path name to the script_server.php file.
   2. Type in your command - Using the example from above, you would type in the following:

      script server> <path_myfunction> my_function argument1 argument2 ...

      In the Windows environment, your example could be the following:

      script server> c:\wwwroot\cacti\scripts\ss_myfunction.php ss_myfunction localhost public 1 get duddle

   3. If your function is operating properly, you should get a result.

   4. To quit the script server, simply type "quit" <cr> at the command line.

NOTE: If there are errors in your script, you must restart the script server before your retest your code.

cray74
Posts: 4
Joined: Fri Dec 01, 2006 4:46 am

#15 Post by cray74 » Thu Dec 07, 2006 4:08 am

from the CLI it works:
[[email protected] scripts]# php ./ss_apache_stats.php eunbrux09.eun.org
apache_total_hits:5465153 apache_total_kbytes:40996177 apache_cpuload:.196092 thread_W:14 threadS:0 threadR:0 threadW:4 threadK:28 threadD:0 threadC:0 threadL:0 threadG:9 threadI:0 thread_O:201[[email protected] scripts]#

Post Reply