NCPA new install not working on RHEL 6.9 server

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.
hpzaramk
Posts: 25
Joined: Wed Nov 21, 2018 12:06 am

NCPA new install not working on RHEL 6.9 server

Post by hpzaramk »

Hi,

I have installed NCPA 2.1.9 on RHEL 6.9 box using the below command , the installation went good, but the ncpa_listener and ncpa_passive services are not working.

rpm -Uvh https://assets.nagios.com/downloads/ncp ... x86_64.rpm

The ncpa_listener service immediately stops running after restarting it.. I have configured the ncpa.cfg under "/usr/local/ncpa/etc" as per the documentation and also done with nrdp.cfg located under /usr/local/ncpa/etc/ncpa.cfg.d.

[root@uitlblg16:/root]
# service ncpa_listener start
Starting NCPA Listener: [ OK ]

[root@uitlblg16:/root]
# service ncpa_listener status
NCPA Listener: Service is not running.

Here is the error message i see in the ncpa_listener.log:

2019-10-22 12:30:56,411 2988 INFO started
2019-10-22 12:30:56,413 2988 INFO Using SSL version TLSv1_2
2019-10-22 12:30:56,415 2988 ERROR [Errno 97] Address family not supported by protocol
Traceback (most recent call last):
File "ncpa_listener.py", line 108, in run
File "/usr/local/lib/python2.7/site-packages/gevent/baseserver.py", line 360, in serve_forever
File "/usr/local/lib/python2.7/site-packages/gevent/baseserver.py", line 304, in start
File "/usr/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 1450, in init_socket
File "/usr/local/lib/python2.7/site-packages/gevent/server.py", line 127, in init_socket
File "/usr/local/lib/python2.7/site-packages/gevent/server.py", line 138, in get_listener
File "/usr/local/lib/python2.7/site-packages/gevent/server.py", line 225, in _tcp_listener
File "/usr/local/lib/python2.7/site-packages/gevent/_socket2.py", line 107, in __init__
error: [Errno 97] Address family not supported by protocol
2019-10-22 12:30:56,416 2988 INFO stopped

ncpa_passive.log:

NoSectionError: No section: 'passive checks'
2019-10-22 12:43:44,562 32680 ERROR No section: 'passive checks'
Traceback (most recent call last):
File "ncpa_passive.py", line 51, in run_all_handlers
File "/root/ncpa/agent/passive/nrdp.py", line 112, in run
File "/root/ncpa/agent/passive/nagioshandler.py", line 78, in run
File "/root/ncpa/agent/passive/nagioshandler.py", line 35, in get_commands_from_config
File "/usr/local/lib/python2.7/ConfigParser.py", line 642, in items

Thanks,
Ram.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: NCPA new install not working on RHEL 6.9 server

Post by cdienger »

What is the ip set to in ncpa.cfg? You may need to change it to 0.0.0.0 per https://github.com/NagiosEnterprises/ncpa/issues/523
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
hpzaramk
Posts: 25
Joined: Wed Nov 21, 2018 12:06 am

Re: NCPA new install not working on RHEL 6.9 server

Post by hpzaramk »

Thanks ! ncpa_listener started and running ok after changing ip = :: to ip = 0.0.0.0 in the ncpa.cfg.

ncpa_passive service is up, however i see the below errors in the ncpa_passive.log.

NoSectionError: No section: 'passive checks'
2019-10-22 16:26:00,090 8222 ERROR No section: 'passive checks'
Traceback (most recent call last):
File "ncpa_passive.py", line 51, in run_all_handlers
File "/root/ncpa/agent/passive/nrdp.py", line 112, in run
File "/root/ncpa/agent/passive/nagioshandler.py", line 78, in run
File "/root/ncpa/agent/passive/nagioshandler.py", line 35, in get_commands_from_config
File "/usr/local/lib/python2.7/ConfigParser.py", line 642, in items
NoSectionError: No section: 'passive checks'


Here is the contents of nrdp.cfg located under /usr/local/ncpa/etc/ncpa.cfg.d directory.

# cat nrdp.cfg
#
# Basic example of Passive checks being defined
#

