Nagios Installation on Cpanel Server

Ideal place for discussions related to Linux/Windows server security, Apache, MySQL, MS SQL and PHP, including tutorials and questions.
hr-ethadmin
Site Admin
Posts: 67
Joined: Fri May 31, 2013 1:04 pm

Nagios Installation on Cpanel Server

Postby hr-ethadmin » Sat Jun 01, 2013 1:45 am

Nagios: It is the perfect monitoring tool. It helps to monitor hosts, services, applications and many more things.

1) For monitoring server(Who will monitor others) : a)nagios b) nagios-plugin c) nrpe daemon
2) For monitored remote server(who will be monitored) : a) nagios-plugin c) nrpe daemon
3) Configuring monitoring server to monitor remote hosts.

On cpanel server required modules are might be already installed. If not then using easyapache you can install it.

1. Installation and configuration of tools on monitoring nagios server( who will monitor others) : a)nagios b) nagios-plugin c) nrpe daemon

A)nagios :-

------------------
1. SSh to server
2. useradd nagios
3. passwd nagios
4. groupadd nagcmd
5. /usr/sbin/usermod -a -G nagcmd nagios
6. /usr/sbin/usermod -a -G nagcmd nobody

To find Apache user : grep '^User' /usr/local/apache/conf/httpd.conf

7. cd /usr/local/src/
8. wget http://prdownloads.sourceforge.net/sour ... 5.0.tar.gz
9. tar -xvzf nagios-3.5.0.tar.gz
10. cd nagios-*
11. ./configure --with-command-group=nagcmd
12. make all
13. make install
14. make install-init
15. make install-config
16. make install-commandmode
17. make install-webconf
18. htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

B) nagios-plugin installation :

1. cd /usr/local/src/
2. wget http://prdownloads.sourceforge.net/sour ... .16.tar.gz
3. tar -xvzf nagios-plugins-1.4.16.tar.gz
4. cd nagios-plugins-*
5. ./configure --with-nagios-user=nagios --with-nagio-group=nagios
6. make
7. make install
8. chkconfig --add nagios
9. chkconfig nagios on
10. chown nagios.nagios /usr/local/nagios
11. chown -R nagios.nagios /usr/local/nagios/libexec
12. /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

c) nrpe daemon installation:
1. cd /usr/local/src/
2. wget http://downloads.sourceforge.net/projec ... .14.tar.gz
3. tar -xvzf nrpe-2.14.tar.gz
4. cd nrpe-*
5. ./configure
6. make all
7. make install-plugin
8. make install-daemon
9. make install-daemon-config
10. make install-xinetd
11. vi /etc/xinetd.d/nrpe
12. echo "nrpe 5666/tcp # NRPE" >> /etc/services
13. Make it sure that you have opened the above port at the firewall.
14. chkconfig xinetd on
15. service xinetd restart
16. Service nagios restart
17. /usr/local/nagios/libexec/check_nrpe -H localhost

C) Configuring monitoring server to monitor remote hosts

1. Create a command definition: /usr/local/nagios/etc/commands.cfg

and add following entries in that file :
---
root@server [/usr/local/nagios/etc/objects]# cat /usr/local/nagios/etc/commands.cfg
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

root@server [/usr/local/nagios/etc/objects]
---

2. chown nagios. /usr/local/nagios/etc/commands.cfg
3. create the file /usr/local/nagios/etc/objects/linux-box-remote.cfg and add
following entries in that file.

........
root@server [/usr/local/nagios/etc/objects]# cat /usr/local/nagios/etc/objects/linux-box-remote.cfg
define host{
name linux-box-remote ; Name of this
template
use generic-host ; Inherit default values
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups admins
register 0 ; DONT REGISTER THIS - ITS A
TEMPLATE

root@server [/usr/local/nagios/etc/objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Make sure warning and error are zero.
....

7. service nagios restart
8. You can add multiple remote host in the linux-box-remote.cfg file. Just add another entry like second defined "host" to last one(only you have to change the hostname and services those you want to monitor).

Thats all my friends. Try it now.

Return to “System Security”

Who is online

Users browsing this forum: No registered users and 1 guest