I had a case where I had a pool of servers. And I wanted email notifications if any server or some of them meet the condition. The condition was if my rsync exceeds X number of files, send me a mail. The problem came in the moment when only 1 server met the condition but I received mails for all of them. It was annoying, spamming and WRONG.
The example I am going to show you does NOT include the rsync part because it is simply useless but you will see simulation with a predefined value.
pool=”s1 s2 s3″
for HOST in $pool; do
if [[ $number -eq 5 || $1 == true ]];then
echo “No mail”
echo “Test $emptyvar $HOST” | mutt -s “Test” firstname.lastname@example.org
echo “continue to actual”