Linux

check_fs_readable

Description:

Check to see if a file system is writable.

Current Version

0.5b

Last Release Date

2012-02-29

Compatible With

  • Nagios 3.x

License

GPL


Project Files
Project Notes
######################################################################### # # 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) Add a Review
Too many comments not enough functionality
by isaaclw, May 31, 2012

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);



Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
2 (1)
Favorites
0
Views
76,778