Page 1 of 1
Distinguish critical alerts and warning with colors
Posted: Fri Jan 10, 2020 5:48 am
by kalyanivalaboju
Hi Team,
Do we have any mechanism to have email notification highlighted in different colors for critical alerts to distinguish.
Kindly help.
Regards,
Kalyani
Re: Distinguish critical alerts and warning with colors
Posted: Fri Jan 10, 2020 1:55 pm
by tacolover101
yes, but it would require you to set it up. there's a bit of work needed for this. i can provide you a skeleton to use to build it out.
1. setup a new host notification command to tell nagios to use your custom command (look at notify-host-by-email for reference)
2. rewrite the command to evaluate $HOSTSTATE$ (or $SERVICESTATE$ if a service), here is an example of what it's likely set to:
Code: Select all
/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
3. once you evaluate, and have your different logic set for the different states, add the html to each.
example:
Code: Select all
<font color="red">AUSTRALIA IS ON FIRE</font>
another option would be to evaluate a variable such as $fontcolor, and change that based on what the variable $HOSTSTATE$ equals to, then use this:
Code: Select all
if [ $HOSTSTATE$ = "critical" ] then
fontcolor=red
else
##placeholder for additional logic
fi
then modify your mailing command to use the variable:
Code: Select all
<font color="$fontcolor">AUSTRALIA IS ON FIRE</font>
Re: Distinguish critical alerts and warning with colors
Posted: Mon Jan 13, 2020 9:28 am
by scottwilkerson
Re: Distinguish critical alerts and warning with colors
Posted: Wed Jan 22, 2020 4:51 am
by kalyanivalaboju
Hi,
Thanks for the response.
Can i get step by step document as i am new to this.
Regards,
Kalyani.V
Re: Distinguish critical alerts and warning with colors
Posted: Wed Jan 22, 2020 7:45 am
by scottwilkerson
We don't have a step by step guide because yo are asking for something that isn't done out of the box.
The only guidance we could give as an example
@tacolover101 already gave