Permissions for /usr/local/nagios/var/rw/nagios.cmd:

Prepare the system


Networking must be set up correctly (/etc/hosts, /etc/resolv.conf etc.)

Apache should be installed and working.


yum update
yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp ntp sudo
yum install -y mailx cpan openssl-devel

Start NTP

It's important that all servers show the correct time:

service ntpd start
chkconfig ntpd on

If the system is running on a virtual machine, NTP may fail with the following error message in /var/log/messages:

cap_set_proc() failed to drop root privileges: Operation not permitted

See here how to handle this problem.

Perl and Perl plug-ins

The minimum requirements are Perl, CPAN, and the Net::SMPP module:

yum install perl cpan
install Net::SMPP

As an option, you might want to install YAML and upgrade all packages to their latest version - this is a very time-consuming process!

install YAML
install CPAN
reload CPAN

Add users and groups

useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -G nagcmd apache

Download and install Nagios

Download Nagios

Check the websites below for the latest versions.

cd /tmp
tar zxvf nagios-3.5.0.tar.gz
tar zxvf nagios-plugins-1.4.16.tar.gz
tar zxvf nrpe-2.14.tar.gz

Install Nagios

cd /tmp/nagios
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

In the next statement you will create a NAgios administrator for the web interface. Feel free to use another user name instead of "nagiosadmin".

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
-> set password


The next two steps are only required with SELinux:

chcon -R -t httpd_sys_content_t /usr/local/nagios
chcon -R -t httpd_sys_script_rw_t /usr/local/nagios/var/rw

chown nagios:nagcmd /usr/local/nagios/var/rw
chown nagios:nagcmd /usr/local/nagios/var/rw/nagios.cmd
chmod -R ug+rwx /usr/local/nagios/var/rw
chmod -R g+s /usr/local/nagios/var/rw/
chkconfig --add nagios
chkconfig --level 35 nagios on
chkconfig --add httpd
chkconfig --level 35 httpd on

Make sure that http://localhost/index.html is reachable:

touch /var/www/html/index.html

Install Nagios Plugins

cd /tmp/nagios-plugins-*
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make install

Install NRPE plugin

cd /tmp/nrpe-*
make all
make install-plugin

Install and configure

cd /usr/local/nagios/libexec/
wget -O
chmod 755 /usr/local/nagios/libexec/

In, you have to enter the credentials and other information for your SMS gateway.

vi /usr/local/nagios/libexec/
$sysid = "the_user_id_of_your_sms_gateway_provider";
$pw = "the_password_for_this_user_id";
$host = 'the_IP_address_of_the_SMS_gateway';
$port = 4999; ### or whichever port your SMS gateway provider gave you

If you want to receive only the first part of multipart SMS message, I suggest to apply the following modifications to

1. Declaration area:

$send_multimsg = 0;

2. Near the end, between "$multimsg_curpart++;" and "$ref++;":

Changes to
    if ($send_multimsg) {
        $msgtext = substr ($mymsg, 0, 120, "");
    } else {
        $msgtext = "";
    } - Host not available

The download site seems to be unavailable at times. If this is the case, you may use the file attached below.

For credentials, copyright and other details see:

Alternative download link:

Commands for alternative download location:
cd /usr/local/nagios/libexec/
chmod 755 /usr/local/nagios/libexec/

Startup Nagios

service nagios restart
service httpd graceful

Test Nagios

Point your browser to http://your-nagios.domain.tld/nagios

Username and password are the ones you set above.



  • No labels