[Nagiosplug-help] stale NFS handles detection

Andreas Ericsson ae at op5.se
Fri Feb 1 10:44:08 CET 2008


Katherine Sauceda wrote:
> An ls of the mount point at the level of the NFS directory itself produces the
> stale mount error. I was thinking to write a script to check for it that way.
> 

Something like this would do the trick:

---%<---%<---
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>

int main(int argc, char **argv)
{
    struct stat st;
    if (stat(path_on_nfs, &st) < 0 && errno == ESTALE) {
        printf("CRITICAL: %s resides on a stale mount-point\n", path_on_nfs);
        return 2;
    }

    printf("OK: NFS is happily serving %s\n", path_on_nfs);
    return 0;
}

---%<---%<---

Fixing up the code so it's usable with Nagios is left as an exercise
to the reader.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231




More information about the Help mailing list