Web Hosting Talk







View Full Version : Analyse your http e mysql requests on MRTG!


Lem0nHead
09-08-2004, 02:17 AM
hello

this shell script generates the number of http requests/second on the first line and mysql requests/second (average) on second line

that's all MRTG needs to make a graphic

the script should work on any cpanel server... for other control panels it will need modifications on the apache status url (who finds the URL for other panels may post on this thread to help others):

#!/bin/sh
# by Luís Fernando Estrozi - 09/08/2004

echo `lynx -dump http://127.0.0.1/whm-server-status?auto | grep ReqPerSec | awk '{print$2}'`
PASS=`cat /root/.my.cnf | grep pass | cut -d'=' -f2`
echo `mysqladmin -uroot -p$PASS status | awk '{print$22}'`

save it as /your_mrtg_path/reqpersec
chmod 755 /your_mrtg_path/reqpersec

now edit mrtg.cfg and add:

#----------------------------
# Requests per second
#----------------------------

Target[reqpersec]: `/etc/mrtg/reqpersec`
Title[reqpersec]: Requests per second
PageTop[reqpersec]: <h3>Requests per second</h3>
YLegend[reqpersec]: Requests per second
ShortLegend[reqpersec]: &nbsp;&nbsp;&nbsp;
LegendI[reqpersec]: apache&nbsp;
LegendO[reqpersec]: mysql&nbsp;

service mrtg restart

good luck

BizB
09-08-2004, 03:34 AM
i did all that but nothing changed in my mrtg page ?!

Lem0nHead
09-08-2004, 09:14 AM
Originally posted by BizB
i did all that but nothing changed in my mrtg page ?!

the index didn't change
just access http://.../mrtg/reqpersec.html

BizB
09-08-2004, 11:42 AM
cool found it
thanks

evilek
02-17-2005, 04:46 PM
# /etc/rc.d/init.d/mrtg start
Starting MRTG: /etc/rc.d/init.d/mrtg: /usr/bin/mrtg: /usr/local/bin/perl: bad interpreter: No such file or directory

wtf ?
i have perl.. and show this msg :angry:

anyone know how to fix it?

sehe
02-17-2005, 06:55 PM
Starting MRTG: /etc/rc.d/init.d/mrtg: /usr/bin/mrtg: /usr/local/bin/perl: bad interpreter: No such file or directory

does your perl binary exist in /usr/local/bin/? i guess not
maybe /usr/bin/perl?
you can fix it with a symlink

sehe
02-17-2005, 07:24 PM
Originally posted by Lem0nHead
the script should work on any cpanel server... for other control panels it will need modifications on the apache status url (who finds the URL for other panels may post on this thread to help others):


echo `lynx -dump http://127.0.0.1/whm-server-status?auto | grep ReqPerSec | awk '{print$2}'`


untested

lynx --dump http://127.0.0.1/server-status | grep "requests/sec" | awk {'print $1'}

needs server-status and "ExtendedStatus On" in httpd.conf