For work it seemed useful to graph how busy our MySQL servers are, so after a quick check on the web, I put together the following pieces of gum and rope:
- A query script to get the desired value, let’s call it snmp_helper:
#!/bin/sh mysqladmin status | awk {'print $'$1}
- Two entries in our /etc/snmp/snmpd.conf file so that it can be accessed from the host that does the actual graphing:
exec mysql-queries <path-to-snmp_helper>/snmp_helper 6 exec mysql-slow <path-to-snmp_helper>/snmp_helper 9
- Entries in the /etc/mrtg.cfg file that look roughly like this:
LegendI[_]: Queries LegendO[_]: Slow Legend1[_]: Queries Legend2[_]: Slow queries YLegend[_]: Queries ShortLegend[_]: Q/s Target[mysql]: 1.3.6.1.4.1.2021.8.1.101.1&1.3.6.1.4.1.2021.8.1.101.2:community@mysqlserver options[mysql]: growright nopercent Title[mysql]: MySQL Stats PageTop[mysql]: <h1>MySQL Stats</h1> RouterUptime[mysql]: community@mysqlserver
Voila, another happy customer (me). 😉