Chapter 10 Nagios Notification
1. How to configure
notification period
# vi
/etc/nagios/objects/server.cfg
define host & service {
use linux-server
host_name
server
alias
server
address 192.168.80.5
check_period 24x7
notification_period workhours
notification_interval 10 <- come from templates.cfg
}
# vi
/etc/nagios/objects/timeperiods.cfg
define timeperiod {
timeperiod_name workhours
timeperiod_name
24x7
}
# nagios –v
/etc/nagios/nagios.cfg ; # service nagios restart
2. How to configure
notification for groups
# vi
/etc/nagios/objects/contacts.cfg
define
contactgroup {
contactgroup_name nagios
alias
Network Operations
members chul,linux
}
define contact {
use
generic-contact
contact_name chul
alias
Jeong Chul
email tland@chul.com
}
define contact {
use
generic-contact
contact_name linux
alias
Power Linux
email linux@chul.com
}
# vi /etc/nagios/objects/server.cfg
define host & service {
use linux-server //templates.cfg
host_name server
address 192.168.80.5
check_period 24x7
notification_period workhours
contact_groups nagios
}
# nagios –v /etc/nagios/nagios.cfg; # service
nagios restart
3. How to specify
which states to be notified about
# vi /etc/nagios/objects/server.cfg
define
host {
use linux-server
host_name
server
address
192.168.80.5
contacts chul
notification_options d,u,r,f,s
//templates.cfg
notifications_enabled 1
}
define service {
contacts chul
notifications_enabled 1
notification_options w,u,c,r,f,s //templates.cfg
}
# vi /etc/nagios/objects/contacts.cfg
define contact {
use
generic-contact //templates.cfg
contact_name
chul
email tland@chul.com
host_notification_options d,u,r,f,s
service_notification_options w,u,c,r,f,s
}
※ d: Down, u: UNrechable, r: Recovering,
f: Flapping, s:
Scheduled
w: Warn, u:Unknown, c: Critical
# nagios –v
/etc/nagios/nagios.cfg
# service nagios restart
4. How to define a
custom notification method
a. Defining command
# vi
/etc/nagios/objects/commands.cfg
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "*****
Nagios *****\n\nNotifi cation Type:
$NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAdd ress: $HOSTADDRESS$\nInfo:
$HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" |
}
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "*****
Nagios *****\n\nNotifi cation Type:
$NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIA S$\nAddress: $HOSTADDRESS$\nState:
$SERVICESTATE$\n\nDate/Time: $LONGDATET
IME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" |
b. Defining contacts in the templates
# vi /etc/nagios/objects/templates.cfg
define contact{
name generic-contact
host_notification_commands
notify-host-by-email
service_notification_commands
notify-service-by-email
}
c. Defining host and service
# vi /etc/nagios/objects/server.cfg
define host{
use linux-server
contact_groups nagios
//contacts.cfg <- templaes.cfg
# nagios –v /etc/nagios/nagios.cfg
# service nagios restart
Chapter 11 Nagios Security & Performance
1.Requiring
authentication for the web interface
a.
Adding user
#
htpasswd /etc/nagios/htpasswd.users tland
b.
Add this user to cgi.cfg
#
vi /etc/nagios/cgi.cfg
authorized_for_read_only=tland
authorized_for_all_services=nagios,tland
authorized_for_all_hosts=nagios,tland
c. Access web interface using new user
http://localhost/nagios/
2. Using authenticated contacts
a. Creating new user
# htpasswd /etc/nagios/htppasswd.uesrs linux
http://localhost/nagios
b. Editing contact and host information
# vi /etc/nagios/objects/contacts.cfg
define contact {
use generic-contacts
contact_name linux
alias Linux Admin
email linux@chul.com
}
# vi /etc/nagios/objects/linux.cfg
define host {
host_name linux
alias linux server
address 192.168.80.5
contacts nagios,linux
}
# nagos –v /etc/nagios/nagios.cfg ; # service
nagios restart
3.
Writing debugging information to Nagios log file
a.
Editing nagios.cfg
#
vi /etc/nagios/nagios.cfg
debug_level
= -1 //everything
debug_verbosity=2 //very detailed
debug_file=/var/log/nagios/nagios.log
#
touch /var/log/nagios/nagios.log
#
chown nagios.nagios /var/log/nagios/nagios.log
b.
Service restart
#
nagios –v /etc/nagios/nagios.cfg
#
service nagios restart
#
tail –f /var/log/nagios/nagios.log
4.
Monitoring Nagios performance with Nagiostats
#
vi /etc/nagios/nagios.cfg
status_file=/var/log/nagios/status.dat
#
nagiostats –c /etc/nagios/nagios.cfg
#
nagiostats –c /etc/nagios/nagios.cfg –help
Chapter 12 How to
integrate MRTG & Nagios
1.Check
MRTG data
#
service httpd restart
#
ls –l /var/www/mrtg
http://localhost/mrtg
2.
Service definition
#
vi /etc/nagios/objects/router.cfg
# Router on MRTG
define service{
use
generic-service
host_name
router
service_description
Router Bandwidth Usage
check_command
check_local_mrtgtraf!/var/www/mrtg/192.168.80.11_1.log!A VG!1000,5000!8000,50 000!10
}
3.
Command definition
#
vi /etc/nagios/objects/commands.cfg
#
check_mrtgtraf' command definition
define
command{
command_name check_local_mrtgtraf
command_line $USER1$/check_mrtgtraf
-F $ARG1$ -a $ARG2$ -w
$ARG3$,$ARG4$ -c $ARG5$,$ARG6$
}
4.
Testing MRTG and Nagios
#
nagios –v /etc/nagios/nagios.cfg
#
service nagios restart
Summary
1.
Network Monitoring Structure
2.
How to setup Managed Devices
Linux server, Windows Server, Cisco Router
& Webserver
3.
Nagios Visualization
Nagiosgraph, NDOUtils with MySQL
4.
Nagios Notification & Security with Performance
5.
Integration with Nagios and MRTG
Very Very nice tutorial
ReplyDeleteThank you for your comment.
Deletevery kindful help and very helpful Toturial really you are very good Tutor Thank you for your helping, keep on going please. helping knowledge seeks
ReplyDeletereally i was new in this topic but now i have get some knowledge about Nagios after i have watched your Tutorials. it is better if you may direct another docs such as books, other tutorials and etc. to help me enough knowledge in this monitoring system.
again thank you Boss.
Dear Abdullahi Gure. Thank you for your comment here. If you visit knowledgepia.com, you will find these kind of docs for each videos. I will upload more data for each video on my youtube channel to knowledgepia.com. Enjoy much knowledge in this website.
DeleteHello Brother,
ReplyDeleteMy question is : How to add icon/image in front of host or services on nagios portal.
for example i have one host in nagios it is RHEL7 i want to keep icon/image of REDHAT in front of host on nagios portal so that i can recognize easily.
how to do this process through nagios configurations ?
Thank you very much in advance.
jonusjoseph@gmail.com
-Jonus Joseph