Hello Experts,
I need to do some customization in email alerts which I get from Nagios. For example, I dont need hostname and IP address mentioned in the email as it is not secure.
Last 2 octets of IP addresses will do but not the whole IP address.
Email is sent by nagios@hostname. I want some other email id to send an email from Nagios.
Is this possible anyways.
Below is the example content of the email:
***** Nagios *****
Notification Type: PROBLEM
Service: MySQL Replication 5951
Host: localhost
Address: 192.168.0.1
State: CRITICAL
Date/Time: Tue Jul 7 14:50:18 CDT 2015
Additional Info:
CRIT Slave_IO_Running: No Slave_SQL_Running: No Last_Error:
--------------------------------------------------------------------------------------------------------------------------------------
Instead of Address I need just X.X.0.1 or the last 2 octets will also do. and email should be sent by any other email id. Please suggest any ideas.
Need customization in email
-
jdalrymple
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Need customization in email
This is the default service notification command:
You can just omit $HOSTALIAS$
You can run a cut on $HOSTADDRESS$ - something like `cut -d '.' -f 3-`
You can add -r to your mail command for the from address
Result:
cutting $HOSTADDRESS$ may not work if you use DNS names at all... YMMV
Code: Select all
/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$You can run a cut on $HOSTADDRESS$ - something like `cut -d '.' -f 3-`
You can add -r to your mail command for the from address
Result:
Code: Select all
/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nAddress: `echo $HOSTADDRESS$ | cut -d '.' -f 3-`\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -r [email protected] $CONTACTEMAIL$-
yunushaikh
- Posts: 176
- Joined: Sat Jun 20, 2015 9:04 pm
Re: Need customization in email
I will check and let you know sir
Thanks for you quick help
Thanks for you quick help
Re: Need customization in email
Great, let us know how it works for you.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
-
yunushaikh
- Posts: 176
- Joined: Sat Jun 20, 2015 9:04 pm
Re: Need customization in email
Hello Sir this is working.
Thanks for your great help.
Thanks for your great help.