Emit a warning to stderr when your disk usage is too high. Great when used from cron. This is a mirror.
Go to file
2024-02-25 18:51:08 -08:00
domain Setup pyenv+pipenv, refactor code to 'domain' style, upgrade README 2024-02-25 18:46:38 -08:00
.gitignore Start tracking sample yaml files 2019-05-16 16:59:19 -07:00
.python-version Setup pyenv+pipenv, refactor code to 'domain' style, upgrade README 2024-02-25 18:46:38 -08:00
LICENSE Add license 2019-05-16 20:35:24 -07:00
main.py Setup pyenv+pipenv, refactor code to 'domain' style, upgrade README 2024-02-25 18:46:38 -08:00
Pipfile Setup pyenv+pipenv, refactor code to 'domain' style, upgrade README 2024-02-25 18:46:38 -08:00
Pipfile.lock Setup pyenv+pipenv, refactor code to 'domain' style, upgrade README 2024-02-25 18:46:38 -08:00
README.md Tweak wording of README 2024-02-25 18:51:08 -08:00
sample-config.yaml Sample yaml config file 2019-05-16 16:59:28 -07:00

Mike's Disk Usage Warn Thing

This is a simple script that will emit a warning to stderr when your disk usage surpasses a configured threshold. Makes it easy to get emails fron crontab when your disk gets too full

Requirements

  • pyenv

    • pipenv inside
  • logger program, which should be on most distributions

Installation

  1. Install pyenv

  2. cd to this repo's directory and run $ pyenv install to get the correct version of python

  3. Install pyenv with $ pip install --upgrade pip pipenv

  4. Initialize the pip environment with $ pipenv install

  5. Create a yaml configuration file somewhere.

  6. Create a crontab entry that will call this script with an argument "--config" followed by the path to your configuration file.

Command Line Arguments

This script needs command line arguments to work. Primarily, it needs to know the location of at least one valid configuration file

--config < path >

Specifies a path to a configuration file or directory. If a directory is specified, it will be scanned for configuration files.

Example Call With Arguments

cd /path/to/this/repo && pipenv run python main.py --config "/my/config/path-1" --config "/my/config/path-2"

Example Crontab Entry

As mentioned, the easiest way to use this script is with crontabs. By default, cron jobs will send you an email any time a script outputs to stdout or stderr. Since this script will output lots of information to stdout, and only output to stderr when a disk has become full, it's useful to redirect stdout to /dev/null, like so:

cd /path/to/this/repo && pipenv run python main.py --config "/path/to/config" > /dev/null

So, in order to run this script every 5 minutes, use something like the following:

*/5 * * * * cd /path/to/this/repo && pipenv run python main.py --config "/path/to/config" > /dev/null