NCPA config file question

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
cbeattie-unitrends
Posts: 84
Joined: Mon Oct 10, 2016 2:51 pm

NCPA config file question

Post by cbeattie-unitrends »

I'm trying to get NCPA 2.1.5 to load a config file for an additional disk check on Windows. What I've done in the past with no problem is modify the existing nrdp.cfg and restart NCPA.
nrdp.cfg:

Code: Select all

#
# AUTO GENERATED NRDP CONFIG FROM WINDOWS INSTALLER
#

[passive checks]

# Host check  - This is to stop "pending check" status in Nagios
%HOSTNAME%|__HOST__ = /system/agent_version

# Service checks
%HOSTNAME%|CPU Usage = /cpu/percent --warning 80 --critical 90 --aggregate avg
%HOSTNAME%|Disk C = /disk/logical/C:|/used_percent --warning 80 --critical 90
%HOSTNAME%|Swap Usage = /memory/swap --warning 60 --critical 80
%HOSTNAME%|Memory Usage = /memory/virtual --warning 80 --critical 90
%HOSTNAME%|Process Count = /processes --warning 300 --critical 400
If I try to add a check from a separate file like this:
disk_e.cfg, in the same directory as nrdp.cfg:

Code: Select all

[passive checks]

%HOSTNAME%|Disk E = /disk/logical/E:|/used_percent --warning 80 --critical 90
NCPA refuses to start, and win32service_ncpapassive.log says there are no headers:

Code: Select all

[00928] 2018/08/21 09:41:29.415 starting logging at level ERROR
[00928] 2018/08/21 09:41:30.857 Python exception encountered:
[00928] 2018/08/21 09:41:30.857     Internal Message: failed to initialize instance properly
[00928] 2018/08/21 09:41:30.857     Type => <class 'ConfigParser.MissingSectionHeaderError'>
[00928] 2018/08/21 09:41:30.857     Value => File contains no section headers.
file: C:\Program Files (x86)\Nagios\NCPA\etc\ncpa.cfg.d\disk_e.cfg, line: 1
'\xef\xbb\xbf[passive checks]\n'
[00928] 2018/08/21 09:41:30.857     Traceback (most recent call last):

[00928] 2018/08/21 09:41:30.857       File "C:\ncpa\agent\ncpa_windows.py", line 286, in Initialize

[00928] 2018/08/21 09:41:30.857       File "C:\ncpa\agent\ncpa_windows.py", line 64, in parse_config

[00928] 2018/08/21 09:41:30.857       File "C:\Python27\lib\ConfigParser.py", line 305, in read

[00928] 2018/08/21 09:41:30.857       File "C:\Python27\lib\ConfigParser.py", line 512, in _read

[00928] 2018/08/21 09:41:30.857     MissingSectionHeaderError: File contains no section headers.
file: C:\Program Files (x86)\Nagios\NCPA\etc\ncpa.cfg.d\disk_e.cfg, line: 1
'\xef\xbb\xbf[passive checks]\n'

[17968] 2018/08/21 09:41:30.859 ending logging
I've tried combinations of [nrdp] and [passive checks] in disk_e.cfg to no avail. If I paste the line from disk_e.cfg into nrdp.cfg, NCPA starts up just fine. Any idea what I'm doing wrong?

Thanks.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA config file question

Post by lmiltchev »

file: C:\Program Files (x86)\Nagios\NCPA\etc\ncpa.cfg.d\disk_e.cfg, line: 1
'\xef\xbb\xbf[passive checks]\n'
I am able to cause a similar error when I add a space in front of the [passive checks] section.... In your case, you may have some other weird characters. What editor did you use to add your command to the disk_e.cfg file? I would recommend using Notepad++.
Be sure to check out our Knowledgebase for helpful articles and solutions!
cbeattie-unitrends
Posts: 84
Joined: Mon Oct 10, 2016 2:51 pm

Re: NCPA config file question

Post by cbeattie-unitrends »

I did everything in Notepad++ and turned on the option line endings to make sure they were the same. However, after copying the line out of nrdp.cfg and creating a new disk_e.cfg by hand, it worked. But you put me on the right track!
When I created the file manually, it had UTF-8 encoding. When I had PowerShell Desired State Configuration create the file, it had UTF-8-BOM encoding. NCPA didn't like UTF-8-BOM, but as soon as I converted the encoding and resaved it as vanilla UTF-8, NCPA fired right up.

So, the file encoding is the problem I need to fix, not anything with NCPA. Thanks! Feel free to close and lock this thread.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA config file question

Post by lmiltchev »

I am glad I could help! :)

I am locking this topic.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked