I firstly want to acknowledge the work of Mark Round and Linux iostat monitoring with Cacti. The following work was inspired and based on the ideas found in Mark’s post.
My main objective when I started looking into disk monitoring was to get some similar stats into Cacti for Linux that can be found with the Windows PerfMon utility. I found Mark’s post and didn’t quite like the way it used cron to collect its statistics, and wanted something that I could easily add to snmpd.conf without needing to change much more. I was also keen on obtaining the mount point data for each partition as looking at “cciss/c0d0p3” doesn’t mean as much to management (and sometimes to me) and hopefully “/home” does.
So I wrote a script which uses the output from “df -l”, “vmstat -d”, “iostat -dk”, “iostat -xdk” to produce the results I wanted. This script only looks at the individual partition on the disk. Some of the stats don’t work with Software RAID, and some stats are missing for some older versions of the kernel when used with a HP Hardware RAID card (this is all I have tested with). These are the results.
- sysstat package
- Tie::IxHash perl module
- Cacti (Ver 0.8.7d minimum)
- Make sure you have the requirements installed.
Tie::IxHash comes as a package on both Debian/Ubuntu and OpenSUSE and at the very least you could install it using CPAN.
Sysstat also should come prepackaged for most Linux Distros.
- Copy the “disk_stats.xml” file from the archive into the “resource/snmp_queries” folder of your Cacti installation.
- Copy the “disk_stats.pl” file to your “/usr/local/bin” directory and run “chmod +x /usr/local/bin/disk_stats.pl“.
- Edit your “snmpd.conf” file and add the following line “pass .22.214.171.124.4.1.2021.51 /usr/bin/perl /usr/local/bin/disk_stats.pl” (If that OID conflicts with another OID on your system you need to change the value used both in your snmpd.conf file and in the disk_stats.pl file. You will need to restart SNMPD after this change.
- Import the “cacti_data_query_snmp_-_disk_stats.xml” file into your Cacti installation using the “Import Templates” menu option.
You should now be able to open a device and add the “SNMP – Disk Stats” in the “Associated Data Queries” section.