| 1 | Registry Operations Curriculum |
|---|
| 2 | Nagios and Request Tracker Ticket Creation |
|---|
| 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 | * Create the proper command in Nagios to use the rt-mailgate |
|---|
| 23 | interface. The command is defined in /etc/nagios3/commands.cfg |
|---|
| 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 PC or open a terminal window as the sysadmin user. |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | 1.) Configure a Contact in Nagios |
|---|
| 41 | --------------------------------- |
|---|
| 42 | |
|---|
| 43 | - Edit the file /etc/nagios3/conf.d/contacts_nagios2.cfg |
|---|
| 44 | |
|---|
| 45 | # vi /etc/nagios3/conf.d/contacts_nagios2.cfg |
|---|
| 46 | |
|---|
| 47 | - In this file we will first add a new contact name under |
|---|
| 48 | the default root contact entry. The new contact should |
|---|
| 49 | look like this: |
|---|
| 50 | |
|---|
| 51 | define contact{ |
|---|
| 52 | contact_name net |
|---|
| 53 | alias RT Alert Queue |
|---|
| 54 | service_notification_period 24x7 |
|---|
| 55 | host_notification_period 24x7 |
|---|
| 56 | service_notification_options c |
|---|
| 57 | host_notification_options d |
|---|
| 58 | service_notification_commands notify-service-ticket-by-email |
|---|
| 59 | host_notification_commands notify-host-ticket-by-email |
|---|
| 60 | email net@localhost |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | - the service_notification_option of "c" means only notify once a |
|---|
| 65 | service is considered "critical" by Nagios (i.e. down). The |
|---|
| 66 | host_notification_option of "d" means down. By specify only "c" |
|---|
| 67 | and "d" this means that notifications will not be sent for other |
|---|
| 68 | states. |
|---|
| 69 | |
|---|
| 70 | - Note the email address in use "net@localhost" - this is important |
|---|
| 71 | as this was previously defined for RT. |
|---|
| 72 | |
|---|
| 73 | - Now we must create a Contact Group that contains this contact. |
|---|
| 74 | We will call this group "tickets." Do this at the end of the file: |
|---|
| 75 | |
|---|
| 76 | define contactgroup{ |
|---|
| 77 | contactgroup_name tickets |
|---|
| 78 | alias email to ticket system for RT |
|---|
| 79 | members net,root |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | - You could leave off "root" as a member, but we've left this on to |
|---|
| 83 | have another user that receives email to help us troubleshoot if |
|---|
| 84 | there are issues. |
|---|
| 85 | |
|---|
| 86 | - Now that your contact have been created you need to create the commands |
|---|
| 87 | that were referenced in the initial contact creation above, these are |
|---|
| 88 | "notify-service-ticket-by-email" and "notify-host-ticket-by-email" |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | 2.) Update Nagios Commands |
|---|
| 92 | -------------------------- |
|---|
| 93 | |
|---|
| 94 | - To create the notify-service-ticket-by-email and notify-host-ticket-by-email |
|---|
| 95 | commands we need to edit the file /etc/nagios3/commands.cfg. |
|---|
| 96 | |
|---|
| 97 | # vi /etc/nagios3/commands.cfg |
|---|
| 98 | |
|---|
| 99 | - In this file you already have two command definitions that we are using. These are |
|---|
| 100 | called notify-host-by-email and notify-service-by-email. We are going to add two |
|---|
| 101 | new commands. |
|---|
| 102 | |
|---|
| 103 | - We _strongly_ suggest that you COPY and PASTE the text below. It is almost impossible |
|---|
| 104 | to type it without errors. |
|---|
| 105 | |
|---|
| 106 | - Put these two new entries below the current notify-host-by-email and notify-service-by-email |
|---|
| 107 | command entries. Do not remove the old one. |
|---|
| 108 | |
|---|
| 109 | - NOTE: The "commands below do not contain breaks. They are a single line. Be aware of this as |
|---|
| 110 | COPY and PASTE between some editors and environments may insert line breaks. |
|---|
| 111 | |
|---|
| 112 | ################################################################ |
|---|
| 113 | # Additional commands created for network management workshop # |
|---|
| 114 | ################################################################ |
|---|
| 115 | |
|---|
| 116 | # 'notifiy-host-ticket-by-email' command definition |
|---|
| 117 | define command{ |
|---|
| 118 | command_name notify-host-ticket-by-email |
|---|
| 119 | command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | # 'notify-service-ticket-by-email' command definition |
|---|
| 123 | define command{ |
|---|
| 124 | command_name notify-service-ticket-by-email |
|---|
| 125 | command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | 3.) Choose a Service to Monitor with RT Tickets |
|---|
| 130 | ----------------------------------------------- |
|---|
| 131 | |
|---|
| 132 | - The final step is to tell Nagios that you wish to notify the contact "tickets" for a |
|---|
| 133 | particular service. If you look in /etc/nagios3/conf.d/generic-service_nagios2.cfg the |
|---|
| 134 | default contact_groups is "admins". To override this for a service edit the file |
|---|
| 135 | /etc/nagios3/conf.d/services_nagios2.cfg and a contact_groups entry for one of the |
|---|
| 136 | service definitions. |
|---|
| 137 | |
|---|
| 138 | - To o send email to generate tickets in RT if SSH goes down on a box you would edit the |
|---|
| 139 | SSH service check so that it looks like this: |
|---|
| 140 | |
|---|
| 141 | # check that ssh services are running |
|---|
| 142 | define service { |
|---|
| 143 | hostgroup_name ssh-servers |
|---|
| 144 | service_description SSH |
|---|
| 145 | check_command check_ssh |
|---|
| 146 | use generic-service |
|---|
| 147 | notification_interval 0 ; set > 0 if you want to be renotified |
|---|
| 148 | contact_groups tickets |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | Note the additional item that we now have, "contact_groups." You can do this for other |
|---|
| 152 | entries as well if you wish. |
|---|
| 153 | |
|---|
| 154 | - When you are done, save the file and exit. |
|---|
| 155 | |
|---|
| 156 | - Now restart Nagios to verify your changes are correct. |
|---|
| 157 | |
|---|
| 158 | # /etc/init.d/nagios3 stop |
|---|
| 159 | # /etc/init.d/nagios3 start |
|---|
| 160 | |
|---|
| 161 | |
|---|
| 162 | 4.) Generate RT Tickets for Hosts |
|---|
| 163 | --------------------------------- |
|---|
| 164 | |
|---|
| 165 | - To do this you must either specify "contact_groups tickets" for individual host |
|---|
| 166 | definitions, or you must update the template file for all hosts and change the |
|---|
| 167 | default contact_groups entry to tickets. This file is generic-host_nagios2.cfg. |
|---|
| 168 | |
|---|
| 169 | - If you wish to do this go ahead. Tickets will be generated if a host goes down |
|---|
| 170 | and you have specified the contact_groups for that host as being "tickets" |
|---|
| 171 | |
|---|
| 172 | 5. See Nagios Tickets in RT |
|---|
| 173 | --------------------------- |
|---|
| 174 | |
|---|
| 175 | - To verify your changes have worked you will need to stop the ssh service on your |
|---|
| 176 | machine or another machine. |
|---|
| 177 | |
|---|
| 178 | # /etc/init.d/ssh stop |
|---|
| 179 | |
|---|
| 180 | - It will take a while (up to 10 minutes) for Nagios to report that SSH is |
|---|
| 181 | "critical", but once that happens a new ticket should appear in your RT instance |
|---|
| 182 | in the net queue generated by Nagios. |
|---|
| 183 | |
|---|
| 184 | - Remember to see this go to http://MyMAchine/rt/ and log in as Username "sysadmin" |
|---|
| 185 | with the password you chose when you created the RT sysadmin account. The new |
|---|
| 186 | ticket should appear in the "10 newest unowned tickets" box in the main log in |
|---|
| 187 | page in RT. |
|---|