Date post: | 01-Dec-2015 |
Category: |
Documents |
Upload: | pablito-roberto |
View: | 63 times |
Download: | 3 times |
Monitoreando con Nagios
EN LA MÁQUINA A MONITOREAR instalar nagios-plugins y también el paquete openssl-devel
yum install openssl-devel
Para instalar el plugin de Nagios seguir estos pasos:
Instalar el Plugin de Nagios desde su página oficial (se supone descargado el paquete dentro de la
carpeta downloads).
[hostremoto]# cd /home/downloads
[hostremoto]# tar xvfz nagios-plugins-1.4.11.tar.gz
[hostremoto]# cd nagios-plugins-1.4.11
[hostremoto]# export LDFLAGS=-ldl
[hostremoto]# ./configure –with-nagios-user=nagios –with-nagios-group=nagios –enable-redhat-pthread-
workaround
[hostremoto]# make
[hostremoto]# make install
[hostremoto]# chown nagios:nagios /usr/local/nagios
[hostremoto]# chown -R nagios:nagios /usr/local/nagios/libexec/
Fuente: http://www.nagios-do.org/?p=192
Ahora instalar el paquete nrpe disponible en la página de nagios, descomprimirlo, ir dentro del
directorio y ejecutar
Nota: NRPE (Nagios Remote Plugin Executor) permite monitorizar dispositivos de redremotos usando
Nagios.
[root@localhost nrpe-2.13]# ./configure
Lo anterior da como salida:
[root@localhost nrpe-2.13]# yum search openssl-devel
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: centosc6.centos.org
* extras: centosq3.centos.org
* updates: centosr3.centos.org
========================== N/S Matched: openssl-devel ==========================
openssl-devel.i686 : Files for development of applications which will use
: OpenSSL
Name and summary matches only, use "search all" for everything.
[root@localhost nrpe-2.13]# yum install openssl-devel
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: centosz3.centos.org
* extras: centosx5.centos.org
* updates: centosp4.centos.org
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package openssl-devel.i686 0:1.0.0-25.el6_3.1 will be installed
--> Processing Dependency: openssl = 1.0.0-25.el6_3.1 for package: openssl-devel-1.0.0-25.el6_3.1.i686
--> Processing Dependency: krb5-devel for package: openssl-devel-1.0.0-25.el6_3.1.i686
--> Running transaction check
---> Package krb5-devel.i686 0:1.9-33.el6_3.3 will be installed
--> Processing Dependency: krb5-libs = 1.9-33.el6_3.3 for package: krb5-devel-1.9-33.el6_3.3.i686
--> Processing Dependency: libselinux-devel for package: krb5-devel-1.9-33.el6_3.3.i686
--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.9-33.el6_3.3.i686
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.9-33.el6_3.3.i686
---> Package openssl.i686 0:1.0.0-20.el6 will be updated
---> Package openssl.i686 0:1.0.0-25.el6_3.1 will be an update
--> Running transaction check
---> Package keyutils-libs-devel.i686 0:1.4-4.el6 will be installed
--> Processing Dependency: keyutils-libs = 1.4-4.el6 for package: keyutils-libs-devel-1.4-4.el6.i686
---> Package krb5-libs.i686 0:1.9-22.el6 will be updated
--> Processing Dependency: krb5-libs = 1.9-22.el6 for package: krb5-workstation-1.9-22.el6.i686
---> Package krb5-libs.i686 0:1.9-33.el6_3.3 will be an update
---> Package libcom_err-devel.i686 0:1.41.12-12.el6 will be installed
--> Processing Dependency: libcom_err = 1.41.12-12.el6 for package: libcom_err-devel-1.41.12-
12.el6.i686
---> Package libselinux-devel.i686 0:2.0.94-5.3.el6 will be installed
--> Processing Dependency: libselinux = 2.0.94-5.3.el6 for package: libselinux-devel-2.0.94-
5.3.el6.i686
--> Processing Dependency: libsepol-devel >= 2.0.32-1 for package: libselinux-devel-2.0.94-5.3.el6.i686
--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.0.94-5.3.el6.i686
--> Running transaction check
---> Package keyutils-libs.i686 0:1.4-3.el6 will be updated
--> Processing Dependency: keyutils-libs = 1.4-3.el6 for package: keyutils-1.4-3.el6.i686
---> Package keyutils-libs.i686 0:1.4-4.el6 will be an update
---> Package krb5-workstation.i686 0:1.9-22.el6 will be updated
---> Package krb5-workstation.i686 0:1.9-33.el6_3.3 will be an update
---> Package libcom_err.i686 0:1.41.12-11.el6 will be updated
--> Processing Dependency: libcom_err = 1.41.12-11.el6 for package: libss-1.41.12-11.el6.i686
--> Processing Dependency: libcom_err = 1.41.12-11.el6 for package: e2fsprogs-libs-1.41.12-11.el6.i686
--> Processing Dependency: libcom_err = 1.41.12-11.el6 for package: e2fsprogs-1.41.12-11.el6.i686
---> Package libcom_err.i686 0:1.41.12-12.el6 will be an update
---> Package libselinux.i686 0:2.0.94-5.2.el6 will be updated
--> Processing Dependency: libselinux = 2.0.94-5.2.el6 for package: libselinux-utils-2.0.94-
5.2.el6.i686
--> Processing Dependency: libselinux = 2.0.94-5.2.el6 for package: libselinux-python-2.0.94-
5.2.el6.i686
---> Package libselinux.i686 0:2.0.94-5.3.el6 will be an update
---> Package libsepol-devel.i686 0:2.0.41-4.el6 will be installed
--> Running transaction check
---> Package e2fsprogs.i686 0:1.41.12-11.el6 will be updated
---> Package e2fsprogs.i686 0:1.41.12-12.el6 will be an update
---> Package e2fsprogs-libs.i686 0:1.41.12-11.el6 will be updated
---> Package e2fsprogs-libs.i686 0:1.41.12-12.el6 will be an update
---> Package keyutils.i686 0:1.4-3.el6 will be updated
---> Package keyutils.i686 0:1.4-4.el6 will be an update
---> Package libselinux-python.i686 0:2.0.94-5.2.el6 will be updated
---> Package libselinux-python.i686 0:2.0.94-5.3.el6 will be an update
---> Package libselinux-utils.i686 0:2.0.94-5.2.el6 will be updated
---> Package libselinux-utils.i686 0:2.0.94-5.3.el6 will be an update
---> Package libss.i686 0:1.41.12-11.el6 will be updated
---> Package libss.i686 0:1.41.12-12.el6 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
openssl-devel i686 1.0.0-25.el6_3.1 updates 1.1 M
Installing for dependencies:
keyutils-libs-devel i686 1.4-4.el6 base 28 k
krb5-devel i686 1.9-33.el6_3.3 updates 1.2 M
libcom_err-devel i686 1.41.12-12.el6 base 31 k
libselinux-devel i686 2.0.94-5.3.el6 base 136 k
libsepol-devel i686 2.0.41-4.el6 base 64 k
Updating for dependencies:
e2fsprogs i686 1.41.12-12.el6 base 551 k
e2fsprogs-libs i686 1.41.12-12.el6 base 126 k
keyutils i686 1.4-4.el6 base 38 k
keyutils-libs i686 1.4-4.el6 base 20 k
krb5-libs i686 1.9-33.el6_3.3 updates 720 k
krb5-workstation i686 1.9-33.el6_3.3 updates 412 k
libcom_err i686 1.41.12-12.el6 base 36 k
libselinux i686 2.0.94-5.3.el6 base 108 k
libselinux-python i686 2.0.94-5.3.el6 base 199 k
libselinux-utils i686 2.0.94-5.3.el6 base 81 k
libss i686 1.41.12-12.el6 base 40 k
openssl i686 1.0.0-25.el6_3.1 updates 1.4 M
Transaction Summary
================================================================================
Install 6 Package(s)
Upgrade 12 Package(s)
Total download size: 6.2 M
Is this ok [y/N]: y
Downloading Packages:
(1/18): e2fsprogs-1.41.12-12.el6.i686.rpm | 551 kB 00:04
(2/18): e2fsprogs-libs-1.41.12-12.el6.i686.rpm | 126 kB 00:01
(3/18): keyutils-1.4-4.el6.i686.rpm | 38 kB 00:00
(4/18): keyutils-libs-1.4-4.el6.i686.rpm | 20 kB 00:00
(5/18): keyutils-libs-devel-1.4-4.el6.i686.rpm | 28 kB 00:00
http://centosp4.centos.org/centos/6.3/updates/i386/Packages/krb5-devel-1.9-33.el6_3.3.i686.rpm: [Errno
12] Timeout on http://centosp4.centos.org/centos/6.3/updates/i386/Packages/krb5-devel-1.9-
33.el6_3.3.i686.rpm: (28, 'Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds')
Trying other mirror.
(6/18): krb5-devel-1.9-33.el6_3.3.i686.rpm | 1.2 MB 00:08
(7/18): krb5-libs-1.9-33.el6_3.3.i686.rpm | 720 kB 00:06
(8/18): krb5-workstation-1.9-33.el6_3.3.i686.rpm | 412 kB 00:03
(9/18): libcom_err-1.41.12-12.el6.i686.rpm | 36 kB 00:00
(10/18): libcom_err-devel-1.41.12-12.el6.i686.rpm | 31 kB 00:00
(11/18): libselinux-2.0.94-5.3.el6.i686.rpm | 108 kB 00:01
(12/18): libselinux-devel-2.0.94-5.3.el6.i686.rpm | 136 kB 00:01
(13/18): libselinux-python-2.0.94-5.3.el6.i686.rpm | 199 kB 00:01
(14/18): libselinux-utils-2.0.94-5.3.el6.i686.rpm | 81 kB 00:00
(15/18): libsepol-devel-2.0.41-4.el6.i686.rpm | 64 kB 00:00
(16/18): libss-1.41.12-12.el6.i686.rpm | 40 kB 00:00
(17/18): openssl-1.0.0-25.el6_3.1.i686.rpm | 1.4 MB 00:11
(18/18): openssl-devel-1.0.0-25.el6_3.1.i686.rpm | 1.1 MB 00:09
--------------------------------------------------------------------------------
Total 66 kB/s | 6.2 MB 01:36
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : libsepol-devel-2.0.41-4.el6.i686 1/30
Updating : libcom_err-1.41.12-12.el6.i686 2/30
Updating : libselinux-2.0.94-5.3.el6.i686 3/30
Updating : keyutils-libs-1.4-4.el6.i686 4/30
Updating : krb5-libs-1.9-33.el6_3.3.i686 5/30
Updating : libss-1.41.12-12.el6.i686 6/30
Installing : keyutils-libs-devel-1.4-4.el6.i686 7/30
Installing : libselinux-devel-2.0.94-5.3.el6.i686 8/30
Installing : libcom_err-devel-1.41.12-12.el6.i686 9/30
Installing : krb5-devel-1.9-33.el6_3.3.i686 10/30
Updating : openssl-1.0.0-25.el6_3.1.i686 11/30
Updating : e2fsprogs-libs-1.41.12-12.el6.i686 12/30
Installing : openssl-devel-1.0.0-25.el6_3.1.i686 13/30
Updating : e2fsprogs-1.41.12-12.el6.i686 14/30
Updating : krb5-workstation-1.9-33.el6_3.3.i686 15/30
Updating : keyutils-1.4-4.el6.i686 16/30
Updating : libselinux-utils-2.0.94-5.3.el6.i686 17/30
Updating : libselinux-python-2.0.94-5.3.el6.i686 18/30
Cleanup : krb5-workstation-1.9-22.el6.i686 19/30
Cleanup : e2fsprogs-1.41.12-11.el6.i686 20/30
Cleanup : openssl-1.0.0-20.el6.i686 21/30
Cleanup : krb5-libs-1.9-22.el6.i686 22/30
Cleanup : e2fsprogs-libs-1.41.12-11.el6.i686 23/30
Cleanup : libss-1.41.12-11.el6.i686 24/30
Cleanup : keyutils-1.4-3.el6.i686 25/30
Cleanup : libselinux-python-2.0.94-5.2.el6.i686 26/30
Cleanup : libselinux-utils-2.0.94-5.2.el6.i686 27/30
Cleanup : libselinux-2.0.94-5.2.el6.i686 28/30
Cleanup : keyutils-libs-1.4-3.el6.i686 29/30
Cleanup : libcom_err-1.41.12-11.el6.i686 30/30
Installed:
openssl-devel.i686 0:1.0.0-25.el6_3.1
Dependency Installed:
keyutils-libs-devel.i686 0:1.4-4.el6 krb5-devel.i686 0:1.9-33.el6_3.3
libcom_err-devel.i686 0:1.41.12-12.el6 libselinux-devel.i686 0:2.0.94-5.3.el6
libsepol-devel.i686 0:2.0.41-4.el6
Dependency Updated:
e2fsprogs.i686 0:1.41.12-12.el6
e2fsprogs-libs.i686 0:1.41.12-12.el6
keyutils.i686 0:1.4-4.el6
keyutils-libs.i686 0:1.4-4.el6
krb5-libs.i686 0:1.9-33.el6_3.3
krb5-workstation.i686 0:1.9-33.el6_3.3
libcom_err.i686 0:1.41.12-12.el6
libselinux.i686 0:2.0.94-5.3.el6
libselinux-python.i686 0:2.0.94-5.3.el6
libselinux-utils.i686 0:2.0.94-5.3.el6
libss.i686 0:1.41.12-12.el6
openssl.i686 0:1.0.0-25.el6_3.1
Complete!
[root@localhost nrpe-2.13]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
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 ANSI C... none needed
checking whether make sets $(MAKE)... yes
checking how to run the C preprocessor... gcc -E
checking for egrep... 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 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 for int... yes
checking size of int... 4
checking for short... yes
checking size of short... 2
checking for long... yes
checking size of long... 4
checking for uint32_t... yes
checking for u_int32_t... yes
checking for int32_t... 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 initgroups... yes
checking for closesocket... no
checking for socklen_t... yes
checking for type of socket size... size_t
checking for SSL headers... SSL headers found in /usr
checking for SSL libraries... SSL libraries found in /usr/lib
*** Generating DH Parameters for SSL/TLS ***
Generating DH parameters, 512 bit long safe prime, generator 2
This is going to take a long time
.............+...............................+...................................................+...++
*++*++*++*++*++*
checking for Kerberos include files... could not find include files
checking for perl... /usr/bin/perl
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating subst
config.status: creating include/config.h
*** Configuration summary for nrpe 2.13 11-11-2011 ***:
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.
[root@localhost nrpe-2.13]#
Ahora ejecutamos make all
[root@localhost nrpe-2.13]# make all
cd ./src/; make ; cd ..
make[1]: Entering directory `/root/Downloads/nrpe-2.13/src'
gcc -g -O2 -I/usr/include/openssl -I/usr/include -DHAVE_CONFIG_H -o nrpe nrpe.c utils.c acl.c -
L/usr/lib -lssl -lcrypto -lnsl
nrpe.c: In function ‘main’:
nrpe.c:218: warning: assignment discards qualifiers from pointer target type
gcc -g -O2 -I/usr/include/openssl -I/usr/include -DHAVE_CONFIG_H -o check_nrpe check_nrpe.c utils.c -
L/usr/lib -lssl -lcrypto -lnsl
check_nrpe.c: In function ‘main’:
check_nrpe.c:126: warning: assignment discards qualifiers from pointer target type
make[1]: Leaving directory `/root/Downloads/nrpe-2.13/src'
*** Compile finished ***
If the NRPE daemon and client compiled without any errors, you
can continue with the installation or upgrade process.
Read the PDF documentation (NRPE.pdf) for information on the next
steps you should take to complete the installation or upgrade.
[root@localhost nrpe-2.13]#
Ahora make install-plugin
[root@localhost nrpe-2.13]# make install-plugin
cd ./src/ && make install-plugin
make[1]: Entering directory `/root/Downloads/nrpe-2.13/src'
/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/Downloads/nrpe-2.13/src'
[root@localhost nrpe-2.13]#
Ahora make install-daemon
[root@localhost nrpe-2.13]# make install-daemon
cd ./src/ && make install-daemon
make[1]: Entering directory `/root/Downloads/nrpe-2.13/src'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/bin
/usr/bin/install -c -m 775 -o nagios -g nagios nrpe /usr/local/nagios/bin
make[1]: Leaving directory `/root/Downloads/nrpe-2.13/src'
[root@localhost nrpe-2.13]#
Ahora make install-daemon-config
[root@localhost nrpe-2.13]# make install-daemon-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@localhost nrpe-2.13]#
Ahora make install-xinetd
[root@localhost nrpe-2.13]# make install-xinetd
/usr/bin/install -c -m 644 sample-config/nrpe.xinetd /etc/xinetd.d/nrpe
[root@localhost nrpe-2.13]#
Editar (sacar un backup) el archivo /etc/xinetd.d/nrpe y agragar la IP de nuestro servidor nagios (con el
core) que es 192.168.1.2.
# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
flags = REUSE
socket_type = stream
port = 5666
wait = no
user = nagios
group = nagios
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure += USERID
disable = no
only_from = 127.0.0.1 192.168.1.2
}
Editar el archivo /etc/services y agregar en la última línea “nrpe 5666/tcp # NRPE ”
blp5 48129/udp # Bloomberg locator
com-bardac-dw 48556/tcp # com-bardac-dw
com-bardac-dw 48556/udp # com-bardac-dw
iqobject 48619/tcp # iqobject
iqobject 48619/udp # iqobject
nrpe 5666/tcp # NRPE
Ahora reiniciar el servicio xinetd y verificar que nrpe está escuchando:
[root@localhost nrpe-2.13]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@localhost nrpe-2.13]# netstat -at | grep nrpe
tcp 0 0 *:nrpe *:* LISTEN
[root@localhost nrpe-2.13]#
Ahora sí a probar (PERO DESDE EL MISMO HOST):
Vemos los dispositivos que tenemos:
[root@localhost nagios-plugins-1.4.16]# fdisk -l
Disk /dev/sda: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009ba81
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2089 16264192 8e Linux LVM
Disk /dev/mapper/VolGroup-lv_root: 15.3 GB, 15342764032 bytes
255 heads, 63 sectors/track, 1865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_root doesn't contain a valid partition table
Disk /dev/mapper/VolGroup-lv_swap: 1308 MB, 1308622848 bytes
255 heads, 63 sectors/track, 159 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_swap doesn't contain a valid partition table
[root@localhost nagios-plugins-1.4.16]#
Ahora vemos el estado del /dev/sda:
[root@localhost nagios-plugins-1.4.16]# /usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda
DISK OK - free space: / 9172 MB (67% inode=88%);| /=4498MB;11521;12961;0;14402
[root@localhost nagios-plugins-1.4.16]#
El comando anterior establece que devuelva un advertencia (-w) si el disco está a menos de 20% de
espacio libre y Crítico (-c) si a menos de 10%.
IMPORTANTE: HABILITAR EL PUERTO 5666/TCP en el cortafuegos. !!!!
para poder hacer
[root@localhost nagios-plugins-1.4.16]# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.4
NRPE v2.13
[root@localhost nagios-plugins-1.4.16]# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.2
NRPE v2.13
Sino sale “connection refused or time out” o esto:
[root@localhost nagios-plugins-1.4.16]# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.2
CHECK_NRPE: Error - Could not complete SSL handshake.
# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
disable = no
flags = REUSE
socket_type = stream
port = 5666
wait = no
user = nagios
group = nagios
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure += USERID
only_from = 192.168.1.2 127.0.0.1 192.168.1.4
}
CONFIGURACIONES PARA EN SERVIDOR NAGIOS (que va a monitorear)
Instalar el core-nagios, el nagios-plugins , el nrpe y MUY IMPORTANTE antes de todo eso instalar el
openssl-devel con yum install (se instalan sus dependencias) ya que este openssl-devel hace que no
salgan los errores al hacer make o make install en los paquetes nahios-plugibns y nrpe.
Igual se configuran los archivos /etc/xinetd.d/nrpe y /etc/services como se ve arriba y SE HABILITA
EL PUERTO 5666 EN EL MURO CORTAFUEGOS y se reinicia el servcicio xinetd.
A esta altura se puede hacer a y desde el servidor:
[root@localhost nagios-plugins-1.4.16]# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.2
NRPE v2.13
Lo anterior se hace desde el servidor a ser monitorizado (192.168.1.2) al servidor nagios (192.168.1.4)
comprobando que se pueda establecer conexión.
MONITOREANDO DESDE EL SERVIDOR NAGIOS a un servidor linux
Abrir la interfaz web de nagios como http://<ip del servidor nagios ó nombre>/nagios/
Para solucioanr el problema de que ingún link de la izquierda funca (aparece eso de “The server
encountered an internal error or misconfiguration...”) salvo dos (home y documentation)
ejecutar el comando:
[root@localhost nagios-plugins-1.4.16]# chcon -R -t httpd_sys_content_t /usr/local/nagios
Ahora sí se puede observar información y gráficos en la interfaz de nagios:
AHORA SÍ MONITOREMOS ALGO
MONITOREANDO A OTRO HOST CON CENTOS COMO SO
Supongamos que queremos monitorear un servidor con CentOS 6.2 de IP 192.168.1.2 desde otro
equipo monitorizador con nagios (y nrpe) instalado de IP 192.168.1.4.
Digamos que vamos a chequear el disco del otro equipo:
En el servidor nagios (monitorizador)
Definir el comando a usar para checar el disco:
[root@nagios Desktop]# gedit /usr/local/nagios/etc/nrpe.cfg
Agregar la línea al final del archivo:
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda
Definir un comando, para ello:
[root@nagios Desktop]# gedit /usr/local/nagios/etc/objects/commands.cfg
Y definir un comando como el siguiente (agregarlo al último): define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
define command{
command_name check_disk
command_line $USER1$/check_disk -w 20% -c 10% -p /dev/sda
}
NOTA:
/dev/mapper/sda puede variar, representa la unidad de disco , “la que vamos a monitorear”. Para saber
cuál unidad o partición monitorear se puede ejecutar el comando (EN EL HOST REMOTO):
[root@nagios Desktop]# fdisk -l
Disk /dev/sda: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009ba81
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2089 16264192 8e Linux LVM
Disk /dev/mapper/VolGroup-lv_root: 15.3 GB, 15342764032 bytes
255 heads, 63 sectors/track, 1865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_root doesn't contain a valid partition table
Disk /dev/mapper/VolGroup-lv_swap: 1308 MB, 1308622848 bytes
255 heads, 63 sectors/track, 159 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_swap doesn't contain a valid partition table
[root@nagios Desktop]#
(En el equipo monitorizador ) crear un archivo en /usr/local/nagios/etc/objects/ con extensión .cfg
por ejemplo: /usr/local/nagios/etc/objects/srvremoto.cfg y agregar lo siguiente:
define host{
use linux-server
host_name dns1.midominio.com.ec
alias servidor de midominio.com.ec
address 192.168.1.2
contact_groups admins
}
define service{
use generic-service
host dns1.midominio.com.ec
service_description Disco duro
contact_groups admins
check_command check_nrpe!check_disk
}
En el archivo más o menos por la línea 37 añadir la línea:
cfg_file=/usr/local/nagios/etc/objects/srvremoto.cfg
Reiniciar el servicio nagios y xinetd
En el equipo a monitorizar
Sabíamos que en el archivo /etc/xinetd.d/nrpe debe estar la IP de nuestro servidor nagios (con el core)
que es 192.168.1.2.
# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
flags = REUSE
socket_type = stream
port = 5666
wait = no
user = nagios
group = nagios
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure += USERID
disable = no
only_from = 127.0.0.1 192.168.1.2
}
IMPORTANTE:
Agregar la misma línea en el host remoto en el mismo archivo (reiniciar xinetd y nagios)
Definir el comando a usar para checar el disco:
[root@nagios Desktop]# gedit /usr/local/nagios/etc/nrpe.cfg
Agregar la línea al final del archivo:
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda
Reiniciar nagios y xinetd (porsiaca)
[root@nagios Desktop]# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.
[root@nagios Desktop]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@nagios Desktop]#
Y LISTO
En este punto ya podemos checar en la interface web:
Para chequear smtp
En el servidor nagios (monitorizador)
Agregar al archivo srvremoto.cfg
define service{
use generic-service
host dns1.midominio.com.ec
service_description SMTP
contact_groups admins
check_command check_nrpe!check_smtp
}
Y en el archivo nrpe.cfg
command[check_smtp]=/usr/local/nagios/libexec/check_smtp -w 10 -c 5
reiniciar xinetd y nagios
En el equipo a monitorizar:
En el archivo nrpe.cfg
command[check_smtp]=/usr/local/nagios/libexec/check_smtp -w 10 -c 5
reiniciar xinetd y nagios
Y se puede ver: