Page 1 of 2

Passive checks passing Haproxy to CORE

Posted: Tue Jul 21, 2015 2:01 am
by ashleydrees
I have my Pro Nagios® Core ™Version 4.0.7 June 03, 2014, I use PFsense as my firewall/router and behind that is my ESXi server with all the various virtual machines that folk love to hand out these days, i am happy with that but need to share ports 80 and 443 with some other services, my current method is using HAproxy, which seems to work pretty well. BUT the passive checks do not make it to CORE server...

At the moment the ncpa_passive log show...

2015-07-21 07:54:26,581 1147 ERROR Invalid URL u'nagios.domain.tld/': No schema supplied. Perhaps you meant http://nagios.domain.tld/?

I have tried to add an http to the hostname in ncpa.cfg - but it does not like that.

Has anyone any thoughts about this.. or am i really barking up the wrong tree and need to either rethink the proxy or the port setup (or even a VPN).

Re: Passive checks passing Haproxy to CORE

Posted: Tue Jul 21, 2015 4:36 pm
by tmcdonald
Can you post a sanitized version of your ncpa config? Sounds like you just need to format it properly. I won't discount HAProxy tampering with things, but I wanna try some other stuff first.

Re: Passive checks passing Haproxy to CORE

Posted: Sun Nov 01, 2015 6:14 am
by ashleydrees
tmcdonald wrote:Can you post a sanitized version of your ncpa config? Sounds like you just need to format it properly. I won't discount HAProxy tampering with things, but I wanna try some other stuff first.
Sorry i dropped the ball on this, we had some problems with hackers, which needed to be urgently resolved (we love our backups) - now back on track and looking at this again...

Do you want to see the whole config or just [passive] ?

I am getting a lot of stuff back from the nagios server via the haproxy but i think i need help to evaluate what is actually going on, is there a "special" url for passive checks to a core installation.

Re: Passive checks passing Haproxy to CORE

Posted: Mon Nov 02, 2015 10:48 am
by rkennedy
Please post the whole configuration (make sure to sanitize it of passwords as needed).

Re: Passive checks passing Haproxy to CORE

Posted: Wed Nov 04, 2015 2:04 pm
by ashleydrees
OK, It is beginning to look better now...

The issues i had not dealt with were.
1, ensure that the hostname i was using in the "parent" was correct.
2, add my token to the authorized_tokens and restart apache
3, add nrdp to the end of the url i was using in ncpa.cfg (NOT /nagios or /nagios/nrdp)
parent = http://nagios.domain.tld/nrdp/
4, /etc/init.d/ncpa_passive restart

All of that is covered in this link.
https://assets.nagios.com/downloads/nrd ... erview.pdf

I am now getting the passive checks showing up in my core log, but with an error...

[11-04-2015 13:42:35] Error: Got check result for service 'Memory_Usage' on host 'monitor.domain.tld'. Unable to find service

I have renamed the service i am trying to get a passive check to

Memory_Usage

along with the Config name, Description and also Display name in core. ALL are now Memory_Usage and in the ncpa.cfg it looks like...

%HOSTNAME%|Memory_Usage = /memory/virtual/percent --warning 60 --critical 80

Passive checks are explicitly enabled - and now i am stuck again, but i feel a lot closer...

[listener]
uid = nagios
certificate = adhoc
loglevel = debug
ip = 0.0.0.0
gid = nagcmd
logfile = var/ncpa_listener.log
port = 5693
pidfile = var/ncpa_listener.pid
ssl_version = SSLv3

[passive]
uid = nagios
handlers = nrds,nrdp
loglevel = debug
gid = nagcmd
sleep = 300
logfile = var/ncpa_passive.log
pidfile = var/ncpa_passive.pid

[nrdp]
token = notinmyname
hostname = monitor.domain.tld
parent = http://nagios.domain.tld/nrdp

[nrds]
url = None
CONFIG_VERSION = None
token = None
CONFIG_NAME = None
CONFIG_OS = None
UPDATE_PLUGINS = 0
UPDATE_CONFIG = 1

