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