Pages

Check free disk space with nagios + SNMP

Nagios is very useful tool for watching over your servers health. There is however many sysadmins which uses it in very awkward way. They tend to write their own little and buggy scripts instead of using standard set of tools. This short post should show you how to make nagios use standard SNMP plugin to check occupied space on all disks.


Doing it this way is really simple as there is only need to change one line on each watched server. And it ensures that if you add another HDD to any of your servers you don't have to change anything. Nagios will start monitoring newly added hard-drive automatically.

Nagios configuration
First we need to install corresponding nagios plugin:
apt-get install nagios-snmp-plugins

Edit /etc/nagios3/services.cfg:
define service {
  use                  generic-service
  hostgroup_name       all_servers
  service_description  Disk free
  check_command        check_snmp_storage_v2!/!95!97!-G!public
}

Values for check_command directive:
check_snmp_storage_v2
Command to use. This command definition is in /etc/nagios-plugins/config/snmp_storage.cfg
/
We want to check all disks
95
Warning is triggered when disk is filled up more than 95%
97
Critical is triggered when disk is filled up more than 97%
-G
Any additional parameters passed to /usr/lib/nagios/plugins/check_snmp_storage.pl. In our example -G means that we want output in Gigabytes.
public
Community name

Official man for check_snmp_storage.pl is very useful if you want to use this plugin.

Client configuration
The only thing you need to do on your client (watched) machines is to edit /etc/snmp/snmpd.conf to include following line:

includeAllDisks

1 comment:

  1. i spent almost 2 days looking for this! thanks for sharing!

    ReplyDelete