Agenda: nagios-exercises.txt

File nagios-exercises.txt, 5.9 KB (added by admin, 7 years ago)
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
14        as working copies:
15       
16        # cp cgi.cfg-sample cgi.cfg
17        # cp nagios.cfg-sample nagios.cfg
18        # cp resource.cfg-sample resource.cfg
19        # cp objects/commands.cfg-sample objects/commands.cfg
20        # cp objects/contacts.cfg-sample objects/contacts.cfg
21        # cp objects/localhost.cfg-sample objects/localhost.cfg
22        # cp objects/templates.cfg-sample objects/templates.cfg
23        # cp objects/timeperiods.cfg-sample objects/timeperiods.cfg
24
25       
263. Create monitoring configuration files for DNS Servers
27
28        While are you still in Nagios working directory, create a new file for DNS servers monitoring
29       
30        Change the following below:
31                xx:     your group number
32                yy:     group number of your slave server
33                MYTLD:  your zone name
34       
35        # Edit objects/dns-servers.cfg
36       
37- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - -
38
39### Define the host server
40
41define host{
42        use                     freebsd-server
43        host_name               master
44        alias                   master
45        address                 10.10.xx.1
46}
47
48define host{
49        use                     freebsd-server
50        host_name               cache
51        alias                   cache
52        address                 10.10.xx.2
53}
54
55define host{
56        use                     freebsd-server
57        host_name               slave
58        alias                   slave
59        address                 10.10.YY.1
60}
61
62### Define the group
63
64define hostgroup{
65        hostgroup_name  dns-servers
66        alias           DNS Servers
67        members         cache,master,slave
68}
69
70### Define Services
71
72define service {
73        use                             generic-service         ; Name of service template to use
74        hostgroup_name                  dns-servers
75        service_description             PING
76        check_command                   check_ping!100.0,20%!500.0,60%
77}
78
79define service {
80        use                             generic-service         ; Name of service template to use
81        hostgroup_name                  dns-servers
82        service_description             Check DNS
83        check_command                   check_dns!www.MYTLD
84}
85
86- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - -
87
884. Add check_dns service
89
90        By default, Nagios doesn't configure check_dns service, we need to add line below into commands.cfg
91       
92        # Edit objects/commands.cfg
93
94        - Place this below the check_nt service check definition:
95
96- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - -
97
98define command{
99        command_name    check_dns
100        command_line    $USER1$/check_dns -s $HOSTADDRESS$ -H $ARG1$
101}
102
103- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - -
104
1055. Enable DNS monitoring group in Nagios configuration files
106
107        Now you have DNS Server monitoring files (dns-server.cfg) created. We need to enable on nagios.cfg file for monitoring
108       
109        # Edit /usr/local/etc/nagios/nagios.cfg
110
111        Look for the line "cfg_file=/usr/local/etc/nagios/objects/localhost.cfg" and add below content
112       
113- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - -
114
115# Definition for DNS servers
116cfg_file=/usr/local/etc/nagios/objects/dns-servers.cfg
117
118- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - -
119
120 
1216. Enable Nagios service
122
123        To enable nagios service add the line below in /etc/rc.conf
124       
125        nagios_enable="YES"
126       
127       
1287. Start Nagios service
129
130        To start nagios service
131       
132        # /usr/local/etc/rc.d/nagios start
133       
134        Nagios should be running right now without any error report.
135
136
137#. Create Apache password authentication file for Nagios
138
139        Nagios required authentication via http to gain admin access to it web interface.
140        Let's create the password file
141       
142        # htpasswd -c /usr/local/etc/apache22/nagios.auth nagiosadmin
143       
144        Set your desire password (perhaps, use the class password)
145       
146        Password file is now created
147       
148#. Create Nagios' Apache configuration for web interface access
149
150        Go to Apache Include directory
151       
152        # cd /usr/local/etc/apache22/Include
153
154        There is already a nagios.conf file. We need to update this. The
155        simplest method is to remove and rebuild the file as our new
156        configuration is significantly different. To do this do:
157
158        # rm nagios.conf
159       
160        Then edit the file:
161       
162        # Edit Includes/nagios.conf
163       
164        Add the lines below into the file:
165       
166- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - -
167
168AddType application/x-httpd-php .php
169AddType application/x-httpd-php-source .phps
170
171ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/
172Alias /nagios/ /usr/local/www/nagios/
173
174<Directory "/usr/local/www/nagios/cgi-bin">
175        Options ExecCGI
176        AllowOverride None
177        Order allow,deny
178        Allow from all
179        AuthName "Nagios Access"
180        AuthType Basic
181        Require valid-user
182        AuthUserFile /usr/local/etc/apache22/nagios.auth
183</Directory>
184
185<Directory "/usr/local/www/nagios">
186        AllowOverride None
187        Order allow,deny
188        Allow from all
189        AuthName "Nagios Access"
190        AuthType Basic
191        Require valid-user
192        AuthUserFile /usr/local/etc/apache22/nagios.auth
193</Directory>
194
195- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - -
196
197        # In /usr/local/etc/apache22/httpd.conf, find the line:
198
199DirectoryIndex index.html
200       
201        And change it to:
202       
203DirectoryIndex index.html index.php
204
205        # Enable and start Apache web service
206        Add into /etc/rc.conf
207        apache22_enable="YES"
208       
209        # /usr/local/etc/rc.d/apache22 start
210       
211        Access to Nagios web page via http://10.10.xxx.1/nagios/index.php
212
213        You will need to user "nagiosadmin" as the user and the password you
214        specified previously using the "htpasswd" command.
215
216        Take a looking around the Nagios interface to see what is being
217        reported.
218