[api]
community_string = notinmyname

[plugin directives]
plugin_path = plugins/
.sh = /bin/sh $plugin_name $plugin_args
command [check_fail2ban] = /usr/bin/sudo /usr/local/ncpa/plugins/check_fail2ban
command [check_dhcp] = /usr/bin/sudo /usr/local/ncpa/plugins/check_dhcp

[passive checks]
%HOSTNAME%|cpu usage = /cpu/percent --warning 20 --critical 30
%HOSTNAME%|swap usage = /memory/swap/percent --warning 40 --critical 80
%HOSTNAME%|Memory_Usage = /memory/virtual/percent --warning 60 --critical 80

Re: Passive checks passing Haproxy to CORE

Posted: Wed Nov 04, 2015 5:59 pm
by jdalrymple
ashleydrees wrote:I am now getting the passive checks showing up in my core log, but with an error...

[11-04-2015 13:42:35] Error: Got check result for service 'Memory_Usage' on host 'monitor.domain.tld'. Unable to find service

I have renamed the service i am trying to get a passive check to

Memory_Usage

along with the Config name, Description and also Display name in core. ALL are now Memory_Usage and in the ncpa.cfg it looks like...

%HOSTNAME%|Memory_Usage = /memory/virtual/percent --warning 60 --critical 80

Passive checks are explicitly enabled - and now i am stuck again, but i feel a lot closer...
What are you stuck at now? Any new logs you can share? I don't see an update on the behavior.

Re: Passive checks passing Haproxy to CORE

Posted: Wed Nov 04, 2015 6:29 pm
by Box293
Lets also check we don't have multiple instances of nagios running:

Can you please run this command and send us the output:

Code: Select all

ps -ef | grep nagios.cfg

Re: Passive checks passing Haproxy to CORE

Posted: Thu Nov 05, 2015 4:34 am
by ashleydrees
Thanks all.. once i finally understood what the error message meant - i realised i had not yet assigned that particular services check for the host i was testing with, (the answer was in the error message). I have a host group which should have had all the hosts in, but did not have the test host.

I apologise for the stupidity, sometimes talking something through is the door to the solution - along with your questions. (only one nagios running too).

Fixed that and now i have a new issue

NOW i have the passive check arriving, i am having an issue with a check i am trying to do, i want the remote host to report that it has a connection as well as the active check - belt and braces i guess

%HOSTNAME%|Host Alive = /agent/plugin/check_http/-H/nagios.domain.tld/-u/http://nagios.domain.tld/robots.txt

But the "/"'s are turned to spaces in the passive check... in the url (-u) i have tried http:\/\/nagios.domain.tld\/robots.txt, "http://nagios.domain.tld/robots.txt", http://nagios.domain.tldt/robots.txt

Am i able to include "/"'s in the passive check statement?

Re: Passive checks passing Haproxy to CORE

Posted: Thu Nov 05, 2015 3:22 pm
by rkennedy
I noticed in your command there are no spaces -

Code: Select all

/agent/plugin/check_http/-H/nagios.domain.tld/-u/http://nagios.domain.tld/robots.txt
is that how you have it configured?

Re: Passive checks passing Haproxy to CORE

Posted: Thu Nov 05, 2015 4:36 pm
by ashleydrees
is that how you have it configured?
Yes, and the command is sent as follows...

DEBUG Running process with command line: `/usr/local/ncpa/plugins/check_http -H nagios.domain.tld -u http: nagios.domain.tld robots.txt`

from the documentation i realised that i could use the forward slash to simplify my commands - but because it replaces the forward slash with a space i am unable to send a URL, i have tried escaping them, using HTML and both single and double quotes, but i am unable to get the passive check to sand what i want - which is

DEBUG Running process with command line: `/usr/local/ncpa/plugins/check_http -H nagios.domain.tld -u http://nagios.domain.tld/robots.txt`

Which will return an OK as the robots.txt is actually there.