Overview
This guide will show you how to install NSCA on a Nagios Core 4.0.x host running on CentOS 6.5.
At the end of this guide, Nagios will be listening for check results submitted from external hosts.
Install NSCA
Establish an ssh session to your Nagios host as the user root
Type:
yum -y install gcc xinetd
Wait while the components are downloaded/updated
Type:
cd /tmp
Type:
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nsca-2.9.1.tar.gz
Wait while the file is downloaded
Type:
tar xzf nsca-2.9.1.tar.gz
Type:
cd nsca-2.9.1
Type:
./configure
Wait while the "configure" procedure is run
Type:
make all
Wait while the "make all" procedure is run
Type:
cp src/nsca /usr/local/nagios/bin
Type:
cp sample-config/nsca.cfg /usr/local/nagios/etc
Type:
chown nagios.nagcmd /usr/local/nagios/etc/nsca.cfg
Type:
chmod g+r /usr/local/nagios/etc/nsca.cfg
Type:
cp src/send_nsca /usr/local/nagios/libexec
Type:
cp sample-config/send_nsca.cfg /usr/local/nagios/etc
Type:
cp sample-config/nsca.xinetd /etc/xinetd.d/nsca
The following three commands allow inbound TCP traffic on port 5667.
Type:
echo 'nsca 5667/tcp #NSCA' >> /etc/services
Type:
iptables -I INPUT -p tcp --destination-port 5667 -j ACCEPT
Type:
service iptables save
Type:
chkconfig xinetd on
At this point NSCA is installed, but still needs to be configured.
Configure NSCA
Before we can start the NSCA service we need to define some configuration settings.
These are the security settings:
Type:
nano /usr/local/nagios/etc/nsca.cfg
A password needs to be defined that the sending clients use
Change:
#password=
To:
password=Passw0rd
That's a pretty basic password, you should pick something better!
A decryption method also needs to be defined, however the default is 1 (Simple XOR) and we'll leave it at that for the moment
decryption_method=1
Press Ctrl + X
Type:
Y
Press Enter to save changes
These are the service settings:
Type:
nano /etc/xinetd.d/nsca
You need to allow what hosts can submit results.
This can be an IP Address:
10.25.254.16
It it could be a Subnet:
10.25.0.0/16
In my scenario I'm allowing the localhost AND a subnet.
Change:
only_from = 127.0.0.1
To:
only_from = 127.0.0.1 10.25.0.0/16
Press Ctrl + X
Type:
Y
Press Enter to save changes
Start NSCA
Type:
service xinetd start
Test NSCA
A simple NSCA client is also installed as part of NSCA so we can do a simple test to ensue it works. First it needs configuring:
Type:
nano /usr/local/nagios/etc/send_nsca.cfg
A password needs to be defined that the sending clients use
Change:
#password=
To:
password=Passw0rd
That's a pretty basic password, you should pick something better!
A encryption method also needs to be defined, however the default is 1 (Simple XOR) and we'll leave it at that for the moment
encryption_method=1
Press Ctrl + X
Type:
Y
Press Enter to save changes
Now we are going to create a simple check result in a file
Type:
nano /tmp/nsca_test
Type:
localhost
Press TAB key
Type:
Test Result
Press TAB key
Type:
1
Press TAB key
Type:
This is the test result with a WARNING status
NOTE: Those are tabs separating the fields, what you typed is:
localhost[TAB]Test Service[TAB]1[TAB]This is the test result with a WARNING status
Press Ctrl + X
Type:
Y
Press Enter to save changes
Now we are going to submit that simple check result
Type:
/usr/local/nagios/libexec/send_nsca -H 127.0.0.1 -p 5667 -c /usr/local/nagios/etc/send_nsca.cfg < /tmp/nsca_test
You should receive a response like:
1 data packet(s) sent to host successfully.
In addition to this, you will see the passive check result in the nagios log:
[1419031130] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;localhost;Test Service;1;This is the test result with a WARNING status
[1419031130] Warning: Passive check result was received for service 'Test Service' on host 'localhost', but the service could not be found!
[1419031130] Error: External command failed -> PROCESS_SERVICE_CHECK_RESULT;localhost;Test Service;1;This is the test result with a WARNING status
[1419031130] External command error: Command failed
The errors are simply because there is no passive service called "Test Service" for the host localhost, this is expected.
Summary
At this point NSCA is now installed and configured. In the example above, it will accept checks from 127.0.0.1 AND the subnet 10.25.0.0/16.
Final Thoughts
For any support related questions please visit the Nagios Support Forums at: