Atom Feed
Comments Atom Feed

Similar Articles

2012-04-26 16:59
MySQL Performance Graphs on Cacti via SNMP
2012-10-16 20:07
iostat on Cacti via SNMP
2009-10-31 14:46
SMART stats on Cacti (via SNMP)
2009-10-31 11:03
Linux (Debian, Ubuntu) SNMP basics
2013-03-24 15:44
fail2ban on Cacti via SNMP

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

vmstat 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.

vmstat 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 vmstat 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 vmstat-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 vmstat run
/etc/snmp/vmstat-cron /var/local/snmp/vmstat &

That will launch vmstat 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.

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. Next, to get the data into snmpd add the following to the /etc/snmp/snmpd.conf file:

extend vmstat /bin/cat /var/local/snmp/vmstat

That simply picks up the contents of the 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

Import the Cacti template cacti_host_template_vmstat.xml 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.

What it looks like

vmstat cpu statistics on Cacti

vmstat io statistics on Cacti

vmstat memory statistics on Cacti

vmstat procs statistics on Cacti

vmstat swap statistics on Cacti

vmstat System cs statistics on Cacti

vmstat System in statistics on Cacti


voytek Image  2013-10-30 13:02 :: voytek

thanks, Glen

Voytek Eymont Image  2013-10-31 10:26 :: Voytek Eymont

My cs and in graph seem identical? and yours seems missing, so can"t compare.

Glen Pitt-Pladdy Image  2013-10-31 19:10 :: Glen Pitt-Pladdy

Thanks for pointing out the missing graph - fixed.

In my case "cs" and "in" are similar, which is not unexpected since they will relate to some common things like the level of activity on the system. One thing to check is the items in the stats file - I believe items 11 and 12 should be these two, and also just run vmstat yourself (300 second samples) to check the numbers stack up.

Note: Identity details will be stored in a cookie. Posts may not appear immediately