Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
Check File and Dir Size for BASH
Bash shell script to check min/max size of files and/or directories.
Relies on "stat" and "du", which most distributions would have.
Usage: check_file_size.sh [--minwarn size] [--maxwarn size] [--mincrit size] [--maxcrit size] [-m|--missingok] [-v|--verbose]
--minwarn,maxwarn,mincrit,maxcrit all take size in bytes
--missingok prevents errors from being raised if passed in files are missing
Examples:
# Warn if /tmp is above 1GB, Critical if above 2GB
sh check_file_size.sh --maxwarn 1000000000 --maxcrit 2000000000 /tmp
# Warn if any one file in /tmp is above 1GB, Critical if above 2GB
sh check_file_size.sh --maxwarn 1000000000 --maxcrit 2000000000 /tmp/*
Relies on "stat" and "du", which most distributions would have.
Usage: check_file_size.sh [--minwarn size] [--maxwarn size] [--mincrit size] [--maxcrit size] [-m|--missingok] [-v|--verbose]
--minwarn,maxwarn,mincrit,maxcrit all take size in bytes
--missingok prevents errors from being raised if passed in files are missing
Examples:
# Warn if /tmp is above 1GB, Critical if above 2GB
sh check_file_size.sh --maxwarn 1000000000 --maxcrit 2000000000 /tmp
# Warn if any one file in /tmp is above 1GB, Critical if above 2GB
sh check_file_size.sh --maxwarn 1000000000 --maxcrit 2000000000 /tmp/*
Reviews (1)
byfalqueb, December 13, 2020
Thanks a lot, I'm using nrpe and it works well with it