Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
check_fs_readable
0.5b
2012-02-29
- Nagios 3.x
GPL
76766
File | Description |
---|---|
check_fs_readable.pl | Perl script; check file system writability |
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!
#########################################################################
#
# 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.
#
########################################################################
#
# 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)
byisaaclw, May 21, 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);
#!/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);