1 | % Nagios and Request Tracker Integration |
---|
2 | % |
---|
3 | % Creating Tickets |
---|
4 | |
---|
5 | # Introduction |
---|
6 | |
---|
7 | ## Goals |
---|
8 | |
---|
9 | * Learn how to configure Nagios to raise tickets in RT |
---|
10 | |
---|
11 | ## Notes |
---|
12 | |
---|
13 | * Commands preceded with "$" imply that you should execute the command as |
---|
14 | a general user - not as root. |
---|
15 | * Commands preceded with "#" imply that you should be working as root. |
---|
16 | * Commands with more specific command lines (e.g. "RTR-GW>" or "mysql>") |
---|
17 | imply that you are executing commands on remote equipment, or within |
---|
18 | another program. |
---|
19 | |
---|
20 | # Exercises |
---|
21 | |
---|
22 | To configure RT and Nagios so that alerts from Nagios automatically |
---|
23 | create tickets requires a few steps: |
---|
24 | |
---|
25 | * Create a proper contact entry for Nagios in |
---|
26 | /etc/nagios3/conf.d/contacts_nagios2.cfg |
---|
27 | |
---|
28 | * Update either services_nagios2.cfg or an individuall host entry to use |
---|
29 | the new contact group. |
---|
30 | |
---|
31 | These next two items should already be done in RT if you have |
---|
32 | finished the RT exercises. |
---|
33 | |
---|
34 | * Install the rt-mailgate software and configure it properly |
---|
35 | in your /etc/aliases file for your MTA in use. |
---|
36 | |
---|
37 | * Configure the appropriate queues in RT to receive emails |
---|
38 | passed to it from Nagios via the rt-mailgate software. |
---|
39 | |
---|
40 | # Exercises |
---|
41 | |
---|
42 | Log in to your virtual machine as the sysadm user. |
---|
43 | |
---|
44 | |
---|
45 | # Configure a Contact in Nagios |
---|
46 | |
---|
47 | Become root on your PC: |
---|
48 | |
---|
49 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
50 | $ sudo -s |
---|
51 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
52 | |
---|
53 | |
---|
54 | Edit the file /etc/nagios3/conf.d/contacts_nagios2.cfg |
---|
55 | |
---|
56 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
57 | # editor /etc/nagios3/conf.d/contacts_nagios2.cfg |
---|
58 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
59 | |
---|
60 | In this file we will first add a new contact name under |
---|
61 | the default root contact entry. |
---|
62 | |
---|
63 | WARNING: DO NOT remove the root contact entry. |
---|
64 | |
---|
65 | REALLY - READ THIS! DO NOT remove the root contact entry. |
---|
66 | |
---|
67 | The new contact should look like this (UNDERNEATH the root contact entry): |
---|
68 | |
---|
69 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
70 | define contact{ |
---|
71 | contact_name net |
---|
72 | alias RT Alert Queue |
---|
73 | service_notification_period 24x7 |
---|
74 | host_notification_period 24x7 |
---|
75 | service_notification_options c |
---|
76 | host_notification_options d |
---|
77 | service_notification_commands notify-service-by-email |
---|
78 | host_notification_commands notify-host-by-email |
---|
79 | email net@pcX.ws.nsrc.org |
---|
80 | } |
---|
81 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
82 | |
---|
83 | |
---|
84 | Now at the end of the file add the following entry: |
---|
85 | (Note: do not delete or update other entries.) |
---|
86 | |
---|
87 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
88 | define contactgroup{ |
---|
89 | contactgroup_name tickets |
---|
90 | alias email to ticket system for RT |
---|
91 | members net,root |
---|
92 | } |
---|
93 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
94 | |
---|
95 | |
---|
96 | Save and exit from the file. |
---|
97 | |
---|
98 | ## Notes |
---|
99 | |
---|
100 | - the service_notification_option of "c" means only notify once a |
---|
101 | service is considered "critical" by Nagios (i.e. down). The |
---|
102 | host_notification_option of "d" means down. By specifying only "c" |
---|
103 | and "d" this means that notifications will not be sent for other |
---|
104 | states. |
---|
105 | |
---|
106 | - Note the email address in use "net@pcX.ws.nsrc.org" - this is important |
---|
107 | as this was previously defined in the Request Tracker (RT) exercises. |
---|
108 | |
---|
109 | - You could leave off "root" as a member, but we've left this on to |
---|
110 | have another user that receives email to help us troubleshoot if |
---|
111 | there are issues. |
---|
112 | |
---|
113 | |
---|
114 | |
---|
115 | # Choose a Service to Monitor that Creates Tickets in RT |
---|
116 | |
---|
117 | To send email to generate tickets in RT if SSH goes down on a box you would edit the |
---|
118 | SSH service check: |
---|
119 | |
---|
120 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
121 | # editor /etc/nagios3/conf.d/services_nagios2.cfg |
---|
122 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
123 | |
---|
124 | Find the service with the hostgroup_name of "ssh-servers" and add the "contact_groups" |
---|
125 | entry at the end of the definition. When you are done your definition should look like this: |
---|
126 | |
---|
127 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
128 | define service { |
---|
129 | hostgroup_name ssh-servers |
---|
130 | service_description SSH |
---|
131 | check_command check_ssh |
---|
132 | use generic-service |
---|
133 | notification_interval 0 ; set > 0 if you want to be renotified |
---|
134 | contact_groups tickets,admins |
---|
135 | } |
---|
136 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
137 | |
---|
138 | |
---|
139 | Save and exit from the file. |
---|
140 | |
---|
141 | ## Notes |
---|
142 | |
---|
143 | - Note the additional item that we now have, "contact_groups." You can do this for other |
---|
144 | entries as well if you wish. |
---|
145 | |
---|
146 | - We, also, included the default contact group of admins. You could leave this off if you |
---|
147 | wish. |
---|
148 | |
---|
149 | # Include noc in as members of ssh-server |
---|
150 | |
---|
151 | |
---|
152 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
153 | # editor /etc/nagios3/conf.d/hostgroups_nagios2.cfg |
---|
154 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
155 | |
---|
156 | Find the group with the hostgroup_name of "ssh-servers" and noc to the "members" |
---|
157 | entry at the end of the definition. When you are done your definition should look like this: |
---|
158 | |
---|
159 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
160 | # A list of your ssh-accessible servers |
---|
161 | define hostgroup { |
---|
162 | hostgroup_name ssh-servers |
---|
163 | alias SSH servers |
---|
164 | members localhost,noc |
---|
165 | } |
---|
166 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
167 | |
---|
168 | |
---|
169 | |
---|
170 | Restart Nagios to verify your changes are correct: |
---|
171 | |
---|
172 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
173 | # service nagios3 restart |
---|
174 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
175 | |
---|
176 | |
---|
177 | If SSH goes down on any of the devices you are monitoring Nagios should generate a new |
---|
178 | ticket in Request Tracker. We will stop the SSH service on the classroom NOC server. If you |
---|
179 | are not monitoring this machine, then you will need to add an entry for NOC in your Nagios |
---|
180 | configuration and add it to the ssh hostgroup defined in the file hostgroups_nagios2.cfg. |
---|
181 | |
---|
182 | |
---|
183 | # See Nagios Tickets in RT |
---|
184 | |
---|
185 | - It will take a bit (up to 5 minutes) for Nagios to report that SSH is "critical". |
---|
186 | Then you must wait for a total of 4 checks before the SSH service is deemed to be |
---|
187 | down "hard". At that point Nagios will send an email to net@pcX.ws.nsrc.org and a ticket |
---|
188 | will be created in RT. |
---|
189 | |
---|
190 | - Remember to see this go to http://pcX.ws.nsrc.org/rt/ and log in as Username "sysadm" |
---|
191 | with the password you chose when you created the RT sysadm account. The new |
---|
192 | ticket should appear in the "10 newest unowned tickets" box in the main login |
---|
193 | page in RT. |
---|