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.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Passive Alerts With NSCA not working

Post by npolovenko »

@cybergene, Can you upload the ncpa.cfg file from the linux server that you're trying to monitor? Also, please show us the /usr/local/nrdp/server/config.inc.php file from the Nagios server, and also maybe /usr/local/nagios/var/nagios.log file.
Also, please make sure that ports 80 and 443 are open on both monitoring and monitored server?
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 »

See attached files
ncpa.cfg files:
ncpa.cfg
(40.3 KiB) Downloaded 436 times
config.inc.php file:
config.inc.php.txt
(66.79 KiB) Downloaded 406 times
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Passive Alerts With NSCA not working

Post by tgriep »

I would edit the ncpa.cfg file and change this line from

Code: Select all

token = cda35gtdfu72  ;Str0ngT0k3n
to

Code: Select all

token = cda35gtdfu72
It might be sending the whole string as the token and that is why it is not working.

I also do not see and passive checks setup in the ncpa.cfg file. The following example you can use if you like. Adjust the names to match.

Code: Select all

[passive checks]
%HOSTNAME%|__HOST__ = system/agent_version
%HOSTNAME%|CPU Usage = cpu/percent --warning 60 --critical 80 --aggregate avg
%HOSTNAME%|Swap Usage = memory/swap --warning 60 --critical 80 --units Gi
%HOSTNAME%|Memory Usage = memory/virtual --warning 80 --critical 90 --units Gi
%HOSTNAME%|Process Count = processes --warning 300 --critical 40
%HOSTNAME%|disk =  api/disk/logical/| --units=G
%HOSTNAME%|disk =  api/disk/logical/|boot --units=G
Save the file and restart xinetd

Also, it looks like you have a configuration error on the Nagios server.

Code: Select all

Error: Unexpected token or statement in file '/usr/local/nagios/etc/objects/hanjin.cfg' on line 113.
Error: Invalid max_check_attempts value for host 'hanjin'
Be sure to check out our Knowledgebase for helpful articles and solutions!
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 @tgriep,

I already fixed the errors. And I have made the changes required.

One thing I didn't get from your reply:

Code: Select all

[passive checks]
%HOSTNAME%|__HOST__ = system/agent_version
%HOSTNAME%|CPU Usage = cpu/percent --warning 60 --critical 80 --aggregate avg
%HOSTNAME%|Swap Usage = memory/swap --warning 60 --critical 80 --units Gi
%HOSTNAME%|Memory Usage = memory/virtual --warning 80 --critical 90 --units Gi
%HOSTNAME%|Process Count = processes --warning 300 --critical 40
%HOSTNAME%|disk =  api/disk/logical/| --units=G
%HOSTNAME%|disk =  api/disk/logical/|boot --units=G
These commands are located in nrdp.cfg under

Code: Select all

/usr/local/ncpa/etc/ncpa.cfg.d
on my remote system.

Should they be added to the ncpa.cfg? or create a new file?
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Passive Alerts With NSCA not working

Post by tgriep »

From the files you uploaded, I did not see any passive commands defined so I posted some examples you can look at but if you have some already defined, can you post them here as well as a the full

Code: Select all

/usr/local/ncpa/etc/ncpa.cfg
file so we can verify the syntax of the commands?
Be sure to check out our Knowledgebase for helpful articles and solutions!
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 »

Here are the files:

Code: Select all

/usr/local/ncpa/etc/ncpa.cfg

Code: Select all

/usr/local/ncpa/etc/ncpa.cfg.d/nrpd.cfg
Attachments
nrdp.cfg
(605 Bytes) Downloaded 409 times
ncpa.cfg
(6.4 KiB) Downloaded 401 times
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Passive Alerts With NSCA not working

Post by tgriep »

At the bottom of the nrdp.cfg file, there is a tilde "~" at the bottom of the file, remove that and restart the ncpa_passive service and see if that error is gone and that the checks get sent to the Nagios server.

Then check the nagios.log file on the Nagios server and see if the service checks are received on the server.
Be sure to check out our Knowledgebase for helpful articles and solutions!
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 »

Removed, nothing changed on both sides. Nagios log file is clear

Code: Select all

1514386532] Caught SIGTERM, shutting down...
[1514386532] wproc: Socket to worker Core Worker 1165 broken, removing
[1514386532] wproc: Socket to worker Core Worker 1166 broken, removing
[1514386532] wproc: Socket to worker Core Worker 1167 broken, removing
[1514386532] wproc: Socket to worker Core Worker 1164 broken, removing
[1514386532] Successfully shutdown... (PID=1142)
[1514386532] Event broker module 'NERD' deinitialized successfully.
[1514386532] Nagios 4.3.4 starting... (PID=32049)
[1514386532] Local time is Wed Dec 27 14:55:32 UTC 2017
[1514386532] LOG VERSION: 2.0
[1514386532] qh: Socket '/usr/local/nagios/var/rw/nagios.qh' successfully initialized
[1514386532] qh: core query handler registered
[1514386532] nerd: Channel hostchecks registered successfully
[1514386532] nerd: Channel servicechecks registered successfully
[1514386532] nerd: Channel opathchecks registered successfully
[1514386532] nerd: Fully initialized and ready to rock!
[1514386532] wproc: Successfully registered manager as @wproc with query handler
[1514386532] wproc: Registry request: name=Core Worker 32055;pid=32055
[1514386532] wproc: Registry request: name=Core Worker 32054;pid=32054
[1514386532] wproc: Registry request: name=Core Worker 32053;pid=32053
[1514386532] wproc: Registry request: name=Core Worker 32052;pid=32052
[1514386532] Successfully launched command file worker with pid 32057
[1514390132] Auto-save of retention data completed successfully.
[1514393732] Auto-save of retention data completed successfully.
While ncpa_passive.log file has the following errors:

Code: Select all

2017-12-27 12:40:46,112 9078 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
2017-12-27 12:42:11,693 9078 INFO stopped
2017-12-27 12:42:12,370 9121 INFO started
2017-12-27 12:42:12,376 9121 INFO Running check: cpu/percent --warning 60 --critical 80 --aggregate avg
2017-12-27 12:42:13,420 9121 INFO Running check: memory/swap --warning 60 --critical 80 --units Gi
2017-12-27 12:42:13,453 9121 INFO Running check: memory/virtual --warning 80 --critical 90 --units Gi
2017-12-27 12:42:13,484 9121 INFO Running check: processes --warning 300 --critical 400
2017-12-27 12:42:13,629 9121 INFO Running check: disk/logical/|/used_percent --warning 80 --critical 90
2017-12-27 12:42:13,737 9121 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, You still have two lines commented out in nrdp.cfg file. Please uncomment:

Code: Select all

#%HOSTNAME%|__HOST__ = system/agent_version
#%HOSTNAME%|Disk Usage = disk/logical/C:|/used_percent --warning 80 --critical 90 --units Gi
Should they be added to the ncpa.cfg? or create a new file?
NCPA should automatically include those files. But, if you'd like you could include the passive checks in cpa.cfg file itself. After this line

Code: Select all

hostname = hanjin
Add your definitions:

Code: Select all

[passive checks]

%HOSTNAME%|__HOST__ = system/agent_version
%HOSTNAME%|Workstation Name = system/node
%HOSTNAME%|Uptime = system/uptime
%HOSTNAME%|Disk Usage = disk/logical/C:|/used_percent --warning 80 --critical 90 --units Gi
%HOSTNAME%|CPU Usage = cpu/percent --warning 60 --critical 80 --aggregate avg
%HOSTNAME%|Swap Usage = memory/swap --warning 60 --critical 80 --units Gi
%HOSTNAME%|Memory Usage = memory/virtual --warning 80 --critical 90 --units Gi
%HOSTNAME%|Process Count = processes --warning 300 --critical 400
%HOSTNAME%|NCPA Listener = services?service=ncpalistener&status=running
%HOSTNAME%|NCPA Passive = services?service=ncpapassive&status=running
Don't forget to restart NCPA passive service every time after you make changes:

Code: Select all

systemctl restart ncpa_passive.service
or

Code: Select all

service ncpa_passive restart
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 »

Those commands, I commented them out to not use them. But I uncommitted them for the time being.

I added all the commands to ncpa.cfg file under the hostname section as requested.

Restarted by sudo systemctl restart ncpa_passive.service

I'm getting the same error in the logs:

Code: Select all

2017-12-27 14:23:11,672 9121 INFO stopped
2017-12-27 14:23:12,347 9521 INFO started
2017-12-27 14:23:12,354 9521 INFO Running check: system/agent_version
2017-12-27 14:23:12,366 9521 INFO Did not receive normal values. Unable to find meaningful check.
2017-12-27 14:23:12,394 9521 INFO Running check: disk/logical/C:|/used_percent --warning 80 --critical 90 --units Gi
2017-12-27 14:23:12,427 9521 INFO Running check: cpu/percent --warning 60 --critical 80 --aggregate avg
2017-12-27 14:23:13,458 9521 INFO Running check: memory/swap --warning 60 --critical 80 --units Gi
2017-12-27 14:23:13,490 9521 INFO Running check: memory/virtual --warning 80 --critical 90 --units Gi
2017-12-27 14:23:13,523 9521 INFO Running check: processes --warning 300 --critical 400
2017-12-27 14:23:13,669 9521 INFO Running check: disk/logical/|/used_percent --warning 80 --critical 90
2017-12-27 14:23:13,781 9521 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
Locked