Instalacion de Nagios en Slackware 13.1 x86.

¿QUe es nagios?
Es un sistema de monitoreo de codigo libre (GNU), el cual se encarga del monitoreo tanto de servicios
software, como caracteristicas fisicas de los servidores (equipos) los cuales se encuentren en su lista
de monitoreo.
Tiene la opcion de enviar notificaciones via sms, email, etc.
La operacion de este sistema es através de plugins, los cuales como hemos visto en aplicaciones tales como firefox
chrome, thunderbird, nos ayudan a expandir las posibilidades de estas. por lo que de la misma manera estos plugins
ayudaran a mejorar la operacion de nagios.
Requisitos:
Solo un Servidor Linux, así como un compilador de C.
Un servidor web (apache) así como librerias gd.
Pasos para su instalación.
 
1) Create Account Information
A. Accedemos en modo root
1
2
bash-4.1$ su
Password:

B. Creamos el grupo al cual se anexara el usuario.

1
2
bash-4.1# groupadd nagcmd
bash-4.1# groupadd nagios

C. Creamos el usuario

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
bash-4.1# adduser

Login name for new user []: nagiosusr

User ID ('UID') [ defaults to next available ]:

Initial group [ users ]: nagcmd
Additional UNIX groups: nagios

Users can belong to additional UNIX groups on the system.
For local users using graphical desktop login managers such
as XDM/KDM, users may need to be members of additional groups
to access the full functionality of removable media devices.

* Security implications *
Please be aware that by adding users to additional groups may
potentially give access to the removable media of other users.

If you are creating a new user for remote shell access only,
users do not need to belong to any additional groups as standard,
so you may press ENTER at the next prompt.

Press ENTER to continue without adding any additional groups
Or press the UP arrow key to add/select/edit additional groups
:

Home directory [ /home/nagiosusr ]

Shell [ /bin/bash ]

Expiry date (YYYY-MM-DD) []:

New account will be created as follows:

---------------------------------------
Login name.......: nagiosusr
UID..............: [ Next available ]
Initial group....: nagcmd
Additional groups: [ nagios ]
Home directory...: /home/nagiosusr
Shell............: /bin/bash
Expiry date......: [ Never ]

This is it... if you want to bail out, hit Control-C. Otherwise, press
ENTER to go ahead and make the account.

Creating new account...

Changing the user information for nagiosusr
Enter the new value, or press ENTER for the default
Full Name []: Nagios User
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Changing password for nagiosusr
Enter the new password (minimum of 5 characters)
Please use a combination of upper and lower case letters and numbers.
New password:
Re-enter new password:
passwd: password changed.

Account setup complete.

D. Agregamos Al usuario apache al grupo de nagios
–Validamos los grupos —

1
2
bash-4.1# id apache
uid=80(apache) gid=80(apache) groups=80(apache)

— MOdificamos el usuario —

1
2
3
bash-4.1# usermod -G nagcmd, nagios apache

bash-4.1# id apache

— Validamos los grupos actuales —

1
uid=80(apache) gid=80(apache) groups=80(apache),1003(nagcmd)

— El usuario nagiosusr ya se encuentra en el grupo —

1
2
3
4
5
6
7
bash-4.1# id nagiosusr
uid=1005(nagiosusr) gid=1002(nagcmd) groups=1002(nagcmd)

bash-4.1# usermod -G nagios nagiosusr

bash-4.1# id nagiosusr
uid=1005(nagiosusr) gid=1002(nagcmd) groups=1002(nagcmd),1003(nagios)

2) Download Nagios and the Plugins

A. Obtenemos los archivos correspondientes de Nagios en el siguiente URL: http://www.nagios.org/download/
B. Ubicados en la carpeta de nuestra elección, descomprimimos los archivos de Nagios Core y los Plugins.

1
2
3
4
5
bash-4.1# pwd
/usr/src/nagios
bash-4.1# ls
README birdseye.zip check_mk-1.1.10p3.tar.gz cnagios-0.29.tar.gz cnagios.pl
nagios-3.2.3.tar.gz nagios-plugins-1.4.15.tar.gz nagiosInstallGuide_Me.txt nrpe-2.12.tar.gz

3) Compile and Install Nagios
A. Descomprimimos el archivo de nagios core.

1
bash-4.1# tar -zxvf nagios-3.2.3.tar.gz

B. Ingresamos al directorio

1
bash-4.1# cd nagios-3.2.3

C. Ejecutamos el script de configuracion (personalizamos el mismo de acuerdo a las caracteristicas de las
aplicaciones en nuestro slackware.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
bash-4.1# ./configure --prefix=/usr/nagios-3.2.3 \
--sysconfdir=/etc/nagios \
--localstatedir=/var/nagios \
--libdir=/usr/lib/nagios \
--disable-static \
--mandir=/usr/man \
--docdir=/usr/doc/nagios-3.2.3 \
--htmldir=/usr/doc/nagios-3.2.3/html \
--build=i686-slackware-linux \
--with-command-group=nagcmd \
--with-nagios-group=nagios \
--with-nagios-user=nagiosusr

...
Creating sample config files in sample-config/ ...

*** Configuration summary for nagios 3.2.3 10-03-2010 ***:

General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagcmd
Embedded Perl: no
Event Broker: yes
Install ${prefix}: /usr
Lock file: /var/nagios.lock
Check result directory: /var/spool/checkresults
Init directory: /etc/rc.d/init.d
Apache conf.d directory: /etc/httpd/conf.d
Mail program: /bin/mail
Host OS: linux-gnu

Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /usr/bin/traceroute

Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.

D. Realizamos la compilación.

1
bash-4.1# make all

E. Instalamos los binarios generados, archivos de configuración, y scripts de inicio.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
bash-4.1# make install
cd ./base && make install
make[1]: Entering directory `/usr/src/nagios/nagios-3.2.3/base'
make install-basic
make[2]: Entering directory `/usr/src/nagios/nagios-3.2.3/base'

/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /usr/nagios-3.2.3/bin
/bin/ginstall -c -m 774 -o nagiosusr -g nagios nagios /usr/nagios-3.2.3/bin
/bin/ginstall -c -m 774 -o nagiosusr -g nagios nagiostats /usr/nagios-3.2.3/bin
make[2]: Leaving directory `/usr/src/nagios/nagios-3.2.3/base'
make strip-post-install
make[2]: Entering directory `/usr/src/nagios/nagios-3.2.3/base'

/usr/bin/strip /usr/nagios-3.2.3/bin/nagios
/usr/bin/strip /usr/nagios-3.2.3/bin/nagiostats
make[2]: Leaving directory `/usr/src/nagios/nagios-3.2.3/base'
make[1]: Leaving directory `/usr/src/nagios/nagios-3.2.3/base'

cd ./cgi && make install
make[1]: Entering directory `/usr/src/nagios/nagios-3.2.3/cgi'
make install-basic
make[2]: Entering directory `/usr/src/nagios/nagios-3.2.3/cgi'

/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /usr/nagios-3.2.3/sbin
for file in *.cgi; do \
/bin/ginstall -c -m 775 -o nagiosusr -g nagios $file /usr/nagios-3.2.3/sbin; \
done
make[2]: Leaving directory `/usr/src/nagios/nagios-3.2.3/cgi'
make strip-post-install
make[2]: Entering directory `/usr/src/nagios/nagios-3.2.3/cgi'

for file in *.cgi; do \
/usr/bin/strip /usr/nagios-3.2.3/sbin/$file; \
done
make[2]: Leaving directory `/usr/src/nagios/nagios-3.2.3/cgi'
make[1]: Leaving directory `/usr/src/nagios/nagios-3.2.3/cgi'

cd ./html && make install
make[1]: Entering directory `/usr/src/nagios/nagios-3.2.3/html'
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /usr/nagios-3.2.3/share
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /usr/nagios-3.2.3/share/media
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /usr/nagios-3.2.3/share/stylesheets
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /usr/nagios-3.2.3/share/contexthelp
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /usr/nagios-3.2.3/share/docs
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /usr/nagios-3.2.3/share/docs/images
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /usr/nagios-3.2.3/share/images
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /usr/nagios-3.2.3/share/images/logos
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /usr/nagios-3.2.3/share/includes
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /usr/nagios-3.2.3/share/ssi
/bin/ginstall -c -m 664 -o nagiosusr -g nagios robots.txt /usr/nagios-3.2.3/share
/bin/ginstall -c -m 664 -o nagiosusr -g nagios docs/robots.txt /usr/nagios-3.2.3/share/docs
rm -f /usr/nagios-3.2.3/share/index.html
rm -f /usr/nagios-3.2.3/share/main.html
rm -f /usr/nagios-3.2.3/share/side.html
for file in *.php; \
do /bin/ginstall -c -m 664 -o nagiosusr -g nagios $file /usr/nagios-3.2.3/share; done
for file in stylesheets/*.css; \
do /bin/ginstall -c -m 664 -o nagiosusr -g nagios $file /usr/nagios-3.2.3/share/stylesheets; done
for file in contexthelp/*.html; \
do /bin/ginstall -c -m 664 -o nagiosusr -g nagios $file /usr/nagios-3.2.3/share/contexthelp; done
for file in docs/*.html; \
do /bin/ginstall -c -m 664 -o nagiosusr -g nagios $file /usr/nagios-3.2.3/share/docs; done
for file in docs/images/*.*; \
do /bin/ginstall -c -m 664 -o nagiosusr -g nagios $file /usr/nagios-3.2.3/share/docs/images; done
for file in images/*.gif; \
do /bin/ginstall -c -m 664 -o nagiosusr -g nagios $file /usr/nagios-3.2.3/share/images; done
for file in images/*.jpg; \
do /bin/ginstall -c -m 664 -o nagiosusr -g nagios $file /usr/nagios-3.2.3/share/images; done
for file in images/*.png; \
do /bin/ginstall -c -m 664 -o nagiosusr -g nagios $file /usr/nagios-3.2.3/share/images; done
for file in images/*.ico; \
do /bin/ginstall -c -m 664 -o nagiosusr -g nagios $file /usr/nagios-3.2.3/share/images; done
for file in images/logos/*.*; \
do /bin/ginstall -c -m 664 -o nagiosusr -g nagios $file /usr/nagios-3.2.3/share/images/logos; done
for file in includes/*.*; \
do /bin/ginstall -c -m 664 -o nagiosusr -g nagios $file /usr/nagios-3.2.3/share/includes; done
make[1]: Leaving directory `/usr/src/nagios/nagios-3.2.3/html'

make install-basic
make[1]: Entering directory `/usr/src/nagios/nagios-3.2.3'
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /usr/nagios-3.2.3/libexec
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /var/nagios
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /var/nagios/archives
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /var/nagios/spool/checkresults
if [ no = yes ]; then \
/bin/ginstall -c -m 664 -o nagiosusr -g nagios p1.pl /usr/nagios-3.2.3/bin; \
fi;

*** Main program, CGIs and HTML files installed ***

You can continue with installing Nagios as follows (type '
make'
without any arguments for a list of all possible options):

make install-init
- This installs the init script in /etc/rc.d/init.d

make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file

make install-config
- This installs sample config files in /etc/nagios

make[1]: Leaving directory `/usr/src/nagios/nagios-3.2.3'


...
bash-4.1# make install-init

/bin/ginstall -c -m 755 -d -o root -g root /etc/rc.d/init.d
/bin/ginstall -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios

*** Init script installed ***

bash-4.1# make install-commandmode

/bin/ginstall -c -m 775 -o nagiosusr -g nagcmd -d /var/nagios/rw
chmod g+s /var/nagios/rw

*** External command directory configured ***

bash-4.1# make install-config
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /etc/nagios
/bin/ginstall -c -m 775 -o nagiosusr -g nagios -d /etc/nagios/objects
/bin/ginstall -c -b -m 664 -o nagiosusr -g nagios sample-config/nagios.cfg /etc/nagios/nagios.cfg
/bin/ginstall -c -b -m 664 -o nagiosusr -g nagios sample-config/cgi.cfg /etc/nagios/cgi.cfg
/bin/ginstall -c -b -m 660 -o nagiosusr -g nagios sample-config/resource.cfg /etc/nagios/resource.cfg
/bin/ginstall -c -b -m 664 -o nagiosusr -g nagios sample-config/template-object/templates.cfg /etc/nagios/objects/templates.cfg
/bin/ginstall -c -b -m 664 -o nagiosusr -g nagios sample-config/template-object/commands.cfg /etc/nagios/objects/commands.cfg
/bin/ginstall -c -b -m 664 -o nagiosusr -g nagios sample-config/template-object/contacts.cfg /etc/nagios/objects/contacts.cfg
/bin/ginstall -c -b -m 664 -o nagiosusr -g nagios sample-config/template-object/timeperiods.cfg /etc/nagios/objects/timeperiods.cfg
/bin/ginstall -c -b -m 664 -o nagiosusr -g nagios sample-config/template-object/localhost.cfg /etc/nagios/objects/localhost.cfg
/bin/ginstall -c -b -m 664 -o nagiosusr -g nagios sample-config/template-object/windows.cfg /etc/nagios/objects/windows.cfg
/bin/ginstall -c -b -m 664 -o nagiosusr -g nagios sample-config/template-object/printer.cfg /etc/nagios/objects/printer.cfg
/bin/ginstall -c -b -m 664 -o nagiosusr -g nagios sample-config/template-object/switch.cfg /etc/nagios/objects/switch.cfg

*** Config files installed ***

Remember, these are *SAMPLE* config files. You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.

De acuerdo a la Guia que leí de Fedora, aun no se puede correr ya que se requieren pasos adicionales.
Por lo que continuando.

4) Customize Configuration

