Unix/Linux Go Back    


Infrastructure Monitoring Forum for Nagios, Zabbix and other network monitoring and management tools.

Zabbix Template and PERL Script for Monitoring Apache2

Infrastructure Monitoring


Tags
apache2, zabbix

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 03-09-2009
Neo's Unix or Linux Image
Neo Neo is offline Forum Staff  
Administrator
 
Join Date: Sep 2000
Last Activity: 22 September 2017, 1:33 AM EDT
Location: Asia pacific region
Posts: 13,632
Thanks: 863
Thanked 1,168 Times in 547 Posts
Zabbix Template and PERL Script for Monitoring Apache2

Hello,

Kindly find attached a copy of the Zabbix template and PERL script we are using to monitor our Apache2 server.

Here are the entries for zabbix_agentd.conf


Code:
UserParameter=apache2.total_accesses,/etc/zabbix/zabbix_apache2.pl|cut -f1 -d":"
UserParameter=apache2.total_kbytes,/etc/zabbix/zabbix_apache2.pl|cut -f2 -d":"
UserParameter=apache2.cpuload,/etc/zabbix/zabbix_apache2.pl|cut -f3 -d":"
UserParameter=apache2.uptime,/etc/zabbix/zabbix_apache2.pl|cut -f4 -d":"
UserParameter=apache2.reqpersec,/etc/zabbix/zabbix_apache2.pl|cut -f5 -d":"
UserParameter=apache2.bytespersec,/etc/zabbix/zabbix_apache2.pl|cut -f6 -d":"
UserParameter=apache2.bytesperreq,/etc/zabbix/zabbix_apache2.pl|cut -f7 -d":"
UserParameter=apache2.busyworkers,/etc/zabbix/zabbix_apache2.pl|cut -f8 -d":"
UserParameter=apache2.idleworkers,/etc/zabbix/zabbix_apache2.pl|cut -f9 -d":"
UserParameter=apache2.totalworkers,/etc/zabbix/zabbix_apache2.pl|cut -f10 -d":"

zabbix_apache2.pl and the template Template_Apache2_Server (zabbix_apache2.xml) are attached.

If you need additional installation instructions or want to report bugs or fixs, feel free to ask or post.
Attached Files
File Type: xml zabbix_apache2.xml (6.3 KB, 509 views)
File Type: pl zabbix_apache2.pl (1.4 KB, 660 views)
The Following 3 Users Say Thank You to Neo For This Useful Post:
ghalimer (05-12-2010), mnnn (08-30-2016), tigerq326 (02-20-2012)
Sponsored Links
    #2  
Old Unix and Linux 03-10-2009
Neo's Unix or Linux Image
Neo Neo is offline Forum Staff  
Administrator
 
Join Date: Sep 2000
Last Activity: 22 September 2017, 1:33 AM EDT
Location: Asia pacific region
Posts: 13,632
Thanks: 863
Thanked 1,168 Times in 547 Posts
Version 2: Zabbix Template and PERL Script for Monitoring Apache2

Based on a recommendation at the Zabbix forums, we updated this Zabbix template and PERL script we are using to monitor our Apache2 server.

Here are the entries for zabbix_agentd.conf


Code:
UserParameter=apache2.total_accesses,cut -f1 -d":" /tmp/apache_data.txt
UserParameter=apache2.total_kbytes,cut -f2 -d":" /tmp/apache_data.txt
UserParameter=apache2.cpuload,cut -f3 -d":" /tmp/apache_data.txt
UserParameter=apache2.uptime,cut -f4 -d":" /tmp/apache_data.txt
UserParameter=apache2.reqpersec,cut -f5 -d":" /tmp/apache_data.txt
UserParameter=apache2.bytespersec,cut -f6 -d":" /tmp/apache_data.txt
UserParameter=apache2.bytesperreq,cut -f7 -d":" /tmp/apache_data.txt
UserParameter=apache2.busyworkers,cut -f8 -d":" /tmp/apache_data.txt
UserParameter=apache2.idleworkers,cut -f9 -d":" /tmp/apache_data.txt
UserParameter=apache2.totalworkers,cut -f10 -d":" /tmp/apache_data.txt

Basically, we have moved the PERL script to a crontab running every minute and we then write the results to a /tmp file. Then the Zabbix agent reads the data from the file instead of calling the PERL script 10 times. This is more efficient.

Also, we change the template to update every 60 seconds instead of 30 seconds to match the crontab entry.

Files attached. If you have any questions, please post here.
Attached Files
File Type: pl zabbix_apache2.cron.pl (1.5 KB, 609 views)
File Type: xml zabbix_apache2_v2.xml (6.3 KB, 477 views)
The Following User Says Thank You to Neo For This Useful Post:
tigerq326 (02-20-2012)
Sponsored Links
    #3  
