Passive Alerts With NSCA not working

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
cybergene
Posts: 92
Joined: Wed Aug 10, 2016 7:38 am
Location: Ottawa, Ontario, Canada

Passive Alerts With NSCA not working

Post by cybergene »

Hi,

I have Nagios Core4.3.4 installed on and everything works fine. I want to monitor few remote servers with NSCA since I can't use NRPE to poll into those servers.

I installed NSCA from this https://support.nagios.com/kb/article/n ... -x-79.html

When I testing local on Core (Where NSCA is installed) it works fine:

Code: Select all

/usr/local/nagios/libexec$ ./send_nsca -H localhost  -p 5667 -c /usr/local/nagios/etc/send_nsca.cfg < ./test_nsca
The results are:

Code: Select all

nsca[2118]: Handling the connection...
nsca[2118]: Time difference in packet: 0 seconds for host hanjin
nsca[2118]: SERVICE CHECK -> Host Name: 'hanjin', Service Description: 'OS Version', Return Code: '1', Output: 'This is the test result with a WARNING status.'
nsca[2118]: Attempting to write to nagios command pipe
nsca[2118]: End of connection...
nagios: EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;hanjin;OS Version;1;This is the test result with a WARNING status.
nagios: PASSIVE SERVICE CHECK: hanjin;OS Version;1;This is the test result with a WARNING status.
nagios: SERVICE ALERT: hanjin;OS Version;WARNING;HARD;1;This is the test result with a WARNING status.
and the Service Status changed to WARNING

Running this command from the remote host doesn't change the status of the service on Nagios Core:

Code: Select all

/usr/local/nagios/libexec$ ./send_nsca hanjin -c /usr/local/nagios/etc/send_nsca.cfg < /tmp/nsca_test
nsca_test content:

Code: Select all

/usr/local/nagios/libexec$ ./send_nsca hanjin -c /usr/local/nagios/etc/send_nsca.cfg < /tmp/nsca_test
Syslog:

Code: Select all

Dec 12 10:02:15 hanjin nsca[3153]: Handling the connection...
Dec 12 10:02:16 hanjin nsca[3153]: Time difference in packet: 0 seconds for host hanjin
Dec 12 10:02:16 hanjin nsca[3153]: SERVICE CHECK -> Host Name: 'hanjin', Service Description: 'CPU Load', Return Code: '1', Output: 'This is the test result with a WARNING status.'
Dec 12 10:02:16 hanjin nsca[3153]: Attempting to write to nagios command pipe
Dec 12 10:02:16 hanjin nsca[3153]: Command file '/usr/local/nagios/var/rw/nagios.cmd' does not exist, attempting to use alternate dump file '/usr/local/nagios/var/rw/nsca.dump' for output
Dec 12 10:02:16 hanjin nsca[3153]: Could not open alternate dump file '/usr/local/nagios/var/rw/nsca.dump' for appending
Dec 12 10:02:16 hanjin nsca[3153]: End of connection...
Is the dump file required on the remote host?

Code: Select all

Could not open alternate dump file '/usr/local/nagios/var/rw/nsca.dump' for appending
Any help is appreciated!

Thanks.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Passive Alerts With NSCA not working

Post by npolovenko »

Hello, @cybergene. I'd check the /etc/xinetd.d/nsca and make sure that you added the client's Ip address to the allowed hosts. And all IP's should be separated by space, no commas. Also, when you run this command:

Code: Select all

 ./send_nsca hanjin -c /usr/local/nagios/etc/send_nsca.cfg < /tmp/nsca_test
After that please run: service xinetd start.
The hostname should start with -H:

Code: Select all

./send_nsca -H hanjin -c /usr/local/nagios/etc/send_nsca.cfg < /tmp/nsca_test
Preferably if you used the IP address instead of a hostname.
Btw, for the client's server check out this wrapper:
https://exchange.nagios.org/directory/A ... er/details


I'd also like to highly recommend to use NCPA on the client server, and NRDP on the Nagios Core Server, instead of NSCA. These two agents are more maintained at this point in time.

1. Here's the instruction on how to install NRDP on Nagios Core. https://support.nagios.com/kb/article/n ... e-602.html
Don't forget to test it after the installation.

2. Here's the guide to install NCPA on a Linux or a Windows Server. https://assets.nagios.com/downloads/ncp ... g_NCPA.pdf

