These steps were performed on a Nagios Core 4.0.x host running on CentOS 6.5 as per this guide. NOTE: If you want to receive NSCA checks from NSClient++ 0.3.9 and below you MUST use NSCA version 2.7.2.
Install NSCA- Establish an ssh session as the user root
- Type yum -y install gcc xinetd and press Enter
- Wait while the components are downloaded/updated
- Type cd /tmp and press Enter
- NSCA Version 2.7.2:
- Type wget http://downloads.sourceforge.net/project/nagios/nsca-2.x/nsca-2.7.2/nsca-2.7.2.tar.gz and press Enter
- Type tar xzf nsca-2.7.2.tar.gz and press Enter
- Type cd nsca-2.7.2 and press Enter
- NSCA Version 2.9.1:
- Type wget http://prdownloads.sourceforge.net/sourceforge/nagios/nsca-2.9.1.tar.gz and press Enter
- Type tar xzf nsca-2.9.1.tar.gz and press Enter
- Type cd nsca-2.9.1 and press Enter
- Type ./configure and press Enter
- Type make all and press Enter
- Type cp src/nsca /usr/local/nagios/bin and press Enter
- Type cp sample-config/nsca.cfg /usr/local/nagios/etc and press Enter
- Type chown nagios.nagcmd /usr/local/nagios/etc/nsca.cfg and press Enter
- Type chmod g+r /usr/local/nagios/etc/nsca.cfg and press Enter
- Type cp src/send_nsca /usr/local/nagios/libexec and press Enter
- Type cp sample-config/send_nsca.cfg /usr/local/nagios/etc and press Enter
- Type cp sample-config/nsca.xinetd /etc/xinetd.d/nsca and press Enter
- Type echo 'nsca 5667/tcp #NSCA' >> /etc/services and press Enter
- Type iptables -I INPUT -p tcp --destination-port 5667 -j ACCEPT and press Enter
- Type service iptables save and press Enter
- Type chkconfig xinetd on and press Enter
Configure NSCABefore 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 and press Enter
- A password needs to be defined that the sending clients use
- Change:
- To:
- 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
- Press Ctrl + x
- Type Y
- Press Enter to save changes
These are the service settings:
- Type nano /etc/xinetd.d/nsca and press Enter
- You need to allow what hosts can submit results
- This can be an IP Address:
- In my scenario I'm allowing the localhost AND a subnet
- Change:
- 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 and press Enter
Test NSCAA 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 and press Enter
- A password needs to be defined that the sending clients use
- Change:
- To:
- 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
- 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 and press Enter
- Type localhost
- Press TAB
- Type Test Result
- Press TAB
- Type 1
- Press TAB
- 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 and press Enter
- 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
SummaryAt this point NSCA is now installed and configured. Debug Logging
Sometimes things go wrong and you need to enable debug logging to see what is happening. - Type nano /usr/local/nagios/etc/nsca.cfg and press Enter
- Change:
- To:
- Press Ctrl + x
- Type Y
- Press Enter to save changes
- Type nano /etc/rsyslog.conf and press Enter
- Find:
- *.info;mail.none;authpriv.none;cron.none /var/log/messages
- Change to:
- *.info;mail.none;authpriv.none;cron.none;daemon.debug /var/log/messages
- Press Ctrl + x
- Type Y
- Press Enter to save changes
- Type service rsyslog restart and press Enter
- Type service xinetd restart and press Enter
Now you can watch the debug information by running this command: - Type tail -f /var/log/messages | grep nsca and press Enter
|
|