How do we do using thresholds?
Main Topics
Browse All TopicsLooking for simple pre-built Nagios plugin(s) for linux os that will count files and subfolders.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
#!/bin/sh
# Nagios return codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
# Plugin parameters value if not define
WARNING_THRESHOLD=${WARNIN
CRITICAL_THRESHOLD=${CRITI
# Parse parameters
while [ $# -gt 0 ]; do
case "$1" in
-w | --warning)
shift
WARNING_THRESHOLD=$1
;;
-c | --critical)
shift
CRITICAL_THRESHOLD=$1
;;
-d | --directory)
shift
TOP_DIRECTORY=$1
;;
*) echo "Unknown argument: $1"
exit $STATE_UNKNOWN
;;
esac
FILE_COUNT=`find $TOP_DIRECTORY | wc -l`
# Are we in a critical state?
if [ ${FILE_COUNT} -ge ${CRITICAL_THRESHOLD} ];
then
echo "CRITICAL: too many files, $FILE_COUNT, in $TOP_DIRECTORY"
exit $STATE_CRITICAL
fi
# Are we in a critical state?
if [ ${FILE_COUNT} -ge ${WARNING_THRESHOLD} ];
then
echo "WARNING: There are $FILE_COUNT ( > $WARNING_THRESHOLD) files in $TOP_DIRECTORY"
exit $STATE_WARNING
fi
echo "File count OK: There are $FILE_COUNT files in $TOP_DIRECTORY"
exit $STATE_OK
in command.cfg
define command {
command_name check_file_count # the plugin name above, you can name it any
command_line $USER1$/check_file_count -H $HOSTADDRESS -c $ARG1$ -w $ARG2$ -d $ARG3$
}
Then use in your service configuation called this command as following
define service {
name file-count-cehck
service_description CHECK_FILE_COUNT
check_command check_file_count!1500!1000
}
Business Accounts
Answer for Membership
by: TintinPosted on 2009-09-27 at 22:40:03ID: 25436891
There's no pre-built plugin (that I know of),
Do you want it to count files and dirs in the whole system? If so, you'll have timeout issues as it will take quite a while to do that?
Do you want to use thresholds?