arnaudsj / monit

Monit is a free open source utility for managing and monitoring, processes, files, directories and filesystems on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations. (unofficial mirror)
http://mmonit.com/monit/
Other
515 stars 63 forks source link

[Feature request] add math operators to File Content Test #29

Open eoli3n opened 2 years ago

eoli3n commented 2 years ago

From https://www.mmonit.com/monit/documentation/monit.html#FILE-CONTENT-TEST

operator is either a "=" for match or "!=" for no-match.

I would be able to use math operator to check for upgrades like

check program updates with path "/usr/bin/awk '/packages to be upgraded/ {print $NF}' /tmp/check-updates" # it prints a number
    if content > 5 then alert

I workarounded it with a awk test.

check program updates with path "/usr/bin/awk '/packages to be upgraded/ {v+=$NF}END{print v;if (v>=5) exit 1}' /tmp/check-updates"
    if status == 1 then alert