Project

General

Profile

Setting up NRPE on Debian server » History » Version 3

Jamila Khan, 08/19/2014 05:15 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
90 2 Jamila Khan
h3. restart service
91 1 Jamila Khan
92 2 Jamila Khan
<pre>
93
service nagios-nrpe-server restart
94
</pre>
95 1 Jamila Khan
96 2 Jamila Khan
97
h2. on monitoring server
98
99
h3. test connection
100
101
On Nagios/Icinga server test that that worked:
102
103
<pre>
104
/usr/lib/nagios/plugins/check_nrpe -H clientserveruri.com -c check_nrpe_daemon
105
NRPE OK
106
</pre>
107
108
h3. set up checks.
109
110
example service config file
111
112
<pre>
113
###############################################################################
114
###############################################################################
115
#
116
# SERVICE DEFINITIONS
117
#
118
###############################################################################
119
###############################################################################
120
121
define service{
122
        use                     generic-service         ; Inherit default values from a template
123
        host_name               clientserver
124
        service_description     SSH
125
        check_command           check_ssh
126
        }
127
128
define service{
129
        use                     generic-service         ; Inherit default values from a template
130
        host_name               clientserver
131
        service_description     HTTP
132
        check_command           check_http
133
        }
134
135
define service{
136
        use                     generic-service         ; Inherit default values from a template
137
        host_name               clientserver
138
        service_description     Users
139
        check_command           check_nrpe_1arg!check_users
140
        }
141
142
define service{
143
        use                     generic-service         ; Inherit default values from a template
144
        host_name               clientserver
145
        service_description     Load
146
        check_command           check_nrpe_1arg!check_load
147
        }
148
149
define service{
150
        use                     generic-service         ; Inherit default values from a template
151
        host_name               clientserver
152
        service_description     Zombie Processes
153
        check_command           check_nrpe_1arg!check_zombie_procs
154
        }
155
156
define service{
157
        use                     generic-service         ; Inherit default values from a template
158
        host_name               clientserver
159
        service_description     Total Processes
160
        check_command           check_nrpe_1arg!check_total_procs
161
        }
162
163
define service{
164
        use                     generic-service         ; Inherit default values from a template
165
        host_name               clientserver
166
        service_description     Disk Space /root
167
        check_command           check_nrpe_1arg!check_disk_root
168 1 Jamila Khan
        }
169 3 Jamila Khan
170
define service{
171
        use                     generic-service         ; Inherit default values from a template
172
        host_name               clientserver
173
        service_description     Apache SIGTERM
174
        check_command           check_nrpe_1arg!check_apache_sigterm
175
        }
176 2 Jamila Khan
</pre>
177 1 Jamila Khan
178 3 Jamila Khan
179
h3. restart monitoring service
180
181
for icinga
182
183
<pre>
184
/etc/init.d/icinga restart
185
</pre>
186 2 Jamila Khan
187
188
sources:
189 1 Jamila Khan
http://xmodulo.com/2014/03/nagios-remote-plugin-executor-nrpe-linux.html
190
https://wiki.icinga.org/display/howtos/Setting+up+NRPE+with+Icinga
Go to top