Modificamos el archivo contacts.cfg que se encuentra en la ruta /etc definida anteriormente en nuestro paso 3C. Y agregamos
nuestra direccion de correo.

1
2
3
4
5
6
bash-4.1# vi /etc/objects/contacts.cfg

define contact{
....
email mi_correo@miserver ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}

5) Configure the Web Interface
A. Instalamos los archivos de configuracion web de Nagios para apache.

1
2
3
4
bash-4.1# make install-webconf
/bin/ginstall -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
/bin/ginstall: cannot create regular file `/etc/httpd/conf.d/nagios.conf': No such file or directory
make: *** [install-webconf] Error 1

B. Dado que nuestro apache en Slack tiene las configuraciones directamente en la carpeta /etc/httpd, realizaremos
la copia del archivo manualmente.

1
bash-4.1# /bin/ginstall -c -m 644 sample-config/httpd.conf /etc/httpd/nagios.conf

C. Modificamos el archivo nagios.conf para que la configuracion de nuestro apache continue dentro del
directorio /etc/httpd de la siguiente manera.

1
AuthUserFile /etc/httpd/htpasswd.users

D. Modificamos la siguiente linea de comando htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin quedando
de la siguiente manera: htpasswd -c /etc/httpd/htpasswd.users nagiosadmin, ejecutamos.

1
2
3
4
bash-4.1# htpasswd -c /etc/httpd/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

E. En caso de tener el apache iniciado, habra que reiniciarlo, en otro caso, iniciarlo.

6) Compile and Install the Nagios Plugins

A. Extraemos el comprimido de los plugins e ingresamos a el.

1
2
bash-4.1# tar -zxvf nagios-plugins-1.4.15.tar.gz
bash-4.1# cd nagios-plugins-1.4.15/

B. Ejecutamos el script de configuracion de la misma manera que el core.

1
2
3
4
5
6
7
8
9
10
11
12
./configure --prefix=/usr/nagios-plugins-1.4.15 \
--sysconfdir=/etc/nagios-plugins \
--localstatedir=/var \
--libdir=/usr/lib/nagios-plugins \
--disable-static \
--mandir=/usr/man \
--docdir=/usr/doc/nagios-plugins-1.4.15 \
--htmldir=/usr/doc/nagios-plugins-1.4.15/html \
--build=i686-slackware-linux \
--with-command-group=nagcmd \
--with-nagios-group=nagios \
--with-nagios-user=nagiosusr

C. Compilamos.

1
bash-4.1# make

D. Instalamos

1
bash-4.1# make install

E. Actualizamos librerias y ejecutamos un updatedb

1
2
bash-4.1# ldconfig
bash-4.1# updatedb

7) Start Nagios

A. Verificamos una configuracion simple de Nagios

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
bash-4.1# /usr/bin/nagios -v /etc/nagios.cfg

Nagios Core 3.2.3
Copyright (c) 2009-2010 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 10-03-2010
License: GPL

Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/etc/objects/commands.cfg'...
Processing object config file '/etc/objects/contacts.cfg'...
Processing object config file '/etc/objects/timeperiods.cfg'...
Processing object config file '/etc/objects/templates.cfg'...
Processing object config file '/etc/objects/localhost.cfg'...
Read object config files okay...

Running pre-flight check on configuration data...

Checking services...
Checked 8 services.
Checking hosts...
Checked 1 hosts.
Checking host groups...
Checked 1 host groups.
Checking service groups...
Checked 0 service groups.
Checking contacts...
Checked 1 contacts.
Checking contact groups...
Checked 1 contact groups.
Checking service escalations...
Checked 0 service escalations.
Checking service dependencies...
Checked 0 service dependencies.
Checking host escalations...
Checked 0 host escalations.
Checking host dependencies...
Checked 0 host dependencies.
Checking commands...
Checked 24 commands.
Checking time periods...
Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check

B. Si no presenta errores, podemos iniciar nagios.
C. Al iniciar nagios obtenemos el siguiente error,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
bash-4.1# nagios start -v

Nagios Core 3.2.3
Copyright (c) 2009-2010 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 10-03-2010
License: GPL

Website: http://www.nagios.org
Error: Cannot open main configuration file '/root/start' for reading!
Warning: Cannot open log file '/var/nagios.log' for writing
Nagios 3.2.3 starting... (PID=9240)
Warning: Cannot open log file '/var/nagios.log' for writing
Local time is Sat Jul 02 18:41:52 CDT 2011
Warning: Cannot open log file '/var/nagios.log' for writing
Warning: Cannot open log file '/var/nagios.log' for writing
Bailing out due to one or more errors encountered in the configuration files. Run Nagios from the command line with the -v option to verify your config before restarting. (PID=9240)

log_file=/var/log/nagios.log

nagiosusr@devlnxMob:~$ /etc/init.d/nagios start
Starting nagios:Password:
touch: cannot touch `/var/log/nagios.log': Permission denied
touch: no se puede efectuar `touch'
sobre «/var/lock/subsys/nagios»: Permiso denegado
done.

Verificamos que todas las carpetas y archivos cuenten con los permisos necesarios para el usuario nagiosusr

D. Personalizar el archivo /etc/init.d/nagios de manera que los archivos se correspondan con el tipo
de proceso o informacion.

Ejecución.

A. Ejecutamos el binario de nagios:

1
nagiosusr@devlnxMob:~$ /etc/init.d/nagios start

El siguiente paso es adicional y corresponde exclusivamente a nuestra configuración de slackware.

1. Agregar el virtual host de nagios al httpd.conf.

1
2
#Linea adicional para la configuracion de nagios
Include /etc/httpd/nagios.conf

URLs:

Dejar un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *