Menu
Index

Contact
Atom Feed
Comments Atom Feed

Similar Articles

2012-04-26 16:59
MySQL Performance Graphs on Cacti via SNMP
2012-10-16 19:23
vmstat on Cacti via SNMP
2009-10-31 11:03
Linux (Debian, Ubuntu) SNMP basics
2013-03-24 15:44
fail2ban on Cacti via SNMP
2013-03-24 16:19
Detailed process statistics on Cacti via SNMP (processes+)

Recent Articles

2019-07-28 16:35
git http with Nginx via Flask wsgi application (git4nginx)
2018-05-15 16:48
Raspberry Pi Camera, IR Lights and more
2017-04-23 14:21
Raspberry Pi SD Card Test
2017-04-07 10:54
DNS Firewall (blackhole malicious, like Pi-hole) with bind9
2017-03-28 13:07
Kubernetes to learn Part 4

Glen Pitt-Pladdy :: Blog

iostat on Cacti via SNMP

After a long silence I've finally got round to releasing these templates. The theme is rather simple: take a standard tuning tool and with a tiny bit of scripting deliver it's output via SNMP for Cacti to graph.

This gives you always-on data about the performance of a system and allows unexpected changes to be easily spotted on Cacti graphs.

iostat to SNMP

Like I described previously in my SNMP Basics article, I run a cron job to pick up data and dump it in files where snmpd can pick it up as a low privilege user. I'm doing the same here, except that I'm using it to run iostat in the background to collect data over the polling period.

Download: all the iostat Cacti scripts, files and templates are now on GitHub

Take the data collection script iostat-cron, make this executable and stick it somewhere convenient. I will assume /etc/snmp for this article with the output files in /var/local/snmp. Then add to the SNMP cron job (described previously) some lines to run this in the background:

# background the iostat run
/etc/snmp/iostat-cron /var/local/snmp/iostat &

That will launch iostat in a wrapper which will run for 5 minutes (300 seconds) outputting to a temporary file and rename the temporary file to the name given as the first argument. You can easily alter the script if you poll more/less frequently. Also you can modify the iostat arguments to output per-partition statistics if you require.

Check that the output file is being created and has data in it - it will take 5 minutes from the next cron run before the file is created.

Make the extension script iostat-stats executable and put it somewhere suitable like /etc/snmp which is what we will assume for this article. There are two different variants I know of with the format of the output of iostat: recent versions have additional r_await and w_await columns. Run "iostat -x" to check. Next, to get the data into snmpd add the following to the /etc/snmp/snmpd.conf file if you don't have r_await and w_await columns:

extend iostatdev /etc/snmp/iostat-stats 1
extend iostatmountpoint /etc/snmp/iostat-stats mountpoint
extend iostatrrqms /etc/snmp/iostat-stats 2
extend iostatwrqms /etc/snmp/iostat-stats 3
extend iostatrs /etc/snmp/iostat-stats 4
extend iostatws /etc/snmp/iostat-stats 5
extend iostatrkbs /etc/snmp/iostat-stats 6
extend iostatwkbs /etc/snmp/iostat-stats 7
extend iostatavgrqsz /etc/snmp/iostat-stats 8
extend iostatavgqusz /etc/snmp/iostat-stats 9
extend iostatawait /etc/snmp/iostat-stats 10
extend iostatsvctm /etc/snmp/iostat-stats 11
extend iostatutil /etc/snmp/iostat-stats 12

Or, if you do have r_await and w_await columns:

extend iostatdev /etc/snmp/iostat-stats 1
extend iostatmountpoint /etc/snmp/iostat-stats mountpoint
extend iostatrrqms /etc/snmp/iostat-stats 2
extend iostatwrqms /etc/snmp/iostat-stats 3
extend iostatrs /etc/snmp/iostat-stats 4
extend iostatws /etc/snmp/iostat-stats 5
extend iostatrkbs /etc/snmp/iostat-stats 6
extend iostatwkbs /etc/snmp/iostat-stats 7
extend iostatavgrqsz /etc/snmp/iostat-stats 8
extend iostatavgqusz /etc/snmp/iostat-stats 9
extend iostatawait /etc/snmp/iostat-stats 10
extend iostatrawait /etc/snmp/iostat-stats 11
extend iostatwawait /etc/snmp/iostat-stats 12
extend iostatsvctm /etc/snmp/iostat-stats 13
extend iostatutil /etc/snmp/iostat-stats 14

That simply picks up the column specified from data file when SNMP is queried. Restart snmpd and you should be able to test that with snmpwalk as described in previous articles.

SNMP to Cacti

I have the query xml iostat.xml in /usr/local/share/cacti/resource/snmp_queries/ however if you put it elsewhere then you will need to modify the data query path in the template to match.

Import the Cacti template cacti_host_template_iostat.xml into Cacti and add it to the host you have configured above. Add the graphs and all going well after a couple polls data should start appearing on the graphs.

IMPORTANT: You can only use the "rwawait" graph if your iostat has r_await and w_await columns.

What it looks like

iostat %util statistics on Cacti

iostat avgqu-sz statistics on Cacti

iostat avgrq-sz statistics on Cacti

iostat await statistics on Cacti

iostat merge efficiency statistics on Cacti

iostat rqm/s statistics on Cacti

iostat rw/s statistics on Cacti

iostat svctm statistics on Cacti

iostat rwB/s statistics on Cacti