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
169342
Files:
FileDescription
check_file_size.shcheck_file_size.sh
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!
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