How to use the Nagios check_disk plugin with autofs

hard drivenagiosnetwork-attached-storage

I've been using check_disk without problems until yesterday to check the free space in some partitions.
Now we just added a NAS service from our hosting and I could mount it without problems, and, since we have a fixed amount of space, I would like to check the free space with Nagios for not being overcharged.

The problem is sometimes when check_disk goes to check then I get "unknown" status since of course autofs don't maintain the partition mounted 100% of the time. (Nagios-users) check_disk and autofs recommends making a wrapper for the plugin, but I don't feel comfortable with that.

Any idea about a better solution?

Edit:

Well, I found a solution for this:

  1. I've compiled and installed the check_file plugin.
  2. Created a file on the NAS root: .nagioscheck.
  3. Configured Nagios to check often if this file exists, rather than check the space.

So I can check if the NAS is mounted and the free space.

SERVICE STATUS: OK file or directory /mnt/backup/.nagioscheck exists

Best Answer

Why not make a static entry in fstab instead using automount so it is always mounted?

In the GNU df manual:

This version of df cannot show the space available on unmounted file systems, because on most kinds of systems doing so requires very nonportable intimate knowledge of file system structures.

So I would guess if GNU df is not going to show the free space of a partition that is not mounted, a Nagios plugin probably won't either. But I could be wrong :-)

Maybe if you are using ext2/3 , by parsing out free blocks, block count, and block size out of tune2f you might be able to quickly write a plugin that will accomplish this:

sudo tune2fs -l /dev/sdb1
Related Topic