Home Directory Plugins Operating Systems Linux Check File and Dir Size for BASH

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

Check File and Dir Size for BASH

Rating
5 votes
Favoured:
1
Hits
169108
Files:
FileDescription
check_file_size.shcheck_file_size.sh
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
Bash shell script to check min/max size of files and/or directories. Relies on "stat" and "du", which most distributions should have. Usage: check_file_size.sh [--minwarn size] [--maxwarn size] [--mincrit size] [--maxcrit size] [-m
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/*
Reviews (1)
byfalqueb, December 13, 2020
Thanks a lot, I'm using nrpe and it works well with it