Old Unix and Linux 03-19-2009
Neo's Unix or Linux Image
Neo Neo is offline Forum Staff  
Administrator
 
Join Date: Sep 2000
Last Activity: 22 September 2017, 1:33 AM EDT
Location: Asia pacific region
Posts: 13,632
Thanks: 863
Thanked 1,168 Times in 547 Posts
Version 3: Zabbix Scripts for Monitoring Apache2 (+ vBulletin)

We updated this Zabbix template and scripts we are using to monitor our Apache2 server. In this version, we add monitoring for web crawlers (spiders), Treason uncloaked! (TCP bug) and for vBulletin online users stats:

Here are the addition entries for zabbix_agentd.conf


Code:
UserParameter=spider.googlebot,cut -f1 -d":" /tmp/zabbix_spiders.dat
UserParameter=spider.slurp,cut -f2 -d":" /tmp/zabbix_spiders.dat
UserParameter=spider.others,cut -f3 -d":" /tmp/zabbix_spiders.dat
UserParameter=vbulletin.totalonline,cut -f1 -d":" /tmp/zabbix_vbulletin.txt
UserParameter=vbulletin.membersonline,cut -f2 -d":" /tmp/zabbix_vbulletin.txt
UserParameter=vbulletin.guestsonline,cut -f3 -d":" /tmp/zabbix_vbulletin.txt
UserParameter=security.treason,cut -f1 -d":" /tmp/zabbix_security.dat

Here are the scripts (we run them in cron):

This simple one is for detecting spiders with a two minute delay, to give time for the log file to catch up. However, during heavy load times, more delay might be needed:


Code:
#!/bin/bash
#spiders.sh
TIME=`date +%d/%b/%Y:%H:%M`
LOG="/website/logs/apache2/access.log"
sleep 120
GBOT=`grep "$TIME" "$LOG"| grep Googlebot |wc -l`
SLURP=`grep "$TIME" "$LOG"|grep "Yahoo! Slurp" |wc -l`
OTHER=`grep "$TIME" "$LOG"|grep -i bot| grep -v "Yahoo! Slurp"|grep -v Googlebot |grep -v Firefox|wc -l`
echo $GBOT:$SLURP:$OTHER > /tmp/zabbix_spiders.dat

This simple one is for detecting the Treason Uncloaked! TCP Bug:


Code:
#!/bin/bash
#security.sh
TIME=`date +%d/%b/%Y:%k:%M`
LOG="/var/log/kern.log"
sleep 60
TREASON=`grep "$TIME" "$LOG"| grep -i "Treason Uncloaked" |wc -l`
echo $TREASON: > /tmp/zabbix_security.dat

This simple php code is for writing vBulletin online user information to a temp file for Zabbix:


Code:
$ourFileName = "/tmp/zabbix_vbulletin.txt";
$zabbixfile = fopen($ourFileName, 'w+');
vfprintf($zabbixfile,"%s:%s:%s\n",array($totalonline,$numberregistered,$numberguest));
fclose($zabbixfile);

We call this from a modified index.php file from cron instead of directly from the vB production code to minimize the load.
The Following User Says Thank You to Neo For This Useful Post:
tigerq326 (02-20-2012)
    #4  
Old Unix and Linux 05-20-2010
avrilspirit avrilspirit is offline
Registered User
 
Join Date: May 2010
Last Activity: 20 May 2010, 2:48 PM EDT
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Hello,
Thanks for your script Linux
I juste want to try for apache but when I try with an zabbix_get -s192.168.0.8 -kapache2.total_accesses

I received all the time this message :
ZBX_NOTSUPPORTED

My zabbix_agentd is well configured with ipserver 192.168.0.165


Can you help me ?
The Following User Says Thank You to avrilspirit For This Useful Post:
tigerq326 (02-20-2012)
Sponsored Links
    #5  
Old Unix and Linux 05-20-2010
Neo's Unix or Linux Image
Neo Neo is offline Forum Staff  
Administrator
 
Join Date: Sep 2000
Last Activity: 22 September 2017, 1:33 AM EDT
Location: Asia pacific region
Posts: 13,632
Thanks: 863
Thanked 1,168 Times in 547 Posts
For ZBX_NOTSUPPORTED errors, perhaps you should post in the Zabbix forums?

ZBX_NOTSUPPORTED
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl Scripting for monitoring logs solitare123 UNIX for Dummies Questions & Answers 1 06-25-2008 06:49 AM
Log Monitoring through Perl solitare123 Shell Programming and Scripting 0 06-25-2008 06:42 AM



All times are GMT -4. The time now is 03:52 AM.