Hi Team,
Do we have any mechanism to have email notification highlighted in different colors for critical alerts to distinguish.
Kindly help.
Regards,
Kalyani
Distinguish critical alerts and warning with colors
-
- Posts: 5
- Joined: Thu Jan 02, 2020 4:30 am
- tacolover101
- Posts: 432
- Joined: Mon Apr 10, 2017 11:55 am
Re: Distinguish critical alerts and warning with colors
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:
3. once you evaluate, and have your different logic set for the different states, add the html to each.
example:
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:
then modify your mailing command to use the variable:
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$
example:
Code: Select all
<font color="red">AUSTRALIA IS ON FIRE</font>
Code: Select all
if [ $HOSTSTATE$ = "critical" ] then
fontcolor=red
else
##placeholder for additional logic
fi
Code: Select all
<font color="$fontcolor">AUSTRALIA IS ON FIRE</font>
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
-
- Posts: 5
- Joined: Thu Jan 02, 2020 4:30 am
Re: Distinguish critical alerts and warning with colors
Hi,
Thanks for the response.
Can i get step by step document as i am new to this.
Regards,
Kalyani.V
Thanks for the response.
Can i get step by step document as i am new to this.
Regards,
Kalyani.V
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Distinguish critical alerts and warning with colors
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
The only guidance we could give as an example @tacolover101 already gave