3. And this tutorial actually explains how to send passive checks with NRDP within NCPA:
https://assets.nagios.com/downloads/ncp ... gJ8dPD_BwE

This may sound confusing at this point but i'll be glad to assist with questions as you go.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
cybergene
Posts: 92
Joined: Wed Aug 10, 2016 7:38 am
Location: Ottawa, Ontario, Canada

Re: Passive Alerts With NSCA not working

Post by cybergene »

Hi @ npolovenko,

Thanks for the reply and the suggestions. Since NRDP is NCPA are more maintained, I would go with them. I tried the instructions you provided:

1. Here's the instruction on how to install NRDP on Nagios Core.https://support.nagios.com/kb/article/n ... e-602.html

So I installed NRDP on the same server where Nagios Core is installed and tried launching it in the web http://xx.xx.x.xxx/nrdp/ and I can't reach the page.

I'm following these instructions https://support.nagios.com/kb/article/n ... .html#TEST, restarted apache2 and Nagios.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Passive Alerts With NSCA not working

Post by npolovenko »

@cybergene, What Linux OS are you using? I recommend to run all the commands one more time and try to keep an eye on any errors. Are you still able to access Nagios core web interface?
*I just installed nrdp on top of the Core running on CentOS 6. So once I know your OS version I'll attempt to run the same installation to see if I come across this kind of error.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
cybergene
Posts: 92
Joined: Wed Aug 10, 2016 7:38 am
Location: Ottawa, Ontario, Canada

Re: Passive Alerts With NSCA not working

Post by cybergene »

Hi @npolovenko,

I still have access to Nagios Core Ui and it wasn't affected by running the commands for NRDP.

nagios Core system is:

Code: Select all

Description:    Ubuntu 16.04.3 LTS
Release:        16.04
Codename:       xenial
I did a re-run of the commands on my system and it seems to work, I can see the NRDP UI and ran a couple tests.

Proceeding with the installation, I set up NCPA on a remote host and was able to log into the NCPA UI too (on the remote host).
In the UI, I'm sure how to set-up the communication between the NCPA and NDRP. I attached a screenshot of what I see in the UI.

Is there any instructions for NCPA to work with Nagios Core? I don't think this would work in Core (https://assets.nagios.com/downloads/nag ... ios-XI.pdf)
Attachments
Screenshot_33.png
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Passive Alerts With NSCA not working

Post by npolovenko »

@cybergene, Your next step would be to use this tutorial to configure the NCPA to send passive to the Nagios Server: https://assets.nagios.com/downloads/ncp ... gJ8dPD_BwE


Next, you'd need to go inside the Nagios Core, and open the following log file:/usr/local/nagios/var/nagios.log. You should see something similar to this:

Code: Select all

[1508380204] Error: Got host checkresult for 'S1601', but no such host can be found
[1508380204] Error: Got check result for service 'CPU Usage' on host 'S1601'. Unable to find service
[1508380204] Error: Got check result for service 'Disk Usage' on host 'S1601'. Unable to find service
[1508380204] Error: Got check result for service 'Swap Usage' on host 'S1601'. Unable to find service
[1508380204] Error: Got check result for service 'Memory Usage' on host 'S1601'. Unable to find service
[1508380204] Error: Got check result for service 'Process Count' on host 'S1601'. Unable to find service
[1508380204] Error: Got check result for service 'Disk Usage E' on host 'S1601'. Unable to find service
If you do see that, great! You can move on to the final step and create the service definitions: https://support.nagios.com/kb/article/n ... s-762.html

Let me know how it goes.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
cybergene
Posts: 92
Joined: Wed Aug 10, 2016 7:38 am
Location: Ottawa, Ontario, Canada

Re: Passive Alerts With NSCA not working

Post by cybergene »

Hi @npolovenko,

I did the steps in the manuals and now I have the config on Nagios and the remote host.
I don't see any errors in the log file. Maybe because I already added the hostname and the services that matches with the remote host?

Since yesterday, I haven't seen any changes in the status of any of the service on that server except the ones I was testing.

I'm going to check the config again maybe I missed something. I'm wondering if there a way to do a test from the remote host , like we do for the Active checks...

Noticed this error in the

Code: Select all

/usr/local/ncpa/var/log/ncpa_passive.log

