domain | ||
.gitignore | ||
.python-version | ||
LICENSE | ||
main.py | ||
Pipfile | ||
Pipfile.lock | ||
README.md | ||
sample-config.yaml |
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
-
Install pyenv
-
cd to this repo's directory and run
$ pyenv install
to get the correct version of python -
Install pyenv with
$ pip install --upgrade pip pipenv
-
Initialize the pip environment with
$ pipenv install
-
Create a yaml configuration file somewhere.
-
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