Agenda: nagios-exercises.txt

File nagios-exercises.txt, 5.7 KB (added by paulooi, 8 years ago)

Nagios

Line 
1NAGIOS MONITORING
2-----------------
3
4On Master server
5
61. Go to Nagios working directory
7
8        # cd /usr/local/etc/nagios
9       
102. Copy Nagios sample files
11
12        To do this, make sure you are in Nagios working directory from the first step
13        There are Nagios's sample files in the directory, which we need to copy them as working copy.
14       
15        # cp cgi.cfg-sample cgi.cfg
16        # cp nagios.cfg-sample nagios.cfg
17        # cp resource.cfg-sample resource.cfg
18        # cp objects/commands.cfg-sample objects/commands.cfg
19        # cp objects/contacts.cfg-sample objects/contacts.cfg
20        # cp objects/localhost.cfg-sample objects/localhost.cfg
21        # cp objects/templates.cfg-sample objects/templates.cfg
22        # cp objects/timeperiods.cfg-sample objects/timeperiods.cfg
23
24       
253. Create monitoring configuration files for DNS Servers
26
27        While are you still in Nagios working directory, create a new file for DNS servers monitoring
28       
29        ** Remember to change xxx to your group
30       
31        # Edit objects/dns-server.cfg
32       
33- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - -
34
35### Define the host server
36
37define host{
38        use                     freebsd-server
39        host_name               cache
40        alias                   cache
41        address                 10.10.xxx.2
42}
43
44define host{
45        use                     freebsd-server
46        host_name               auth
47        alias                   auth
48        address                 10.10.xxx.3
49}
50
51### Define the group
52
53define hostgroup{
54        hostgroup_name  dns-servers
55        alias           DNS Servers
56        members         cache, auth
57}
58
59### Define Services
60
61define service {
62        use                             generic-service         ; Name of service template to use
63        host_name                       cache
64        service_description             PING
65        check_command                   check_ping!100.0,20%!500.0,60%
66}
67
68define service {
69        use                             generic-service         ; Name of service template to use
70        host_name                       auth
71        service_description             PING
72        check_command                   check_ping!100.0,20%!500.0,60%
73}
74
75define service {
76        use                             generic-service         ; Name of service template to use
77        host_name                       auth
78        service_description             Check DNS
79        check_command                   check_dns!noc.ws.nsrc.org
80}
81
82define service {
83        use                             generic-service         ; Name of service template to use
84        host_name                       cache
85        service_description             Check DNS
86        check_command                   check_dns!noc.ws.nsrc.org
87}
88
89- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - -
90
914. Add check_dns service
92
93        By default, Nagios doesn't configure check_dns service, we need to add line below into commands.cfg
94       
95        # Edit objects/commands.cfg
96
97
98- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - -
99
100define command{
101        command_name    check_dns
102        command_line    $USER1$/check_dns -H $ARG1$ -s $HOSTADDRESS$
103}
104
105- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - -
106
1075. Enable DNS monitoring group in Nagios configuration files
108
109        Now you have DNS Server monitoring files (dns-server.cfg) created. We need to enable on nagios.cfg file for monitoring
110       
111        # Edit /usr/local/etc/nagios/nagios.cfg
112
113        Look for the line "cfg_file=/usr/local/etc/nagios/objects/localhost.cfg" and add below content
114       
115- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - -
116
117# Definition for DNS servers
118cfg_file=/usr/local/etc/nagios/objects/dns-servers.cfg
119
120- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - -
121
122 
1236. Enable Nagios service
124
125        To enable nagios service add the line below in /etc/rc.conf
126       
127        nagios_enable="YES"
128       
129       
1307. Start Nagios service
131
132        To start nagios service
133       
134        # /usr/local/etc/rc.d/nagios start
135       
136        Nagios should be running right now without any error report.
137
138
139#. Create Apache password authentication file for Nagios
140
141        Nagios required authentication via http to gain admin access to it web interface.
142        Let's create the password file
143       
144        # htpasswd -c /usr/local/etc/apache22/nagios.auth nagiosadmin
145       
146        Set your desire password
147       
148        Password file is now created
149       
150#. Create Nagios' Apache configuration for web interface access
151
152        Go to Apache directory
153       
154        # cd /usr/local/etc/apache22
155       
156        Create a new file
157       
158        # Edit Includes/nagios.conf
159       
160        Add the line below info the file
161       
162- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - -
163
164AddType application/x-httpd-php .php
165AddType application/x-httpd-php-source .phps
166
167ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/
168Alias /nagios/ /usr/local/www/nagios/
169
170<Directory "/usr/local/www/nagios/cgi-bin">
171        Options ExecCGI
172        AllowOverride None
173        Order allow,deny
174        Allow from all
175        AuthName "Nagios Access"
176        AuthType Basic
177        Require valid-user
178        AuthUserFile /usr/local/etc/apache22/nagios.auth
179</Directory>
180
181<Directory "/usr/local/www/nagios">
182        AllowOverride None
183        Order allow,deny
184        Allow from all
185        AuthName "Nagios Access"
186        AuthType Basic
187        Require valid-user
188        AuthUserFile /usr/local/etc/apache22/nagios.auth
189</Directory>
190
191- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - -
192
193        # In /usr/local/etc/apache22/httpd.conf, find the line:
194
195DirectoryIndex index.html
196       
197        And change it to:
198       
199DirectoryIndex index.html index.php
200
201        # Enable and start Apache web service
202        Add into /etc/rc.conf
203        apache22_enable="YES"
204       
205        # /usr/local/etc/rc.d/apache22 start
206       
207        Access to Nagios web page via http://10.10.xxx.1/nagios/index.php
208