Project

General

Profile

Setting up NRPE on Debian server » History » Version 4

Jamila Khan, 09/02/2016 04:25 PM

1 1 Jamila Khan
h1. Setting up NRPE on Debian server
2
3
{{>toc}}
4
5
Process:
6
7 2 Jamila Khan
h2. on client server
8 1 Jamila Khan
9 2 Jamila Khan
h3. Install NRPE
10
11 1 Jamila Khan
<pre>
12
aptitude install nagios-nrpe-server nagios-plugins-basic
13
</pre>
14
15
h3. Edit config file
16
17
<pre>
18
vim /etc/nagios/nrpe.cfg
19
</pre>
20
21
* Add IP_v4_of_Nagios_server to allowed_hosts
22
23
h3. start service
24
25
<pre>
26
service nagios-nrpe-server restart
27
</pre>
28
29
h3. check that service is running
30
31
<pre>
32
netstat -tpln | grep 5666
33
</pre>
34
35
h3. edit local config to add specified checks
36
37
<pre>
38
vim /etc/nagios/nrpe_local.cfg
39
</pre>
40
41 3 Jamila Khan
Add NRPE test check, disk check, and Apache SIGTERM check
42 1 Jamila Khan
43
<pre>
44
0 octavia:/etc/nagios# cat nrpe_local.cfg 
45
######################################
46
# Do any local nrpe configuration here
47
######################################
48
49
command[check_nrpe_daemon]=/bin/echo "NRPE OK"
50
51
# disk checks
52 2 Jamila Khan
command[check_disk_root]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/root
53 1 Jamila Khan
54 3 Jamila Khan
# checking Apache logs for SIGTERM
55
command[check_apache_sigterm]=/usr/lib/nagios/plugins/check_cat.sh /var/log/apache2/error.log SIGTERM 0
56
57 1 Jamila Khan
</pre>
58
59 3 Jamila Khan
h3. add check_cat
60
61
In /usr/lib/nagios/plugins create check_cat.sh
62
63
<pre>
64
#!/bin/bash
65
66
#
67
# checks in files if there are instances of a given string.
68
# $1 is the file
69
# $2 is the string
70
# $3 is the threshold, any more than $3 and it will be Critical
71
72
cnt=`cat $1|grep $2|wc -l`
73
recent=`cat $1|grep $2`
74
if [ $cnt -le $3 ] ; then
75
        echo OK - no errors or warnings
76
        exit 0
77
fi
78
79
echo -e "CRITICAL - String $2 appeared $cnt times\n$recent"
80
exit 2
81
</pre>
82
83
Make it executable
84
85
<pre>
86
chmod 755 /usr/lib/nagios/plugins/check_cat.sh
87
</pre>
88
89 4 Jamila Khan
h3. Make total procs check ignore kernel processes
90
91
Add -k to the total_procs check in /etc/nagios/nrpe.cfg, and lower the threshold.
92
93
<pre>
94
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -k -w 130 -c 180
95
</pre>
96 3 Jamila Khan
97 2 Jamila Khan
h3. restart service
98 1 Jamila Khan
99 2 Jamila Khan
<pre>
100
service nagios-nrpe-server restart
101
</pre>
102 1 Jamila Khan
103 2 Jamila Khan
104
h2. on monitoring server
105
106
h3. test connection
107
108
On Nagios/Icinga server test that that worked:
109
110
<pre>
111
/usr/lib/nagios/plugins/check_nrpe -H clientserveruri.com -c check_nrpe_daemon
112
NRPE OK
113
</pre>
114
115
h3. set up checks.
116
117
example service config file
118
119
<pre>
120
###############################################################################
121
###############################################################################
122
#
123
# SERVICE DEFINITIONS
124
#
125
###############################################################################
126
###############################################################################
127
128
define service{
129
        use                     generic-service         ; Inherit default values from a template
130
        host_name               clientserver
131
        service_description     SSH
132
        check_command           check_ssh
133
        }
134
135
define service{
136
        use                     generic-service         ; Inherit default values from a template
137
        host_name               clientserver
138
        service_description     HTTP
139
        check_command           check_http
140
        }
141
142
define service{
143
        use                     generic-service         ; Inherit default values from a template
144
        host_name               clientserver
145
        service_description     Users
146
        check_command           check_nrpe_1arg!check_users
147
        }
148
149
define service{
150
        use                     generic-service         ; Inherit default values from a template
151
        host_name               clientserver
152
        service_description     Load
153
        check_command           check_nrpe_1arg!check_load
154
        }
155
156
define service{
157
        use                     generic-service         ; Inherit default values from a template
158
        host_name               clientserver
159
        service_description     Zombie Processes
160
        check_command           check_nrpe_1arg!check_zombie_procs
161
        }
162
163
define service{
164
        use                     generic-service         ; Inherit default values from a template
165
        host_name               clientserver
166
        service_description     Total Processes
167
        check_command           check_nrpe_1arg!check_total_procs
168
        }
169
170
define service{
171
        use                     generic-service         ; Inherit default values from a template
172
        host_name               clientserver
173
        service_description     Disk Space /root
174
        check_command           check_nrpe_1arg!check_disk_root
175 1 Jamila Khan
        }
176 3 Jamila Khan
177
define service{
178
        use                     generic-service         ; Inherit default values from a template
179
        host_name               clientserver
180
        service_description     Apache SIGTERM
181
        check_command           check_nrpe_1arg!check_apache_sigterm
182
        }
183 2 Jamila Khan
</pre>
184 1 Jamila Khan
185 3 Jamila Khan
186
h3. restart monitoring service
187
188
for icinga
189
190
<pre>
191
/etc/init.d/icinga restart
192
</pre>
193 2 Jamila Khan
194
195
sources:
196 1 Jamila Khan
http://xmodulo.com/2014/03/nagios-remote-plugin-executor-nrpe-linux.html
197
https://wiki.icinga.org/display/howtos/Setting+up+NRPE+with+Icinga
Go to top