Page 1 of 1

Remote Host Service Monitoring Trouble

Posted: Sat Aug 10, 2019 3:54 pm
by Explodistan
So I installed NCPA on a windows server to monitor critical services and cpu percentages. After I configured everything on the Nagios server end to look at the computer I set up, the services still show the return code of "Return code of 127 is out of bounds. Check if plugin exists". It is passing passive data though as every five minutes the machine shows green on Nagios, with information on the hardware and services running. It just goes back to the return code of 127 after the next active check.

So either 1 I am at a loss since everything seems to be configured ok on both ends

or

2.) Can I just use passive checks for both hardware and services running on the server I am trying to monitor?

Re: Remote Host Service Monitoring Trouble

Posted: Sat Aug 10, 2019 4:27 pm
by Explodistan
Issue solved. It ended up being a problem in the ncpa.conf file on the windows machine. The url was set to XXX.XXX.XXX.XXX instead of XXX.XXX.XXX.XXX/nagios which ended up in the program not being able to find the server. I had looked in the .log file and saw that it was having trouble finding the server. Who knew .log files where so helpful :p

Re: Remote Host Service Monitoring Trouble

Posted: Sat Aug 10, 2019 5:01 pm
by Explodistan
ok, so one more issue. I am testing out monitoring a specific service over NCPA. Everything is set now as the initial configuration commands all work. I input a service through check_ncpa.py to monitor a random service that is running on my test machine, but it is returning the same frustrating 127 error. Here is the configuration I have in Nagios for the system

define host {
use windows-server
host_name Jeff Test
address XXX.XXX.XXX.XXX
check_command check_ncpa!-t 'XXX' -P 5693 -M system/agent_version
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
contacts nagiosadmin
notification_interval 60
notification_period 24x7
notifications_enabled 1
icon_image ncpa.png
statusmap_image ncpa.png
register 1
}

define service {
host_name Jeff Test
service_description CPU Usage
check_command check_ncpa!-t 'XXX' -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg'
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 60
notification_period 24x7
contacts nagiosadmin
register 1
}

define service {
host_name Jeff Test
service_description Memory Usage
check_command check_ncpa!-t 'XXX' -P 5693 -M memory/virtual -w 50 -c 80 -u G
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 60
notification_period 24x7
contacts nagiosadmin
register 1
}

define service {
host_name Jeff Test
service_description Critical Service
check_command check_ncpa!-t 'XXX' -P 5693 -M service -q service=ibtsiva,status=running,match=search
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 60
notification_period 24x7
contacts nagiosadmin
register 1
}

Re: Remote Host Service Monitoring Trouble

Posted: Mon Aug 12, 2019 10:23 am
by mbellerue
Can you go to the command line in your Nagios Core server, navigate to your Nagios plugins directory (usually /usr/local/nagios/libexec/), and try to run your check command?

Code: Select all

./check_ncpa.py -H <HostMachineIP> -t '<your token>' -M 'cpu/percent' -w 20 -c 40 -q 'aggregate=avg' -v 
I'd just like to verify that the NCPA plugin is installed, and the check itself works properly. Also the -v switch will give us additional output to work with.

Re: Remote Host Service Monitoring Trouble

Posted: Mon Aug 12, 2019 3:00 pm
by Explodistan
Ah, so we have a problem. When I input the code, this is what happens.

sudo ./check_ncpa.py -H 'XXX.XXX.XXX.XXX' -t 'XXXXXX' -M 'cpu/percent' -w 20 -c 40 -q 'aggregate=avg' -v
sudo: ./check_ncpa.py: command not found

and this happens with all the ./check_ncpa.py commands. This command does exist and is located in the nagios/libexec folder.

Re: Remote Host Service Monitoring Trouble

Posted: Mon Aug 12, 2019 3:05 pm
by Explodistan
Also, when I try to run it from under the libexec directory it returns

sudo ./check_ncpa.py -H 'XXXXXXXX' -t 'XXXXXXXX' -M 'cpu/percent' -w 20 -c 40 -q 'aggregate=avg' -V
/usr/bin/env: ‘python\r’: No such file or directory

Re: Remote Host Service Monitoring Trouble

Posted: Mon Aug 12, 2019 4:36 pm
by scottwilkerson
I would check first if line endings are set to "unix" in the script. Make sure they are not set to "dos". Open the plugin in "vi" editor

Code: Select all

vi ./check_ncpa.py 
type:

Code: Select all

:set ff=unix
and hit "Enter". Save and exit by typing:

Code: Select all

:wq
and hitting "Enter" again. Test your plugin again.

Re: Remote Host Service Monitoring Trouble

Posted: Mon Aug 12, 2019 5:07 pm
by Explodistan
ok I did that and the fix seems to have worked

./check_ncpa.py -H XXX.XXX.XXX.XXX -t 'XXXXXX' -M 'services' -q 'service=AdobeARMservice,status=running'
OK: AdobeARMservice is running

So it seems like the plugin is now running correctly. Should I restart any of the services on my Nagios server?

Re: Remote Host Service Monitoring Trouble

Posted: Mon Aug 12, 2019 5:13 pm
by Explodistan
So I went and reconfigured the configuration on the Nagios server and the plugin is working fine now. I'll write down this change. The only other question I have is is there a document for what commands are supported with NCPA? Like what checks it can do?

Re: Remote Host Service Monitoring Trouble

Posted: Tue Aug 13, 2019 6:35 am
by scottwilkerson
Explodistan wrote:The only other question I have is is there a document for what commands are supported with NCPA? Like what checks it can do?
The documentation is here
https://www.nagios.org/ncpa/help.php