Guys,
I managed to make a script that is working fine so far.
As some expected i was having problems with any updates that can occur to the alert after we acknowledge it.
I succeeded to create a script that allowed me to insert a Status, TroubleTicketID and send e-mails only after i Acknowledged the alert, which was nice, but Spectrum considers the clear as an update to the alarm, so when the alert was cleared, as the alert was already ack'd i was also sending an e-mail.
if [ -n "$STATUS" ] && [ "$ACKD" = TRUE ]
then
SENDMAIL=True #True or False
else
SENDMAIL=False #True or False
fi
So i had to find a way to also prevent the sendmail to happen when the alert clears.
After researching a little and studying the other Set and Clear Scripts and how they work , i discovered a condition named $MODEL_CONDITION, that shows the condition of the device in the moment the script (Set, Update or Clear) is triggered.
When the %MODEL_CONDITION is "0" it means that is no alert and it's the value that comes when the clear triggers the Update Script. So i improved my script:
if [ -n "$STATUS" ] && [ "$ACKD" = TRUE ] && [ "$MODEL_CONDITION" != "0" ]
then
SENDMAIL=True #True or False
else
SENDMAIL=False #True or False
fi
And so far, it is working as Intended . The only time the UpdateScript send e-mails is when we Acknowledge the alert.