Alert script example
UNIX® shell script sample sending alert by email.
If you have configured the
ALERT_SCRIPT
element to execute a script when the GAS
raises a monitoring alarm, the following sample script provides you with an example of how you might
send notification by email about the alarm. For this purpose, you need to have a mail server set up
on your system. Note:
The script is intended as a sample implementation for sending an email alert. You are encouraged to customize the email content for your own application needs.
#!/bin/bash
# email alert script
echo "Subject: GAS ALERT" > /usr/gas/mail.txt
echo "" >> /usr/gas/mail.txt
echo "DATE:" 'date' >> /usr/gas/mail.txt
echo "ERROR="$1 >> /usr/gas/mail.txt
echo "SESSION="$2 >> /usr/gas/mail.txt
echo "." >> /usr/gas/mail.txt
sendmail -v admin@4js.com < /usr/gas/mail.txt
The arguments passed in contain
information about the actual event:$1
is the event triggered, likeREAL_REQUEST_TIME
.$2
is the session number that triggered the alarm event.
Sample message
This is a sample message sent by the script:
Subject: GAS ALERT DATE: Thu Apr 9 14:58:15 CEST 2020 ERROR=REAL_REQUEST_TIME SESSION=1908f2708ffc685154bc7750ec84dd81