Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_fs_readable

Current Version
0.5b
Last Release Date
2012-02-29
Compatible With
  • Nagios 3.x
License
GPL
Hits
76766
Files:
FileDescription
check_fs_readable.plPerl script; check file system writability
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
Check to see if a file system is writable.
#########################################################################
#
# File: check_fs_readable.pl
#
# Description:
# This nagios plugin is a very simple minded check to determine
# if a mounted file system is writable. This was written in reaction
# to chronic issues with my VPS provider having SAN issues that
# manifested themselves in the root file system suddenly becoming
# read only. Since the VPSes in question were all built with
# a singular file system having root go read only caused all the
# applications on the box to come to a screaching halt.
#
# This plugin is meant to be run locally on a system or from nrpe.
#
# Logic: Attempt to cwd to /tmp and attempt to open a file for writing.
# If either fail, sound the alarm.
#
# Version: 0.5
#
# Author: Peter L. Berghold
#
# License: GPL
#
# CAVEATS: optionally you can provide an alternative directory to check. Make
# certain that whatever userid nagios is running as can write to that
# directory so you do not get false positives.
#
########################################################################
Reviews (1)
It seems strange that half of the script is just comments. I replaced it with this script:


#!/usr/bin/perl -w

use strict;
use Getopt::Long;
use constant {
OK => 0,
WARNING => 1,
CRITICAL => 2,
UNKNOWN => 3
};
use constant RETCODES => qw ( OK WARNING CRITICAL UNKNOWN ) ;
use File::Temp qw/ tempfile tempdir /;

sub error {
my ($rc,$msg)=@_;
printf "%s: %s
",(RETCODES)[$rc],$msg;
exit($rc);
}

my $dir;
if($ARGV[0]){
$dir = $ARGV[0];
}else{
error(UNKNOWN,"No input, specify a directory")
}
my $tmp = File::Temp->new( DIR => $dir );

chdir $dir or error(CRITICAL,"Could not cwd to $dir");

open FOUT,"> $tmp" or error(CRITICAL,"Could to write to $dir");
close FOUT;

printf "OK: $dir is writable.
";
exit(OK);