nagios monitor local resource of remote linux server using NRPE

you can use NRPE for remote linux monitor,describe as below:

1

try to install nrpe daemon

[root@bogon ~]# cd nrpe-3.0.1
[root@bogon nrpe-3.0.1]# ./configure --with-nrpe-user=nagios --with-nrpe-group=nagios  --with-nagios-user=nagios  --with-nagios-group=nagios  --enable-command-args  --enable-ssl
checking for a BSD-compatible install... /usr/bin/install -c
checking what the operating system is ... linux
checking what the distribution type is ... rh
checking what init system is being used ... upstart
checking what inetd is being used ... upstart
checking for which paths to use ... default
checking for which init file to use ... rh-upstart-init
checking for which inetd files to use ... unknown
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/nrpe-3.0.1':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
gcc and openssl were needed,yum install complete them: [root@bogon nrpe-3.0.1]# ./configure --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-command-args --enable-ssl checking for a BSD-compatible install... /usr/bin/install -c checking what the operating system is ... linux checking what the distribution type is ... rh checking what init system is being used ... upstart checking what inetd is being used ... upstart checking for which paths to use ... default checking for which init file to use ... rh-upstart-init checking for which inetd files to use ... unknown checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking whether make sets $(MAKE)... yes checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for ANSI C header files... yes checking whether time.h and sys/time.h may both be included... yes checking for sys/wait.h that is POSIX.1 compatible... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking ctype.h usability... yes checking ctype.h presence... yes checking for ctype.h... yes checking dirent.h usability... yes checking dirent.h presence... yes checking for dirent.h... yes checking errno.h usability... yes checking errno.h presence... yes checking for errno.h... yes checking fcntl.h usability... yes checking fcntl.h presence... yes checking for fcntl.h... yes checking getopt.h usability... yes checking getopt.h presence... yes checking for getopt.h... yes checking grp.h usability... yes checking grp.h presence... yes checking for grp.h... yes checking for inttypes.h... (cached) yes checking netdb.h usability... yes checking netdb.h presence... yes checking for netdb.h... yes checking pwd.h usability... yes checking pwd.h presence... yes checking for pwd.h... yes checking signal.h usability... yes checking signal.h presence... yes checking for signal.h... yes checking for stdint.h... (cached) yes checking for strings.h... (cached) yes checking for string.h... (cached) yes checking syslog.h usability... yes checking syslog.h presence... yes checking for syslog.h... yes checking tcpd.h usability... no checking tcpd.h presence... no checking for tcpd.h... no checking for unistd.h... (cached) yes checking arpa/inet.h usability... yes checking arpa/inet.h presence... yes checking for arpa/inet.h... yes checking netinet/in.h usability... yes checking netinet/in.h presence... yes checking for netinet/in.h... yes checking socket.h usability... no checking socket.h presence... no checking for socket.h... no checking for sys/types.h... (cached) yes checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking sys/resource.h usability... yes checking sys/resource.h presence... yes checking for sys/resource.h... yes checking for sys/wait.h... (cached) yes checking sys/socket.h usability... yes checking sys/socket.h presence... yes checking for sys/socket.h... yes checking for sys/stat.h... (cached) yes checking paths.h usability... yes checking paths.h presence... yes checking for paths.h... yes checking for an ANSI C-conforming const... yes checking whether struct tm is in sys/time.h or time.h... time.h checking for mode_t... yes checking for pid_t... yes checking for size_t... yes checking return type of signal handlers... void checking for uid_t in sys/types.h... yes checking type of array argument to getgroups... gid_t checking size of int... 4 checking size of short... 2 checking size of long... 8 checking for uint32_t... yes checking for u_int32_t... yes checking for int32_t... yes checking for struct sockaddr_storage... yes checking for seteuid... yes checking for va_copy... yes checking for vsnprintf... yes checking for snprintf... yes checking for asprintf... yes checking for vasprintf... yes checking for C99 vsnprintf... yes checking for getopt_long... yes checking for main in -lnsl... yes checking for socket in -lsocket... no checking for main in -lwrap... no checking for strdup... yes checking for strstr... yes checking for strtoul... yes checking for strtok_r... yes checking for initgroups... yes checking for closesocket... no checking for sigaction... yes checking for socklen_t... yes checking for type of socket size... size_t checking for Kerberos include files... found Kerberos include files in /usr/include/krb5 checking for pkg-config... pkg-config checking whether compiling and linking against SSL works... yes checking for openssl... /usr/bin/openssl *** Generating DH Parameters for SSL/TLS *** Generating DH parameters, 2048 bit long safe prime, generator 2 This is going to take a long time ..........................................................................................................................................................+............................................................+...................................................................................................................+...................................................................+..............................................................................................................+..................+....................................................................+...............................................................................................................................................................................................................................................................................................+.................................+...................................................................................................................................................................................................................................................................................+..........+...............................................................................................................................+..........................................+...................................+..........................+.......................+...........+......................................................++*++* checking for perl... /usr/bin/perl configure: creating ./config.status config.status: creating Makefile config.status: creating src/Makefile config.status: creating nrpe.spec config.status: creating uninstall config.status: creating sample-config/nrpe.cfg config.status: creating startup/bsd-init config.status: creating startup/debian-init config.status: creating startup/default-init config.status: creating startup/default-inetd config.status: creating startup/default-service config.status: creating startup/default-socket config.status: creating startup/default-socket-svc config.status: creating startup/default-xinetd config.status: creating startup/mac-init.plist config.status: creating startup/mac-inetd.plist config.status: creating startup/newbsd-init config.status: creating startup/openbsd-init config.status: creating startup/openrc-conf config.status: creating startup/openrc-init config.status: creating startup/solaris-init.xml config.status: creating startup/solaris-inetd.xml config.status: creating startup/tmpfile.conf config.status: creating startup/upstart-init config.status: creating startup/rh-upstart-init config.status: creating include/common.h config.status: creating include/config.h *** Configuration summary for nrpe 3.0.1 09-08-2016 ***: General Options: ------------------------- NRPE port: 5666 NRPE user: nagios NRPE group: nagios Nagios user: nagios Nagios group: nagios Review the options above for accuracy. If they look okay, type 'make all' to compile the NRPE daemon and client or type 'make' to get a list of make options. [root@bogon nrpe-3.0.1]#

make all
make install-plugin
make install-daemon
make install-config

[root@cent nrpe-3.0.1]# make install-plugin
cd ./src/; make install-plugin
make[1]: Entering directory `/root/tool/nrpe-3.0.1/src'
/usr/bin/install -c -m 755 -d /usr/local/nagios/bin
/usr/bin/install -c -m 755 ../uninstall /usr/local/nagios/bin/nrpe-uninstall
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
/usr/bin/install -c -m 775 -o nagios -g nagios check_nrpe /usr/local/nagios/libexec
make[1]: Leaving directory `/root/tool/nrpe-3.0.1/src'
[root@cent nrpe-3.0.1]#

[root@cent nrpe-3.0.1]# make install-daemon
cd ./src/; make install-daemon
make[1]: Entering directory `/root/tool/nrpe-3.0.1/src'
/usr/bin/install -c -m 755 -d /usr/local/nagios/bin
/usr/bin/install -c -m 755 ../uninstall /usr/local/nagios/bin/nrpe-uninstall
/usr/bin/install -c -m 755 nrpe /usr/local/nagios/bin
make[1]: Leaving directory `/root/tool/nrpe-3.0.1/src'

[root@cent nrpe-3.0.1]# make install-config
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 644 -o nagios -g nagios sample-config/nrpe.cfg /usr/local/nagios/etc
[root@cent nrpe-3.0.1]# 

//check the check_nrpe cmd was born in the $libexec dir

2

// to bring up the deamon in server startup

[root@cent nrpe-3.0.1]# make install-init
/usr/bin/install -c -m 644 startup/rh-upstart-init /etc/init/nrpe.conf
initctl reload-configuration

in the nagios server side,we only need the check_nrpe cmd script for getting information from the target server.

//start the nrpe deamon on nagios server side

[root@cent bin]# ./nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

unix  3      [ ]         DGRAM                    7094
[root@cent bin]# netstat -an|grep 5666
tcp        0      0 0.0.0.0:5666                0.0.0.0:*                   LISTEN
tcp        0      0 :::5666                     :::*                        LISTEN

//check the nrpe in localhots side

[root@cent libexec]# ./check_nrpe -H localhost
NRPE v3.0.1

//add the allow hosts

3

nrpe deamon was on client side,the remote server which need to be monitored

install the deamon in remote side which the server needed to be monitored

client side,you need to install all the nrpe including deamon…..
but in nagios server side,you only need the check_nrpe cmd

Install the nrpe in the target server,which need to be monitored

