
6. Edit the
/usr/local/nagios/etc/objects/commands.cfg
file to add
$NOTIFICATIONCOMMENT$\n
after the
$SERVICEOUTPUT$\n
option in
notify-service-by-email
and in the
notify-host-by-
command definition.
# '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 $NOTIFICATIONCOMMENT$
\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/
$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
This section can also be modified to change the service which sends mail. To do so, change
/bin/mail -s
to the preferred mail service, for example
/bin/sendmail
.
7. Restart the Nagios service.
# service nagios restart
The Nagios server sends notifications during status changes to the mail addresses specified in the file. It is
important to note that:
●
By default, the system ensures three occurrences of the event before sending mail notifications.
●
By default, Nagios mail notifications are sent using the
/bin/mail
command. To change this, modify the
definition for the
notify-host-by-email
and
notify-service-by-email
commands in
the
/usr/local/nagios/etc/objects/commands.cfg
file and configure the mail server
accordingly.
4.2.3
Change the Default Log File Path and Rotation Interval
Prerequisites
This procedure requires root privileges.
About this task
Nagios log files are located at
/usr/local/nagios/var/nagios.log
by default. This procedure provides
instructions for modifying this path. In addition, this procedure provides instructions for adjusting the default log
level and the default location of archived log files.
Procedure
1. Log on to the SMW as root.
#
ssh root@machine-smw
2. Stop the Nagios service if it is running.
#
service nagios stop
System Monitoring
S3016
73