Home Directory

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

Directory

erling

Reviews(1)
Great script, but I needed a script to check if a file does not exist. On my Ubuntu server I want to check if the file /var/run/reboot-required does not exist and warn me if it does (to notify me the server needs a reboot).

To check this I just had to switch the output statements of the script, which I saved as check_file_notexists.

Hereby the altered code for check_file_notexists:

#! /bin/bash
#
# Author : Diego Martin Gardella [dgardella@gmail.com]
# Modified by Erling Ouweneel to switch OK and CRITICAL
#
# Desc : Plugin to verify if a file does not exist
#
#

PROGNAME=`basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`

. $PROGPATH/utils.sh

if [ "$1" = "" ]
then
echo -e " Use : $PROGNAME -- Ex : $PROGNAME /etc/hosts \n "
exit $STATE_UNKNOWN
fi


if [ -f $1 ]
then
echo "CRITICAL - $1 : EXISTS :: `head -3 $1`" # shows the first three lines of the file
exit $STATE_CRITICAL
else
echo "OK : $1 Does NOT exists "
exit $STATE_OK
fi