Squid and Mysql metric scripts for Ganglia
After a long day of meetings and other tedious manager work the perfect way to relax is to code. The best is a mini-projects where you see your results after an hour or so. I call these tasks “Plausch-Projekte” (“plah-oosh project” =”fun projects”).
This week my plah-oosh projects were two metric tools for Ganglia. Besides Nagios Ganglia is the main monitoring tool for our cluster. We monitor something like 20 metrics like load, memory, disk usage, network activity.
Ciprian and Stefan recently built a script to monitor apache (bytes/sec, hits/sec, idle processes etc.) via the /server-status interface. Based on their work I hacked two scripts:
ganglia_mysql_metrics.php monitors multiple mysql parameters like queries/sec, slow queries/sec, threads connected:
![]()
ganglia_squid_metrics.php reports regularly about squid metrics: Requests/sec, service time, available file descriptors:
![]()
The scripts are quick and dirty code. Procedural. Not well documented. Does only read the mcast_port from the config file and ignores the rest. But it might be a good base to be used on your cluster too. Just call them every minute via the crontab.

Do you have these available for Nagios? Very useful but we only use nagios and not ganglia?!
Comment by Ben — 11. November 2007 @ 23:27
Unfortunately not. We use Nagios also. But not for performance monitoring. Just to let us know if the services are running or not.
But programming custom checks in Nagios is pretty straightforward: You’ll find the guidelines here.
Comment by Silvan Mühlemann — 14. November 2007 @ 09:00
Do you guys have any documentation for writing Ganglia metric scripts ?
We were looking for custom scripts for a Ganglia cluster node.
Comment by digen — 17. December 2007 @ 18:06
It’s really straightforward. You’ll find an explanation here.
Your script should be a cronjob which runs every minute. And this job should call gmetric to submit the metrics to the ganglia server.
Comment by Silvan Mühlemann — 17. December 2007 @ 18:13
As a big user of ganglia (96 clusters) we’ve written similar gmetric scripts for squid and mysql, but kudos for actually motivating to make them available.
the ganglia community thanks you, you should post them to the ganglia-general mailing list.
Comment by allspaw — 21. May 2008 @ 18:54
Is there a repository for these gmetric scripts, I want to monitor all the mysql parameters, and also apache http requests.
thanks
Comment by Viven Rajendra — 18. June 2008 @ 09:27
Hi Viven
There is a repository at http://ganglia.sourceforge.net/gmetric/
Comment by Silvan Mühlemann — 22. June 2008 @ 21:08
[...] I haven’t had time to look at it yet but Silvan Mühlemann wrote a custom report php script for mysql [...]
Pingback by Ganglia rules! « David’s NEW Blog — 31. January 2009 @ 22:38
Hy,
I use ganglia to monitor 2 servers, and i sent this statistics to another server manager.I want to monitor new resources on them(servers) using new scripts but i don’t now haw to configure them in ganglia to collect results from them. i really appreciate if u help me
Thanks Ciprian
Comment by Ciprian — 25. March 2009 @ 16:41