Skip to content

Instantly share code, notes, and snippets.

@tomasvitek
Last active December 15, 2015 17:48
Show Gist options
  • Save tomasvitek/5298580 to your computer and use it in GitHub Desktop.
Save tomasvitek/5298580 to your computer and use it in GitHub Desktop.
UNIX monitoring system `monit` (http://mmonit.com/monit/) can check space usage on regular filesystems, but can't on a RAID filesystem. This script is a workaround. Usage: Copy `monit_raid_size` script to `/usr/local/bin` and make it executable, set a cron entry for it to 10 minutes and check for timestamp in `monitrc` configuration file.
#!/bin/bash
# Copy this file to `/usr/local/bin` and make this file executable.
# Set a cron entry for this script for 10 minutes (see `crontab` file bellow).
# The space usage limit
readonly PERCENT=90
if [ `df -h /dev/md0 | egrep -o '([[:digit:]]{1,3})%' | egrep -o '([[:digit:]]{1,3})' ` -lt PERCENT ] then
touch /var/tmp/monit_flag_raid
fi
*/10 * * * * monit_raid_size > /dev/null 2>&1
check file raid_hdd with path /var/tmp/monit_flag_raid
if timestamp > 25 minutes then alert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment