Linux

check_dir_filecount.sh

Description:

Nagios plugin to check number of files in a directory. Written in bash, intended to be used on Linux systems.

Current Version

Last Release Date

June 16, 2009

Compatible With


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!
Project Files
Project Notes
Nagios plugin to check number of files in a directory. Written in bash, intended to be used on Linux systems. I've only tested with Nagios 3.0.2, but it should work with v2 as well. Usage is "check_dir_filecount.sh [directory] [warn value] [critical value]".
Reviews (1) Add a Review
error
by xoroz, April 30, 2011
Had errors running the script.
I modified it for

#!/bin/bash

# Return codes:

STATE_OK=0

STATE_WARNING=1

STATE_CRITICAL=2

STATE_UNKNOWN=3

# Arguments:

DIRECTORY=$1

WARNLEVEL=$2

CRITLEVEL=$3

# Get current file count:

FCOUNT=`ls -l $DIRECTORY |grep -v tot* |wc -l`

#echo "Total files in $DIRECTORY is $FCOUNT"

if [ $FCOUNT -lt $WARNLEVEL ]; then

echo "OK, $FCOUNT items in $DIRECTORY|files=$FCOUNT"

exitstatus=$STATE_OK

exit $exitstatus
fi
if [ $FCOUNT -gt $CRITLEVEL ]; then

echo "CRITICAL: $FCOUNT items in $DIRECTORY|files=$FCOUNT"

exitstatus=$STATE_CRITICAL

exit $exitstatus
fi
if [ $FCOUNT -gt $WARNLEVEL ]; then

echo "WARNING: $FCOUNT items in $DIRECTORY|files=$FCOUNT"

exitstatus=$STATE_WARNING

exit $exitstatus
fi


and it works fine
Helpful? Yes  No 
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.5 (2)
Favorites
0
Views
152,659