Configuring email and SMS notifications.

Engage with the community of users including those using the open source solutions.
Includes Nagios Core, Plugins, and NCPA

Re: Configuring email and SMS notifications.

Postby dheerushops » Fri Feb 07, 2020 10:31 am

I copied them.

Is the below syntax is right ?

# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\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$
}

# 'notify-host-by-sms' command definition
define command{
command_name notify-host-by-sms
command_line /usr/local/nagios/libexec/sms_send.sh "--Nagios Host Notification-- Host: $HOSTNAME$, State: $HOSTSTATE$, Time: $LONGDATETIME$"
}




--->Can I add above entries in to commands.cfg file.
dheerushops
 
Posts: 36
Joined: Fri Dec 06, 2019 7:44 am

Re: Configuring email and SMS notifications.

Postby Box293 » Mon Feb 10, 2020 4:51 pm

If you copied them then the syntax should be fine. Add them and restart Nagios.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
Box293
Too Basu
 
Posts: 5106
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia

Re: Configuring email and SMS notifications.

Postby dheerushops » Tue Feb 11, 2020 11:42 am

I have added entries in commands.cfg file.

[root@nagiosserver objects]# tail commands.cfg
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\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$
}

# 'notify-host-by-sms' command definition
define command{
command_name notify-host-by-sms
command_line /usr/local/nagios/libexec/sms_send.sh "--Nagios Host Notification-- Host: $HOSTNAME$, State: $HOSTSTATE$, Time: $LONGDATETIME$"
}
[root@nagiosserver objects]#


Can you please tell the process to receive alerts into mail and SMS
dheerushops
 
Posts: 36
Joined: Fri Dec 06, 2019 7:44 am

Re: Configuring email and SMS notifications.

Postby scottwilkerson » Wed Feb 12, 2020 8:13 am

You would then add these commands as host_notification_commands to contacts in Nagios.

Add the contacts to the hosts you want them to get notifications for.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17979
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Configuring email and SMS notifications.

Postby dheerushops » Thu Feb 13, 2020 9:42 am

I have added host_notification_commands to contacts.cfg. But not received any email alert. Can you please check.


define contact {

contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email dhe*@gmail.com ; CHANGE THIS TO YOUR EMAIL ADDRESS ******

service_notification_period 24x7
service_notification_options w,u,c,r,f,s
service_notification_commands notify-service-by-email
host_notification_period 24x7
host_notification_options d,u,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
}
dheerushops
 
Posts: 36
Joined: Fri Dec 06, 2019 7:44 am

Re: Configuring email and SMS notifications.

Postby scottwilkerson » Thu Feb 13, 2020 9:51 am

not sure why but you have this line in the definition twice
Code: Select all
service_notification_commands notify-service-by-email


Also, do you have this contact (nagiosadmin) added as a contact for any of your hosts/services?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17979
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Configuring email and SMS notifications.

Postby dheerushops » Thu Feb 13, 2020 1:17 pm

I have edited the file.

define contact {

contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email dhe*@gmail.com ; CHANGE THIS TO YOUR EMAIL ADDRESS ******

service_notification_period 24x7
service_notification_options w,u,c,r,f,s
service_notification_commands notify-service-by-email
host_notification_period 24x7
host_notification_options d,u,r
host_notification_commands notify-host-by-email
}


And I have added contact (nagiosadmin) in hosts.
dheerushops
 
Posts: 36
Joined: Fri Dec 06, 2019 7:44 am

Re: Configuring email and SMS notifications.

Postby scottwilkerson » Fri Feb 14, 2020 2:41 pm

Do you see nagios attempting to send notification of the Notification report in the UI?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17979
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Configuring email and SMS notifications.

Postby scottwilkerson » Fri Feb 14, 2020 2:43 pm

Can you send a test message from the CLI

Code: Select all
echo "test message"/bin/mail -s "** TEST MESSAGE **" your-email@address.com
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 17979
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Configuring email and SMS notifications.

Postby dheerushops » Fri Feb 14, 2020 3:53 pm

[root@nagiosserver ~]# echo "test message"/bin/mail -s "** TEST MESSAGE **" dhe*@gmail.com
test message/bin/mail -s ** TEST MESSAGE** dhe*@gmail.com
[root@nagiosserver ~]#
dheerushops
 
Posts: 36
Joined: Fri Dec 06, 2019 7:44 am

PreviousNext

Return to Community Support

Who is online

Users browsing this forum: Majestic-12 [Bot] and 33 guests