Answer the question
In order to leave comments, you need to log in
[[+content_image]]
How to check if a message has already been sent?
I check which process consumes the most memory, and I want to send the result to the mail or xmpp server, as in this case
if [[ $(ps aux | awk '{print $4}' | sort -nr | head -n 1 | sed 's/\..*//g' ) -ge 70 ]] ;\
then ps aux | awk '$4>70' | sendxmpp -s 'Memory Load > 70%' [email protected] ; \
fi
Answer the question
In order to leave comments, you need to log in
For notifications, you can create a lock file (just like a flag). This is how it should work (in the example we are talking about a service crash, but the essence is the same):
1. the first iteration went
- the service crashed
- check for the existence of a lock file
- the notification about the crash is gone, since the lock file does not exist
- the lock file is created
2
.the second iteration started
-
the service is still down
- checking for the existence of the lock file
-
the
lock file exists, so we will not send the notification again that the service has risen
- delete the lock file
4. the cycle continues
...
The lock file can be any file, I usually created an empty file.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question