Nagios Notificatin by mail
Posted: Wed Aug 29, 2018 9:51 am
Hi Nagios,
I have an issue by my mail notification. I do get any mails at the moment still it has worked. I use Nagios Core vers. 4.2.3 on an Linux Ubuntu 14.04. LTS.
I get this from Nagios log when shut down a Server: =>
[1535542909] HOST ALERT: W2012_Tmp;DOWN;SOFT;2;CRITICAL - Host Unreachable (172.31.1.82)
[1535542972] HOST ALERT: W2012_Tmp;DOWN;SOFT;3;CRITICAL - Host Unreachable (172.31.1.82)
[1535543035] HOST ALERT: W2012_Tmp;DOWN;SOFT;4;CRITICAL - Host Unreachable (172.31.1.82)
[1535543098] HOST ALERT: W2012_Tmp;DOWN;SOFT;5;CRITICAL - Host Unreachable (172.31.1.82)
[1535543161] HOST ALERT: W2012_Tmp;DOWN;SOFT;6;CRITICAL - Host Unreachable (172.31.1.82)
[1535543224] HOST ALERT: W2012_Tmp;DOWN;SOFT;7;CRITICAL - Host Unreachable (172.31.1.82)
[1535543287] HOST ALERT: W2012_Tmp;DOWN;SOFT;8;CRITICAL - Host Unreachable (172.31.1.82)
[1535543350] HOST ALERT: W2012_Tmp;DOWN;SOFT;9;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST ALERT: W2012_Tmp;DOWN;HARD;10;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: mpn;W2012_Tmp;DOWN;notify-host-by-email;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: mpn;W2012_Tmp;DOWN;notify-host-by-sms;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: stn;W2012_Tmp;DOWN;notify-host-by-email;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: stn;W2012_Tmp;DOWN;notify-host-by-sms;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: mnl;W2012_Tmp;DOWN;notify-host-by-email;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: mnl;W2012_Tmp;DOWN;notify-host-by-sms;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: jj;W2012_Tmp;DOWN;notify-host-by-email;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: jj;W2012_Tmp;DOWN;notify-host-by-sms;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: pmk;W2012_Tmp;DOWN;notify-host-by-email;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: pmk;W2012_Tmp;DOWN;notify-host-by-sms;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] wproc: NOTIFY job 82 from worker Core Worker 4159 is a non-check helper but exited with return code 255
[1535543413] wproc: host=W2012_Tmp; service=(none); contact=stn
[1535543413] wproc: early_timeout=0; exited_ok=1; wait_status=65280; error_code=0;
[1535543413] wproc: stderr line 01: ERROR: No message given as ARGV[1] at /usr/local/bin/sendsms.pl line 27.
Her is my Contacts and Commands: =>
###############################################################################
# CONTACTS.CFG - SAMPLE CONTACT/CONTACTGROUP DEFINITIONS
#
#
# NOTES: This config file provides you with some example contact and contact
# group definitions that you can reference in host and service
# definitions.
#
# You don't need to keep these definitions in a separate file from your
# other object definitions. This has been done just to make things
# easier to understand.
#
###############################################################################
###############################################################################
###############################################################################
#
# CONTACTS SMS NOTIFICATIONS
#
###############################################################################
###############################################################################
# Just one contact defined by default - the Nagios admin (that's you)
# This contact definition inherits a lot of default values from the 'generic-contact'
# template which is defined elsewhere.
define contact{
contact_name xxx ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Mxxxxx Pxxxxx ; Full name of
pager 05xxxxxx
email [email protected]
host_notification_period 24x7
host_notification_options d,u,r
host_notification_commands notify-host-by-sms,notify-host-by-email
}
define contact{
contact_name xxx ; Short name of user
use generic-contact ; Iherit degault valuses from generic-contact template (defined above)
alias
pager Mxxxxx Nxxxxxx ; Full name of
email [email protected]
host_notification_period 24x7
host_notification_options d,u,r
host_notification_commands notify-host-by-sms,notify-host-by-email
}
define contact{
contact_name xxx ; Short name of user
use generic-contact ; Iherit degault valuses from generic-contact template (defined above)
alias Pxxxx Kxxxx ; Full name of
pager 0045xxxxxx
email [email protected]
host_notification_period 24x7
host_notification_options d,u,r
host_notification_commands notify-host-by-sms,notify-host-by-email
}
define contact{
contact_name xxx ; Short name of user
use generic-contact ; Iherit degault valuses from generic-contact template (defined above)
alias Sxxxx Nxxxxx ; Full name of
pager
email [email protected]
host_notification_period 24x7
host_notification_options d,u,r
host_notification_commands notify-host-by-sms,notify-host-by-email
}
define contact{
contact_name xx ; Short name of user
use generic-contact ; Iherit degault valuses from generic-contact template (defined above)
alias Jxx Jxxxxxx ; Full name of
pager 0045xxxxxx
email [email protected]
host_notification_period 24x7
host_notification_options d,u,r
host_notification_commands notify-host-by-sms,notify-host-by-email
}
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
###############################################################################
# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members xxx, xxx, xxx, xx, xxx
}
###############################################################################
# COMMANDS.CFG - SAMPLE COMMAND DEFINITIONS FOR NAGIOS 4.3.2
#
#
# NOTES: This config file provides you with some example command definitions
# that you can reference in host, service, and contact definitions.
#
# You don't need to keep commands in a separate file from your other
# object definitions. This has been done just to make things easier to
# understand.
#
###############################################################################
################################################################################
#
# SAMPLE NOTIFICATION COMMANDS
#
# These are some example notification commands. They may or may not work on
# your system without modification. As an example, some systems will require
# you to use "/usr/bin/mailx" instead of "/usr/bin/mail" in the commands below.
#
################################################################################
# '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" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /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" | usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
# Braintower 'notify-host-by-sms' command definition
define command{
command_name notify-host-by-sms
command_line /usr/local/bin/sendsms.pl $CONTACTPAGER$ "Nagios: $NOTIFICATIONTYPE$ - Host $HOSTALIAS$ is $HOSTSTATE$ since $SHORTDATETIME$ info: $HOSTOUTPUT$"
}
# Braintower 'notify-service-by-sms' command definition
If I use "wich mail" I do get this => nguser@Nagios:~$ which mail
/usr/bin/mail
1: Could anybody tell me how I'm able to check why it doesn't work ?
2: Is there anybody who could tell me if I missing something in my contacts or commands definitions
3: My send sms do work it is only my mail notification which is not working
As I wrote it did work and I did get the mail notifications from the mail users at Nagios in my Inbox Outlook
Best Regards
Michael Pierre Nielsen
I have an issue by my mail notification. I do get any mails at the moment still it has worked. I use Nagios Core vers. 4.2.3 on an Linux Ubuntu 14.04. LTS.
I get this from Nagios log when shut down a Server: =>
[1535542909] HOST ALERT: W2012_Tmp;DOWN;SOFT;2;CRITICAL - Host Unreachable (172.31.1.82)
[1535542972] HOST ALERT: W2012_Tmp;DOWN;SOFT;3;CRITICAL - Host Unreachable (172.31.1.82)
[1535543035] HOST ALERT: W2012_Tmp;DOWN;SOFT;4;CRITICAL - Host Unreachable (172.31.1.82)
[1535543098] HOST ALERT: W2012_Tmp;DOWN;SOFT;5;CRITICAL - Host Unreachable (172.31.1.82)
[1535543161] HOST ALERT: W2012_Tmp;DOWN;SOFT;6;CRITICAL - Host Unreachable (172.31.1.82)
[1535543224] HOST ALERT: W2012_Tmp;DOWN;SOFT;7;CRITICAL - Host Unreachable (172.31.1.82)
[1535543287] HOST ALERT: W2012_Tmp;DOWN;SOFT;8;CRITICAL - Host Unreachable (172.31.1.82)
[1535543350] HOST ALERT: W2012_Tmp;DOWN;SOFT;9;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST ALERT: W2012_Tmp;DOWN;HARD;10;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: mpn;W2012_Tmp;DOWN;notify-host-by-email;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: mpn;W2012_Tmp;DOWN;notify-host-by-sms;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: stn;W2012_Tmp;DOWN;notify-host-by-email;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: stn;W2012_Tmp;DOWN;notify-host-by-sms;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: mnl;W2012_Tmp;DOWN;notify-host-by-email;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: mnl;W2012_Tmp;DOWN;notify-host-by-sms;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: jj;W2012_Tmp;DOWN;notify-host-by-email;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: jj;W2012_Tmp;DOWN;notify-host-by-sms;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: pmk;W2012_Tmp;DOWN;notify-host-by-email;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] HOST NOTIFICATION: pmk;W2012_Tmp;DOWN;notify-host-by-sms;CRITICAL - Host Unreachable (172.31.1.82)
[1535543413] wproc: NOTIFY job 82 from worker Core Worker 4159 is a non-check helper but exited with return code 255
[1535543413] wproc: host=W2012_Tmp; service=(none); contact=stn
[1535543413] wproc: early_timeout=0; exited_ok=1; wait_status=65280; error_code=0;
[1535543413] wproc: stderr line 01: ERROR: No message given as ARGV[1] at /usr/local/bin/sendsms.pl line 27.
Her is my Contacts and Commands: =>
###############################################################################
# CONTACTS.CFG - SAMPLE CONTACT/CONTACTGROUP DEFINITIONS
#
#
# NOTES: This config file provides you with some example contact and contact
# group definitions that you can reference in host and service
# definitions.
#
# You don't need to keep these definitions in a separate file from your
# other object definitions. This has been done just to make things
# easier to understand.
#
###############################################################################
###############################################################################
###############################################################################
#
# CONTACTS SMS NOTIFICATIONS
#
###############################################################################
###############################################################################
# Just one contact defined by default - the Nagios admin (that's you)
# This contact definition inherits a lot of default values from the 'generic-contact'
# template which is defined elsewhere.
define contact{
contact_name xxx ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Mxxxxx Pxxxxx ; Full name of
pager 05xxxxxx
email [email protected]
host_notification_period 24x7
host_notification_options d,u,r
host_notification_commands notify-host-by-sms,notify-host-by-email
}
define contact{
contact_name xxx ; Short name of user
use generic-contact ; Iherit degault valuses from generic-contact template (defined above)
alias
pager Mxxxxx Nxxxxxx ; Full name of
email [email protected]
host_notification_period 24x7
host_notification_options d,u,r
host_notification_commands notify-host-by-sms,notify-host-by-email
}
define contact{
contact_name xxx ; Short name of user
use generic-contact ; Iherit degault valuses from generic-contact template (defined above)
alias Pxxxx Kxxxx ; Full name of
pager 0045xxxxxx
email [email protected]
host_notification_period 24x7
host_notification_options d,u,r
host_notification_commands notify-host-by-sms,notify-host-by-email
}
define contact{
contact_name xxx ; Short name of user
use generic-contact ; Iherit degault valuses from generic-contact template (defined above)
alias Sxxxx Nxxxxx ; Full name of
pager
email [email protected]
host_notification_period 24x7
host_notification_options d,u,r
host_notification_commands notify-host-by-sms,notify-host-by-email
}
define contact{
contact_name xx ; Short name of user
use generic-contact ; Iherit degault valuses from generic-contact template (defined above)
alias Jxx Jxxxxxx ; Full name of
pager 0045xxxxxx
email [email protected]
host_notification_period 24x7
host_notification_options d,u,r
host_notification_commands notify-host-by-sms,notify-host-by-email
}
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
###############################################################################
# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members xxx, xxx, xxx, xx, xxx
}
###############################################################################
# COMMANDS.CFG - SAMPLE COMMAND DEFINITIONS FOR NAGIOS 4.3.2
#
#
# NOTES: This config file provides you with some example command definitions
# that you can reference in host, service, and contact definitions.
#
# You don't need to keep commands in a separate file from your other
# object definitions. This has been done just to make things easier to
# understand.
#
###############################################################################
################################################################################
#
# SAMPLE NOTIFICATION COMMANDS
#
# These are some example notification commands. They may or may not work on
# your system without modification. As an example, some systems will require
# you to use "/usr/bin/mailx" instead of "/usr/bin/mail" in the commands below.
#
################################################################################
# '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" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /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" | usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
# Braintower 'notify-host-by-sms' command definition
define command{
command_name notify-host-by-sms
command_line /usr/local/bin/sendsms.pl $CONTACTPAGER$ "Nagios: $NOTIFICATIONTYPE$ - Host $HOSTALIAS$ is $HOSTSTATE$ since $SHORTDATETIME$ info: $HOSTOUTPUT$"
}
# Braintower 'notify-service-by-sms' command definition
If I use "wich mail" I do get this => nguser@Nagios:~$ which mail
/usr/bin/mail
1: Could anybody tell me how I'm able to check why it doesn't work ?
2: Is there anybody who could tell me if I missing something in my contacts or commands definitions
3: My send sms do work it is only my mail notification which is not working
As I wrote it did work and I did get the mail notifications from the mail users at Nagios in my Inbox Outlook
Best Regards
Michael Pierre Nielsen