References

Nagios: http://assets.nagios.com/downloads/nagioscore/docs/Installing_Nagios_Core_From_Source.pdf

sendmessage.pl: http://exchange.nagios.org/directory/Addons/Notifications/SMS/nagios_csmpp/details

Permissions for /usr/local/nagios/var/rw/nagios.cmd: http://linux.101hacks.com/unix/nagios-cmd-file-error/

Prepare the system

Prerequisites

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

Apache should be installed and working.

Packages

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
cpan
install Net::SMPP
exit

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

cpan
install YAML
install CPAN
reload CPAN
upgrade
exit

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
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.5.0.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz
wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz
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
make install

Install NRPE plugin

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

Install and configure sendmessage.pl

cd /usr/local/nagios/libexec/
wget http://www.ghevondyan.net/Download/sendmessage.pl.txt -O sendmessage.pl
chmod 755 /usr/local/nagios/libexec/sendmessage.pl

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

vi /usr/local/nagios/libexec/sendmessage.pl
...
$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 sendmessage.pl:

1. Declaration area:

$send_multimsg = 0;

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

Changes to sendmessage.pl
    if ($send_multimsg) {
        $msgtext = substr ($mymsg, 0, 120, "");
    } else {
        $msgtext = "";
    }

sendmessage.pl - 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: http://exchange.nagios.org/directory/Addons/Notifications/SMS/nagios_csmpp/details.

Alternative download link: sendmessage.pl

Commands for alternative download location:
 
cd /usr/local/nagios/libexec/
wget https://wiki.gutzmann.com/confluence/download/attachments/12681239/sendmessage.pl
chmod 755 /usr/local/nagios/libexec/sendmessage.pl

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