[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 400

Thanks,
Ram.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA new install not working on RHEL 6.9 server

Post by lmiltchev »

Make sure you have these lines in the ncpa.cfg file:

Code: Select all

handlers = nrdp
parent = https://x.x.x.x/nrdp
token = <your token>
Save, exit and restart the ncpa_passive service.

Let us know if this helped. Thanks!
Be sure to check out our Knowledgebase for helpful articles and solutions!
hpzaramk
Posts: 25
Joined: Wed Nov 21, 2018 12:06 am

Re: NCPA new install not working on RHEL 6.9 server

Post by hpzaramk »

Hi,

The mentioned entries are already configured on ncpa.cfg. Please find the ncpa.cfg attached here.

Thanks,
Ram.
Attachments
ncpa.cfg.txt
ncpa.cfg
(8.42 KiB) Downloaded 167 times
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA new install not working on RHEL 6.9 server

Post by lmiltchev »

Can you run the following commands and show the output?

Code: Select all

service ncpa_passive restart
service ncpa_passive status
ll -d /usr/local/ncpa/etc/
ll /usr/local/ncpa/etc/
ll /usr/local/ncpa/etc/ncpa.cfg.d/
cat /usr/local/ncpa/etc/ncpa.cfg.d/nrdp.cfg
Be sure to check out our Knowledgebase for helpful articles and solutions!
hpzaramk
Posts: 25
Joined: Wed Nov 21, 2018 12:06 am

Re: NCPA new install not working on RHEL 6.9 server

Post by hpzaramk »

Please find the below outputs from the NCPA agent server.

[root@uitlblg16:/root]
# service ncpa_passive restart
Stopping NCPA Passive: [ OK ]
Starting NCPA Passive: [ OK ]

[root@uitlblg16:/root]
# service ncpa_passive status
NCPA Passive: Service is running. (pid 29700)

[root@uitlblg16:/root]
# ll -d /usr/local/ncpa/etc/
drwxrwxr-x 3 root nagios 4096 Oct 23 08:16 /usr/local/ncpa/etc/

[root@uitlblg16:/root]
# ll /usr/local/ncpa/etc/
total 28
-rw-r--r-- 1 nagios nagios 8318 Oct 23 07:27 ncpa.cfg
drw-r--r-- 2 nagios nagios 4096 Oct 21 15:11 ncpa.cfg.d
-rw-r--r-- 1 nagios nagios 8331 Sep 3 15:41 ncpa.cfg.sample

[root@uitlblg16:/root]
# ll /usr/local/ncpa/etc/ncpa.cfg.d/
total 12
-rw-r--r-- 1 nagios nagios 510 Sep 3 15:41 example.cfg
-rw-r--r-- 1 nagios nagios 411 Oct 21 15:11 nrdp.cfg
-rw-r--r-- 1 nagios nagios 100 Sep 3 15:41 README.txt

[root@uitlblg16:/root]
# cat /usr/local/ncpa/etc/ncpa.cfg.d/nrdp.cfg
#
# Basic example of Passive checks being defined
#

[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 400

Thanks,
Ram.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA new install not working on RHEL 6.9 server

Post by lmiltchev »

If a directory is not "executable" in Linux, you are not going to be able to read the files... Run the following command to fix permissions on the ncpa.cfg.d directory:

Code: Select all

chmod 775 /usr/local/ncpa/etc/ncpa.cfg.d
Let us know if this helped.
Be sure to check out our Knowledgebase for helpful articles and solutions!
hpzaramk
Posts: 25
Joined: Wed Nov 21, 2018 12:06 am

Re: NCPA new install not working on RHEL 6.9 server

Post by hpzaramk »

Great Fix !! It worked Thank you. I have couple of questions..

1) For any new NCPA install on other RHEL servers, does the required directory permission for /usr/local/ncpa/ncpa.cfg.d is set automatically (or) i need to run chmod manually after the agent install ?

2) I have installed the agent as root user and the ncpa listener and passive services are running as "Nagios" user. Is it the expected behavior ?
Does it mean the user nagios has the root privilege locally on the box ?

# ps -ef|grep -i ncpa
nagios 3210 1 0 15:24 ? 00:00:00 /usr/local/ncpa/ncpa_passive --start
root 3680 3051 0 15:26 pts/1 00:00:00 grep -i ncpa
nagios 8144 1 0 Oct22 ? 00:00:07 /usr/local/ncpa/ncpa_listener --start

Thanks,
Ram.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA new install not working on RHEL 6.9 server

Post by lmiltchev »

Great Fix !! It worked Thank you. I have couple of questions..
I am glad I could help!
1) For any new NCPA install on other RHEL servers, does the required directory permission for /usr/local/ncpa/ncpa.cfg.d is set automatically (or) i need to run chmod manually after the agent install ?
You shouldn't need to run chmod manually - I am not sure why your permissions were set that way... Did you use the recommended method (installing NCPA using Nagios repo)?

https://www.nagios.org/ncpa/#downloads

Code: Select all

rpm -Uvh https://repo.nagios.com/nagios/6/nagios-repo-6-4.el6.noarch.rpm
yum install ncpa -y
I just did a fresh install of NCPA on RHEL 6, and my permissions of the ncpa.cfg.d folder are 775.

Code: Select all

[root@TEST_XI_RHEL_6 ~]# ll -d /usr/local/ncpa/
drwxr-xr-x 7 root root 4096 Oct 23 15:43 /usr/local/ncpa/
[root@TEST_XI_RHEL_6 ~]# ll -d /usr/local/ncpa/etc
drwxrwxr-x 3 root nagios 4096 Oct 23 15:43 /usr/local/ncpa/etc
[root@TEST_XI_RHEL_6 ~]# ll -d /usr/local/ncpa/etc/ncpa.cfg.d
drwxrwxr-x 2 root nagios 4096 Oct 23 15:43 /usr/local/ncpa/etc/ncpa.cfg.d
Also, they are root.nagios, not nagios.nagios.
2) I have installed the agent as root user and the ncpa listener and passive services are running as "Nagios" user. Is it the expected behavior ?
Does it mean the user nagios has the root privilege locally on the box ?
NCPA start as root than drops permissions before running the daemon/server. You can actually change the user/group ncpa runs as in the ncpa.cfg file.

Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked