I had to deal with a similar issue a few times ago.
The fact is that
monit is not able to do this, as far as i know.
monit you can deal with
X times and/or
Y cycles directives, but more or less quickly the
exec action will be triggered more than once, depending on time you spend to fix the issue.
So, finally, i've decided to write my own check script to handle all the logic, based on flags.
I'm going to share this with you, then you take or not, it's up to you.
First : Write the script to monitor FS usage, let's say
spaceused=$(df -h | grep "$myFS" | tr -s " " | cut -d" " -f5 | cut -d"%" -f1)
if [ $spaceused -gt $myTreshold ]; then
if [ ! -f $flagFile ]; then
if [ $spaceused -le $myTreshold ]; then
rm -f $flagFile
Here i assume you can understand the script. If not, tell me, i will explain it.
Second : Setup your
monit service definition :
check program check_fs with path "/root/check_fsspace.sh"
if status != 0 then exec "/usr/bin/logger -p daemon.crit 'MAJOR: space test'"