Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


[XML] successor to apachestats 0.4
Goto page 1, 2, 3, 4, 5, 6, 7, 8, 9  Next
 
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates
Author Message
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12295
Location: Muenster, Germany

PostPosted: Sun Oct 16, 2005 4:58 am    Post subject: [XML] successor to apachestats 0.4 Reply with quote

Script was updated due to initialization errors. Please replace old one
Templates have been updated due to errors with newer cacti versions
This post is based on http://forums.cacti.net/viewtopic.php?t=4028 which contains the well know apachestats XML of Rolf Poser. Due to several questions arising (and some fun to have yet another simple perl script), I extended both two of the existing Graph Templates as well as implementing two new ones.
I did not include the docs from Rolf, as they hold for this version as well.
The script is based on the ws_apachestats_hs.pl, so it uses wget. This may as well be adjusted at your own. It has been enhanced in two ways:
- it includes CPULoad and Thread Scoreboard output
- output is performed in one single "print" statement to overcome possible problems using cactid

With later cacti versions, problems were reported with two of the graphs, the "Bytes/Requets" and the "Thread Details (%)" one. These have been corrected as they were due to the fact, that LINEx statements without color were defined.

Explanation of the Output for the "Thread Scoreboard" is best done using the "server-status" URL at your Webserver (e.g. http://<your webserber>/server-status)

ATTENTION
This script extends the Apache Webserver Data Template. So be careful, if you are using the apachestats-0.4 already! As well, the existing Apachestats Graph Templates will be modified!
At the moment, I do not know any way, to modify existing RRDs to include the additional Data Sources needed for CPULoad and Thread Scoreboard (perhaps export/manually modify/import will do?)
SO IT IS WISE NOT TO IMPORT DIRECTLY TO A PRODUCTION SYSTEM
If anyone knows a better way to do this, I'll appreciate to here from you.

Multiple RRDs
Due to the lack of my knowledge of the cacti system, I was not able to suppress the generation of one RRD for each of the Graph Templates. So, if you are going to define all 7 Graph Templates, you will notice 7 RRDs as well. All of them will hold "the same" data. The webserver is inquired 7 times for the same set of data. This is not a desired behaviour. There is a chance to get rid of 6 of them manually (Well, I did this yesterday, but took me "some time". It seems not that easy to describe this here)

As always, use this at your own risk.
Comments, enhancements and the like are appreciated

happy cactiing
Reinhard



apachestats-0.5.png
 Description:
Some 6 of the 7 graphs (well, my laptop was a little overloaded, this caused the gaps in the graphs)
 Filesize:  161.81 KB
 Viewed:  63794 Time(s)

apachestats-0.5.png



cacti087b_host_template_webserver_-_apache.xml
 Description:
UPDATE
Host Template XML for cacti 087b and up
Corrects a Problem with Thread Graph

Download
 Filename:  cacti087b_host_template_webserver_-_apache.xml
 Filesize:  103.3 KB
 Downloaded:  3487 Time(s)


ws_apachestats.pl.gz
 Description:
UPDATE
gzipped perl script to be placed at <path_cacti>/scripts/ws_apachestats.pl

Download
 Filename:  ws_apachestats.pl.gz
 Filesize:  1.46 KB
 Downloaded:  7078 Time(s)


cacti_host_template_webserver_apache.xml
 Description:
The Webserber Host Template XML
Import this one at least using Version cacti 0.8.6g

Download
 Filename:  cacti_host_template_webserver_apache.xml
 Filesize:  97.32 KB
 Downloaded:  13788 Time(s)



Last edited by gandalf on Sun Mar 09, 2008 5:53 am; edited 3 times in total
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12295
Location: Muenster, Germany

PostPosted: Sun Oct 16, 2005 2:31 pm    Post subject: Reply with quote

Just did some tweaking with the "old" and the "new" templates to check any oddities in the mixture of both.
First, I cleared all my "old" resources: Existing Graphs and RRDs as well as all ApacheStats Graph, Data and Host Templates; even the CDEFs.
The I imported the ApacheStats 0.4 Templates and build all 5 Graphs (well, I had to tweak the both corrupted ones as described above to get them to work). This all went fine, as desired.
Now I imported the new ApacheStats Templates. Import went well . Not to forget the new ws_apachestats.pl script!
Checked all Templates, they look as desired.
At last I build both new Graph Templates (CPULoad and Thread Scoreboard). No probs up to this.
I seems, that "overloading" existing Data Templates in this way does not confuse cacti!

The last thing remains: Both new templates will create their own RRDs.

I hope this will ease upgrading ...
Reinhard
Back to top
JJX
Cacti User


Joined: 06 Oct 2005
Posts: 171

PostPosted: Mon Oct 17, 2005 6:11 am    Post subject: Reply with quote

i am facing a strange(?) error:

Quote:
debian:/var/www/cacti/scripts# su www-data
debian:~/cacti/scripts$ ./ws_apachestats.pl 127.0.0.1
apache_total_hits:165 apache_total_kbytes:227 apache_busy_workers:1 apache_idle_workers:8 thread_O:247 threadC:0 threadD:0 threadG:0 threadI:0 threadK:0 threadL:0 threadR:0 threadS:0 threadW:1 thread_W:8 apache_cpuload:3.78073


works fine

when i run the poller:

Quote:
debian:~/cacti/scripts$ ../poller.php
Waiting on 1/1 pollers.
Waiting on 1/1 pollers.
Use of uninitialized value in concatenation (.) or string at /var/www/cacti/scripts/ws_apachestats.pl line 63.
Use of uninitialized value in concatenation (.) or string at /var/www/cacti/scripts/ws_apachestats.pl line 65.
Use of uninitialized value in concatenation (.) or string at /var/www/cacti/scripts/ws_apachestats.pl line 67.
Use of uninitialized value in concatenation (.) or string at /var/www/cacti/scripts/ws_apachestats.pl line 69.
Use of uninitialized value in split at /var/www/cacti/scripts/ws_apachestats.pl line 89.
Use of uninitialized value in concatenation (.) or string at /var/www/cacti/scripts/ws_apachestats.pl line 103.
Use of uninitialized value in concatenation (.) or string at /var/www/cacti/scripts/ws_apachestats.pl line 63.
Use of uninitialized value in concatenation (.) or string at /var/www/cacti/scripts/ws_apachestats.pl line 65.
Use of uninitialized value in concatenation (.) or string at /var/www/cacti/scripts/ws_apachestats.pl line 67.
Use of uninitialized value in concatenation (.) or string at /var/www/cacti/scripts/ws_apachestats.pl line 69.
Use of uninitialized value in split at /var/www/cacti/scripts/ws_apachestats.pl line 89.
Use of uninitialized value in concatenation (.) or string at /var/www/cacti/scripts/ws_apachestats.pl line 103.
Use of uninitialized value in concatenation (.) or string at /var/www/cacti/scripts/ws_apachestats.pl line 63.
Use of uninitialized value in concatenation (.) or string at /var/www/cacti/scripts/ws_apachestats.pl line 65.
Use of uninitialized value in concatenation (.) or string at /var/www/cacti/scripts/ws_apachestats.pl line 67.
Use of uninitialized value in concatenation (.) or string at /var/www/cacti/scripts/ws_apachestats.pl line 69.
Use of uninitialized value in split at /var/www/cacti/scripts/ws_apachestats.pl line 89.
Use of uninitialized value in concatenation (.) or string at /var/www/cacti/scripts/ws_apachestats.pl line 103.


any idea?

i think this problem is because ws_apachestats.pl doesnt get correct parameters....
any idea?
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12295
Location: Muenster, Germany

PostPosted: Tue Oct 18, 2005 9:33 am    Post subject: Reply with quote

You'll have to feed the hostname to the script. This should be done via the Data Input Method. It should have one Input Parameter, <hostname>. This should, of course, be done by the Host Template you have imported. Please post the screen of your Data Input Method for Apache Webstats.
Reinhard
Back to top
JJX
Cacti User


Joined: 06 Oct 2005
Posts: 171

PostPosted: Tue Oct 18, 2005 11:40 am    Post subject: Reply with quote

here is a screenshot - it looks fine


dim.gif
 Description:
 Filesize:  32.79 KB
 Viewed:  63638 Time(s)

dim.gif


Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12295
Location: Muenster, Germany

PostPosted: Wed Oct 19, 2005 9:00 am    Post subject: Reply with quote

Yes, indeed, looks as expected. So I'll have to have a more detailed view at it.
Reinhard
Back to top
pyoung



Joined: 07 Nov 2005
Posts: 13

PostPosted: Mon Nov 07, 2005 2:57 pm    Post subject: Reply with quote

How did you pare down the script so it's not storing duplicated RRD data?
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12295
Location: Muenster, Germany

PostPosted: Tue Nov 08, 2005 5:30 pm    Post subject: Reply with quote

pyoung wrote:
How did you pare down the script so it's not storing duplicated RRD data?
Well, to be honest, it DOES create all that duplicate rrd's if you create all graphs from the device screen.
You may do so and AFTERWARDS change the references to these rrd's from the Data Source list. Then you may delete the obsolete rrd's.
OR, you create only ONE of the graphs from the device screen. The others must be created from the Graph Management screen (not remembering exactly, no cacti installation here at the moment). There you may refer to the Graph Template AND define the rrd file manually (if I'm mistaken, it must have been the [/b]Data Source screen instead).
AFAIK there's no option to do this automatically
Reinhard
Back to top
Ingimar



Joined: 21 Feb 2005
Posts: 7

PostPosted: Thu Nov 10, 2005 11:19 am    Post subject: Reply with quote

Hi there.

I just installed the Apache status. I have extended status on in httpd.conf and access to /server-status works fine. I run the ws_apachestats.pl script and the output seems fine:

ws_apachestats.pl output wrote:
apache_total_hits:6338 apache_total_kbytes:214646 apache_busy_workers:4 apache_idle_workers:9 thread_O:243 threadC:0 threadD:0 threadG:0 threadI:0 threadK:0 threadL:0 threadR:1 threadS:0 threadW:3 thread_W:9 apache_cpuload:12.1027


There are no errors in cacti.log and all graphs look fine to me except the Apache Statistics - CPU Load graph which does not display (it's not empty, it just does not display at all). When I check the properties for the graph they are:


Apache Statistics - CPU Load - Graph properties wrote:
/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Baula - Apache Statistics - CPU Load" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="Apache CPU Load" \
DEF:a="/var/www/cacti/rra/baula_apache_cpuload_26.rrd":apache_cpuload:AVERAGE \
DEF:b="/var/www/cacti/rra/baula_apache_cpuload_26.rrd":apache_cpuload:MAX \
DEF:c="/var/www/cacti/rra/baula_apache_cpuload_26.rrd":apache_cpuload:AVERAGE \
CDEF:cdeff=c,1800,TREND \
AREA:c#FF5F00:"Apache CPU Load" \
GPRINT:c:LAST:"Current\:%8.2lf %s" \
GPRINT:c:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:b:MAX:"Maximum\:%8.2lf %s" \
LINE1:b#FF0000:"MAX" \
LINE1:cdeff#000000:"30min moving average\n"


And when I try running this rrdtool command from the command line I get the following error from rrdtool:

Output from the above rrdtool command wrote:
ERROR: invalid rpn expression 'c,1800,TREND'


Could this be causing the graph not to be displayed?

I'm running on Cacti 0.8.6g on CentOS 4.2 with RRDTool 1.0.50. Both Cacti and RRDTool are fetched from Dag's RPM repository.

I hope someone can help me with this one.
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12295
Location: Muenster, Germany

PostPosted: Sat Nov 12, 2005 4:58 am    Post subject: Reply with quote

This may be related to rrdtool 1.0.x. I used the TREND function. You may delete the "30 min moving average" items out of the graph template to get rid of this
Reinhard
Back to top
Ingimar



Joined: 21 Feb 2005
Posts: 7

PostPosted: Sat Nov 12, 2005 7:15 am    Post subject: Reply with quote

lvm wrote:
This may be related to rrdtool 1.0.x. I used the TREND function. You may delete the "30 min moving average" items out of the graph template to get rid of this
Reinhard


That did the trick! Thanks alot!
Back to top
suse



Joined: 13 Nov 2005
Posts: 23

PostPosted: Tue Nov 15, 2005 8:30 am    Post subject: Reply with quote

one problem
I found
CACTID: Host[3] ERROR: Empty result [hostname]: 'perl /home/mrtg/cacti/scripts/ws_apachestats.pl hostname'
CACTID: Host[3] DS[84] WARNING: Result from SCRIPT not valid. Partial Result: ...


but if I ran perl /home/mrtg/cacti/scripts/ws_apachestats.pl hostname
I can get this
apache_total_hits:3424769 apache_total_kbytes:4463443333 apache_busy_workers:179 apache_idle_workers:31 thread_O:290 threadC:5 threadD:0 threadG:0 threadI:0 threadK:66 threadL:0 threadR:5 threadS:0 threadW:103 thread_W:31 apache_cpuload:.0389393

so why my data can not be polled?
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12295
Location: Muenster, Germany

PostPosted: Wed Nov 16, 2005 3:31 pm    Post subject: Reply with quote

suse wrote:
one problem
I found
CACTID: Host[3] ERROR: Empty result [hostname]: 'perl /home/mrtg/cacti/scripts/ws_apachestats.pl hostname'
CACTID: Host[3] DS[84] WARNING: Result from SCRIPT not valid. Partial Result: ...
Please replace "perl" by the "/full/path/to/perl" (from the Data Source Screen). Remember to "Clear Poller Cache" from Settings to regenerate all commands used by the poller.
Reinhard
Back to top
stevewest15



Joined: 25 Oct 2005
Posts: 9

PostPosted: Mon Dec 05, 2005 4:06 pm    Post subject: Reply with quote

Hi,

Great job on this script! I'm a newbie and trying to figure out why 4 of the graphs don't plot (Bytes/Request, CPU Load, Hits/s, & Kbits/s). Not sure where to look at trouble shooting. Here is what I'm seeing in my cacti/log/cacti.log:

Quote:
12/05/2005 03:40:01 PM - CMDPHP: Poller[0] Host[1] DS[79] CMD: perl /home/apache/htdocs/cacti/scripts/ws_apachestats.pl localhost, output: apache_total_hits: apache_total_kbytes: apache_busy_workers:5 apache_idle_workers:5 thread_O:1014 threadC:0 threadD:0 threadG:0 threadI:0 threadK:3 threadL:0 threadR:0 threadS:0 threadW:2 thread_W:5


I can access wget localhost/server-status which provides me with various apache 1.3 server status.

Can anyone help me look at what's causing not getting these graphs?

thx,

SW
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12295
Location: Muenster, Germany

PostPosted: Wed Dec 07, 2005 3:42 pm    Post subject: Reply with quote

The Script uses the /server-status?auto URL and parses the output. Please post the output of your webserver when pointing to that url
Reinhard
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates All times are GMT - 5 Hours
Goto page 1, 2, 3, 4, 5, 6, 7, 8, 9  Next
Page 1 of 9

 



Powered by phpBB © 2001, 2005 phpBB Group