2017-12-22 11:15:38,930 18763 ERROR no element found: line 1, column 0
Traceback (most recent call last):
  File "ncpa_passive.py", line 45, in run_all_handlers
  File "/root/ncpa/agent/passive/nrdp.py", line 124, in run
  File "/root/ncpa/agent/passive/nrdp.py", line 179, in submit_to_nagios
  File "/root/ncpa/agent/passive/nrdp.py", line 145, in log_result
  File "/usr/local/lib/python2.7/xml/dom/minidom.py", line 1928, in parseString
  File "/usr/local/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString
  File "/usr/local/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString
ExpatError: no element found: line 1, column 0

npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Passive Alerts With NSCA not working

Post by npolovenko »

@cybergene,
I don't see any errors in the log file. Maybe because I already added the hostname and the services that matches with the remote host?
Did you use this tutorial to add a host and services definitions?If not I'd like to see how you defined them.

Code: Select all

https://support.nagios.com/kb/article/nrdp-passive-host-and-service-definitions-762.html
If you added definitions correctly then yeah, you wouldn't see errors in the nagios.log file. But when you click on defined service checks in Core web interface, is the last update time changing at all?
Also, on windows computer you may check out the log file for NRDP:

Code: Select all

C://Program Files x86/Nagios/NCPA/var/log/win32service_ncpapassive.log 
Attachments
screenshot-192.168.4.172-2017-12-22-10-10-21-710.png
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Passive Alerts With NSCA not working

Post by npolovenko »

@cybergene
usr/local/ncpa/var/log/ncpa_passive.log

2017-12-22 11:15:38,930 18763 ERROR no element found: line 1, column 0
Traceback (most recent call last):
File "ncpa_passive.py", line 45, in run_all_handlers
File "/root/ncpa/agent/passive/nrdp.py", line 124, in run
File "/root/ncpa/agent/passive/nrdp.py", line 179, in submit_to_nagios
File "/root/ncpa/agent/passive/nrdp.py", line 145, in log_result
File "/usr/local/lib/python2.7/xml/dom/minidom.py", line 1928, in parseString
File "/usr/local/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString
File "/usr/local/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString
ExpatError: no element found: line 1, column 0
Please run the following command:

Code: Select all

sudo sed -i 's/<\/Directory>/Require all granted\n&/' /etc/apache2/sites-enabled/nrdp.conf
And then restart the apache service:

Code: Select all

sudo systemctl restart apache2.service
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
cybergene
Posts: 92
Joined: Wed Aug 10, 2016 7:38 am
Location: Ottawa, Ontario, Canada

Re: Passive Alerts With NSCA not working

Post by cybergene »

Thanks for the help @npolovenko
npolovenko wrote:@cybergene,
Did you use this tutorial to add a host and services definitions?If not I'd like to see how you defined them.

Code: Select all

https://support.nagios.com/kb/article/nrdp-passive-host-and-service-definitions-762.html
Yes, and it is exactly as the tutorial.

If you added definitions correctly then yeah, you wouldn't see errors in the nagios.log file. But when you click on defined service checks in Core web interface, is the last update time changing at all?
No,no change at all since I set-up the server, check the attached screenshots. The colors are from manual tests.
Also, on windows computer you may check out the log file for NRDP:

Code: Select all

C://Program Files x86/Nagios/NCPA/var/log/win32service_ncpapassive.log 
I don't have any windows boxes as of now.
Please run the following command:

Code: Select all

sudo sed -i 's/<\/Directory>/Require all granted\n&/' /etc/apache2/sites-enabled/nrdp.conf
And then restart the apache service:

Code: Select all

sudo systemctl restart apache2.service
I run those commands on Nagios ore; where NRDP is installed.

nrdp.conf

Code: Select all

<Directory "/usr/local/nrdp">
#  SSLRequireSSL
   Options None
   AllowOverride None
   Order allow,deny
   Allow from all
#  Order deny,allow
#  Deny from all
#  Allow from 127.0.0.1
#   AuthName "NRDP"
#   AuthType Basic
#   AuthUserFile /usr/local/nrdp/htpasswd.users
#  Require valid-user
Require all granted
</Directory>

Alias /nrdp "/usr/local/nrdp/server"
~
Attachments
Screenshot_39.png
Screenshot_38.png
Locked