Project

General

Profile

Installing Icinga on Debian server » History » Version 1

Jamila Khan, 08/19/2014 04:55 PM

1 1 Jamila Khan
h1. Installing Icinga on Debian server
2
3
{{>toc}}
4
5
h1. NEW WAY
6
7
h2. Install Icinga from package
8
9
<pre>
10
aptitude install icinga
11
</pre>
12
13
Say yes
14
<pre>
15
y
16
</pre>
17
18
h3. Configuring icinga-cgi
19
20
Select apache2
21
<pre>
22
Ok
23
</pre>
24
25
create icingaadmin password, enter it twice
26
27
IT'S INSTALLED!
28
29
h2. Make it right!
30
31
h3. Change the hostname in the configs
32
33
<pre>
34
cd /etc/icinga/objects
35
vim localhost_icinga.cfg
36
</pre>
37
38
change all instances of "localhost" to be a more useful name for this server, for this example, dev1
39
40
<pre>
41
:%s/localhost/dev1/g
42
:x
43
</pre>
44
45
Do the same for hostgroups_icinga.cfg
46
47
<pre>
48
vim hostgroups_icinga.cfg
49
:%s/localhost/dev1/g
50
:x
51
</pre>
52
53
restart and see how it looks!
54
55
<pre>
56
/etc/init.d/icinga restart
57
</pre>
58
59
In a browser go to serverurl/icinga and log in with the username "icingaadmin" and the password that you set earlier.
60
61
h2.  External Commands
62
63
Icinga is not configured to look for external commands in the default configuration as a security feature. To enable external commands, you need to allow the web server write access to the nagios command pipe.  the simplest way of doing this is to set check_external_commands=1 in your Icinga configuration, and then change the permissions in a way which will be maintained across package upgrades (otherwise dpkg will overwrite your permission changes).  The following is the recommended approach:
64
  
65
activate external command checks in the Icinga configuration. this can be done by setting check_external_commands=1 in the file /etc/icinga/icinga.cfg. 
66
 
67
perform the following commands to change directory permissions and to make the changes permanent:
68
69
<pre>
70
 service icinga stop
71
 dpkg-statoverride --update --add nagios www-data 2710 /var/lib/icinga/rw
72
 dpkg-statoverride --update --add nagios nagios 751 /var/lib/icinga
73
 service icinga start
74
</pre>
75
76
77
h2. Make it report in!
78
79
I've put all the files we're going to need into /home/jamila/icingafiles on palante2 to make it a bit easier.
80
81
The files are:
82
83
<pre>
84
 43957 Feb  6 20:51 send_nsca
85
  1636 Feb  6 20:52 send_nsca.cfg
86
   997 Feb  6 20:53 submit_check_result
87
   178 Feb  6 20:57 add_to_commands.cfg
88
</pre>
89
90
Copy all of those files to some one place on the new server
91
92
Move send_nsca and submit_check_result to /usr/sbin/
93
94
Move send_nsca.cfg to /etc/icinga
95
96
Add the lines in add_to_commands.cfg to the end of /etc/icinga/commands.cfg
97
98
If libmcrypt isn't installed, we need to install it.
99
100
<pre>
101
aptitude install libmcrypt4
102
</pre>
103
104
Then we need to edit /etc/icinga/icinga.cfg and make the following lines have the following values:
105
106
<pre>
107
enable_notifications=0
108
109
obsess_over_services=1
110
111
ocsp_command=submit_check_result
112
</pre>
113
114
115
Check the icinga config files to make sure we didn't break anything
116
<pre>
117
/etc/init.d/icinga checkconfig
118
</pre>
119
120
If all is well, restart!
121
<pre>
122
/etc/init.d/icinga restart
123
</pre>
124
125
I like to alter the localhost_icinga.cfg to have a different parameters for disk check:
126
127
<pre>
128
# Define a service to check the disk space of the root partition
129
# on the local machine.  Warning if < 10% free, critical if
130
# < 5% free space on partition.
131
132
define service{
133
        use                             generic-service         ; Name of service template to use
134
        host_name                       alpdebian
135
        service_description             Disk Space
136
        check_command                   check_all_disks!10%!5%
137
        }
138
139
</pre>
140
141
142
If that all works, modify the localhost_icinga.cfg to monitor what you want, and then add the host in palante2 Icinga with the correct service check names.
143
144
145
submit_check_result for this contains:
146
147
<pre>
148
#!/bin/sh
149
150
# Arguments:
151
#  $1 = host_name (Short name of host that the service is
152
#       associated with)
153
#  $2 = svc_description (Description of the service)
154
#  $3 = state_string (A string representing the status of
155
#       the given service - "OK", "WARNING", "CRITICAL"
156
#       or "UNKNOWN")
157
#  $4 = plugin_output (A text string that should be used
158
#       as the plugin output for the service checks)
159
#
160
161
# Convert the state string to the corresponding return code
162
return_code=-1
163
164
case "$3" in
165
    OK)
166
        return_code=0
167
        ;;
168
    WARNING)
169
        return_code=1
170
        ;;
171
    CRITICAL)
172
        return_code=2
173
        ;;
174
    UNKNOWN)
175
        return_code=-1
176
        ;;
177
esac
178
179
# pipe the service check info into the send_nsca program, which
180
# in turn transmits the data to the nsca daemon on the central
181
# monitoring server
182
183
/usr/bin/printf "%s\t%s\t%s\t%s\n" "$1" "$2" "$return_code" "$4" | /usr/sbin/send_nsca -H icinga.palantetech.com -c /etc/icinga/send_nsca.cfg
184
</pre>
185
186
add_to_commands.cfg contains
187
188
<pre>
189
 define command{
190
        command_name    submit_check_result
191
        command_line    /usr/sbin/submit_check_result $HOSTNAME$ '$SERVICEDESC$' $SERVICESTATE$ '$SERVICEOUTPUT$'
192
 }
193
</pre>
194
195
send_nsca is a binary file, and send_nsca.cfg is our authentication method and password.
196
197
h2. Lm-sensors
198
199
After installing Icinga, you can set up [[lm-sensors]] 
200
201
202
h1. OLD WAY
203
204
Install Icinga
205
http://docs.icinga.org/latest/en/quickstart-idoutils.html
206
207
You'll need to download Icinga and Nagios plugins to /usr/src
208
209
wget http://sourceforge.net/projects/icinga/files/icinga/1.6.1/icinga-1.6.1.tar.gz/
210
wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
211
212
Then copy the send_nsca and send_nsca.cnf from one of the other MSP servers to this server
213
 scp <Icinga server>:/usr/local/icinga/bin/send_nsca /usr/local/icinga/bin/
214
 scp <Icinga server>:/usr/local/icinga/etc/send_nsca.cfg /usr/local/icinga/etc/
215
216
217
Set up a OSCP command as detailed here:
218
http://docs.icinga.org/latest/en/distributed.html
219
220
You can copy the lines in icinga/etc/objects/command.cfg, and the submit_check_result script in icinga/libexec from another MSP server.
221
222
223
224
old docs here: 
225
https://hq.palantetech.com/issues/1582
226
https://hq.palantetech.com/documents/120
Go to top