Agenda: dns-nagios-exercises.txt

File dns-nagios-exercises.txt, 6.4 KB (added by admin, 5 years ago)
Line 
1NAGIOS MONITORING
2-----------------
3
4On AUTH1 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
14    as working copies. The easiest is to become temporarily root, and rename
15        the files:
16
17        $ sudo -s
18
19        You can then copy the commands below:
20
21cp cgi.cfg-sample cgi.cfg
22cp nagios.cfg-sample nagios.cfg
23cp resource.cfg-sample resource.cfg
24cp objects/commands.cfg-sample objects/commands.cfg
25cp objects/contacts.cfg-sample objects/contacts.cfg
26cp objects/localhost.cfg-sample objects/localhost.cfg
27cp objects/templates.cfg-sample objects/templates.cfg
28cp objects/timeperiods.cfg-sample objects/timeperiods.cfg
29
30        # exit
31        $
32       
333. Create monitoring configuration files for DNS Servers
34
35        While are you still in Nagios working directory, create a new file for DNS servers monitoring
36       
37        Change the following below:
38                xx:     your group number
39                yy:     group number of your slave server
40                MYTLD:  your zone name
41       
42        $ sudo vi objects/dns-servers.cfg
43       
44- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - -
45
46### Define the host server
47
48define host{
49        use                     freebsd-server
50        host_name               auth1
51        alias                   master
52        address                 10.10.xx.1
53}
54
55define host{
56        use                     freebsd-server
57        host_name               resolv
58        alias                   cache
59        address                 10.10.xx.3
60}
61
62## If you didn't configure auth2, don't list it
63
64define host{
65        use                     freebsd-server
66        host_name               auth2
67        alias                   slave
68        address                 10.10.xx.2
69}
70
71## Our secondary in another group (replace Y/yy with the group number)
72
73define host{
74        use                     freebsd-server
75        host_name               auth1.grpYY.dns.nsrc.org
76        alias                   remote-slave
77        address                 10.10.yy.2
78}
79
80### Define the group
81
82define hostgroup{
83        hostgroup_name  dns-servers
84        alias           DNS Servers
85        members         auth1,resolv
86}
87
88### Define Services
89
90define service {
91        use                             generic-service         ; Name of service template to use
92        hostgroup_name                  dns-servers
93        service_description             PING
94        check_command                   check_ping!100.0,20%!500.0,60%
95}
96
97define service {
98        use                             generic-service         ; Name of service template to use
99        hostgroup_name                  dns-servers
100        service_description             Check DNS
101        check_command                   check_dns!www.MYTLD
102}
103
104- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - -
105
1064. Add check_dns service
107
108        By default, Nagios doesn't configure check_dns service, we need to add line below into commands.cfg
109       
110        $ sudo vi objects/commands.cfg
111
112        - Place this below the check_nt service check definition:
113
114- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - -
115
116define command{
117        command_name    check_dns
118        command_line    $USER1$/check_dns -s $HOSTADDRESS$ -H $ARG1$
119}
120
121- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - -
122
1235. Enable DNS monitoring group in Nagios configuration files
124
125        Now you have DNS Server monitoring files (dns-server.cfg) created. We need to enable on nagios.cfg file for monitoring
126       
127        $ sudo vi /usr/local/etc/nagios/nagios.cfg
128
129        Look for the line "cfg_file=/usr/local/etc/nagios/objects/localhost.cfg" and add below content
130       
131- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - -
132
133# Definition for DNS servers
134cfg_file=/usr/local/etc/nagios/objects/dns-servers.cfg
135
136- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - -
137
138 
1396. Enable Nagios service
140
141        To enable nagios service add the line below in /etc/rc.conf
142       
143        nagios_enable="YES"
144       
145       
1467. Start Nagios service
147
148        To start nagios service
149       
150        $ sudo service nagios start
151       
152        Nagios should be running right now without any error report.
153
154
1558. Create Apache password authentication file for Nagios
156
157        Nagios required authentication via http to gain admin access to it web interface.
158        Let's create the password file
159       
160        $ sudo -s
161        # htpasswd -c /usr/local/etc/apache22/nagios.auth nagiosadmin
162        New password:
163
164        Set your desire password (perhaps, use the class password)
165
166        # exit
167        $
168       
169       
170        Password file is now created
171       
1729. Create Nagios' Apache configuration for web interface access
173
174        Go to Apache Includes directory
175
176        $ cd /usr/local/etc/apache22/Includes
177
178        If there already is a nagios.conf file in the directory, we will
179        remove and rebuild it. Our new configuration is significantly different.
180
181        To do this do:
182
183        $ sudo rm nagios.conf
184       
185        Then edit the file:
186       
187        $ sudo vi nagios.conf
188       
189        Add the lines below into the file:
190       
191- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - -
192
193AddType application/x-httpd-php .php
194AddType application/x-httpd-php-source .phps
195
196ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/
197Alias /nagios/ /usr/local/www/nagios/
198
199<Directory "/usr/local/www/nagios/cgi-bin">
200        Options ExecCGI
201        AllowOverride None
202        Order allow,deny
203        Allow from all
204        AuthName "Nagios Access"
205        AuthType Basic
206        Require valid-user
207        AuthUserFile /usr/local/etc/apache22/nagios.auth
208</Directory>
209
210<Directory "/usr/local/www/nagios">
211        AllowOverride None
212        Order allow,deny
213        Allow from all
214        AuthName "Nagios Access"
215        AuthType Basic
216        Require valid-user
217        AuthUserFile /usr/local/etc/apache22/nagios.auth
218</Directory>
219
220- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - -
221
22210. Now, edit the main apache config.
223       
224        $ sudo vi /usr/local/etc/apache22/httpd.conf
225       
226        Find the line:
227
228DirectoryIndex index.html
229       
230        And change it to:
231       
232DirectoryIndex index.html index.php
233
234
23511. Enable and start Apache web service if required, by adding this
236        to /etc/rc.conf
237
238        $ sudo vi /etc/rc.conf
239
240apache22_enable="YES"
241
242        (Save file and exit)
243
244        $ sudo service apache22 restart
245       
24612.     Access to Nagios web page via http://10.10.xxx.1/nagios/
247
248        You will need to user "nagiosadmin" as the user and the password you
249        specified previously using the htpasswd command.
250
251        Take a looking around the Nagios interface to see what is being
252        reported.
253