[root@bogon nrpe]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking what the operating system is ... linux
checking what the distribution type is ... rh
checking what init system is being used ... upstart
checking what inetd is being used ... upstart
checking for which paths to use ... default
checking for which init file to use ... rh-upstart-init
checking for which inetd files to use ... unknown
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether make sets $(MAKE)... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking whether time.h and sys/time.h may both be included... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking ctype.h usability... yes
checking ctype.h presence... yes
checking for ctype.h... yes
checking dirent.h usability... yes
checking dirent.h presence... yes
checking for dirent.h... yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking grp.h usability... yes
checking grp.h presence... yes
checking for grp.h... yes
checking for inttypes.h... (cached) yes
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking pwd.h usability... yes
checking pwd.h presence... yes
checking for pwd.h... yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking for stdint.h... (cached) yes
checking for strings.h... (cached) yes
checking for string.h... (cached) yes
checking syslog.h usability... yes
checking syslog.h presence... yes
checking for syslog.h... yes
checking tcpd.h usability... no
checking tcpd.h presence... no
checking for tcpd.h... no
checking for unistd.h... (cached) yes
checking arpa/inet.h usability... yes
checking arpa/inet.h presence... yes
checking for arpa/inet.h... yes
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking socket.h usability... no
checking socket.h presence... no
checking for socket.h... no
checking for sys/types.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/resource.h usability... yes
checking sys/resource.h presence... yes
checking for sys/resource.h... yes
checking for sys/wait.h... (cached) yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking for sys/stat.h... (cached) yes
checking paths.h usability... yes
checking paths.h presence... yes
checking for paths.h... yes
checking for an ANSI C-conforming const... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for mode_t... yes
checking for pid_t... yes
checking for size_t... yes
checking return type of signal handlers... void
checking for uid_t in sys/types.h... yes
checking type of array argument to getgroups... gid_t
checking size of int... 4
checking size of short... 2
checking size of long... 8
checking for uint32_t... yes
checking for u_int32_t... yes
checking for int32_t... yes
checking for struct sockaddr_storage... yes
checking for seteuid... yes
checking for va_copy... yes
checking for vsnprintf... yes
checking for snprintf... yes
checking for asprintf... yes
checking for vasprintf... yes
checking for C99 vsnprintf... yes
checking for getopt_long... yes
checking for main in -lnsl... yes
checking for socket in -lsocket... no
checking for main in -lwrap... no
checking for strdup... yes
checking for strstr... yes
checking for strtoul... yes
checking for strtok_r... yes
checking for initgroups... yes
checking for closesocket... no
checking for sigaction... yes
checking for socklen_t... yes
checking for type of socket size... size_t
checking for Kerberos include files... found Kerberos include files in /usr/include/krb5
checking for pkg-config... pkg-config
checking whether compiling and linking against SSL works... yes
checking for openssl... /usr/bin/openssl

*** Generating DH Parameters for SSL/TLS ***
Generating DH parameters, 2048 bit long safe prime, generator 2
This is going to take a long time
............+......................................

........++*++*
checking for perl... /usr/bin/perl
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating nrpe.spec
config.status: creating uninstall
config.status: creating sample-config/nrpe.cfg
config.status: creating startup/bsd-init
config.status: creating startup/debian-init
config.status: creating startup/default-init
config.status: creating startup/default-inetd
config.status: creating startup/default-service
config.status: creating startup/default-socket
config.status: creating startup/default-socket-svc
config.status: creating startup/default-xinetd
config.status: creating startup/mac-init.plist
config.status: creating startup/mac-inetd.plist
config.status: creating startup/newbsd-init
config.status: creating startup/openbsd-init
config.status: creating startup/openrc-conf
config.status: creating startup/openrc-init
config.status: creating startup/solaris-init.xml
config.status: creating startup/solaris-inetd.xml
config.status: creating startup/tmpfile.conf
config.status: creating startup/upstart-init
config.status: creating startup/rh-upstart-init
config.status: creating include/common.h
config.status: creating include/config.h

*** Configuration summary for nrpe 3.0.1 09-08-2016 ***:

 General Options:
 -------------------------
 NRPE port:    5666
 NRPE user:    nagios
 NRPE group:   nagios
 Nagios user:  nagios
 Nagios group: nagios



Review the options above for accuracy.  If they look okay,
type 'make all' to compile the NRPE daemon and client
or type 'make' to get a list of make options.

quite easy as before.

[root@bogon nrpe]# make

Please enter make [option] where [option] is one of:

     all                  builds nrpe and check_nrpe
     nrpe                 builds nrpe only
     check_nrpe           builds check_nrpe only
     install-groups-users add the users and groups if they do not exist
     install              install nrpe and check_nrpe
     install-plugin       install the check_nrpe plugin
     install-daemon       install the nrpe daemon
     install-config       install the nrpe configuration file
     install-inetd        install the startup files for inetd, launchd, etc.
     install-init         install the startup files for init, systemd, etc.

[root@bogon nrpe]# make install-daemon
cd ./src/; make install-daemon
make[1]: Entering directory `/usr/local/nrpe/src'
/usr/bin/install -c -m 755 -d /usr/local/nagios/bin
/usr/bin/install -c -m 755 ../uninstall /usr/local/nagios/bin/nrpe-uninstall
/usr/bin/install -c -m 755 nrpe /usr/local/nagios/bin
/usr/bin/install -c -m 755 -o nagios -g nagios -d /usr/local/nagios/var
/usr/bin/install: invalid user `nagios'
make[1]: *** [install-daemon] Error 1
make[1]: Leaving directory `/usr/local/nrpe/src'
make: *** [install-daemon] Error 2
[root@bogon nrpe]#

seems need the nagios user

useradd -s /sbin/nologin nagios

// in nagios server side

touch a cfg file for remote linux monitor in nagios server side

4

5

6

7

8

9

–EOF–