Page 1 of 2

Observing "returned an invalid return code: 255" for windows

Posted: Thu Nov 26, 2020 9:55 am
by Amit_Alone
Hi All,

I'm continuously observing The command (checklogfile_activemq) returned an invalid return code: 255 while trying to monitor the Log File on windows. However, rest of the alerts are working as expected. But whenever I tried to configure any of the log file it is showing 255 error.

I have followed the same process on different server for log file monitoring and on all that servers it is working as expected but on one of the server it is not working :( .

I'm using check_log3.exe plugin to monitor the log file. I tried exciting the script on the same server and it is showing expected result.

Code: Select all

PS C:\Program Files\NSClient++\scripts> .\check_log3.exe -l "C:\***\Logs\AGTSG\JBoss\hibernate.log" -P "C:\Program Files\NSClient++\PatternFiles\PatternTraxTSG.txt" --show-filename
OK: Found 0 lines (limit=1/0): No matches found. [C:\***\Logs\AGTSG\JBoss\hibernate.log]|lines=0 
But while communicating with the nagios xi server it is showing me the same error.

Code: Select all

[e5613751@avgdlnxvp126 ~]$ /usr/local/nagios/libexec/check_nrpe -H 10.144.136.169 -t 90 -c CheckLogFile_Hibernate                                            The command (checklogfile_hibernate) returned an invalid return code: 255
[e5613751@avgdlnxvp126 ~]$
I tried different Nagios XI test but observed the same error. Below is the nsclient.ini file command for log file monitoring.

Code: Select all

CheckLogFile_Hibernate=scripts\check_log3.exe -l "C:\***\Logs\AGTSG\JBoss\hibernate.log" -P "C:\Program Files\NSClient++\PatternFiles\PatternTraxTSG.txt" --show-filename
Do let me know if you want nsclient.ini file I will PM you.

Re: Observing "returned an invalid return code: 255" for win

Posted: Tue Dec 01, 2020 12:04 pm
by cdienger
Yes, please PM me a copy of the nsclient.ini.

Re: Observing "returned an invalid return code: 255" for win

Posted: Wed Dec 02, 2020 3:30 am
by Amit_Alone
I have PM the nsclient.ini file

Re: Observing "returned an invalid return code: 255" for win

Posted: Wed Dec 02, 2020 5:25 pm
by cdienger
Data recieved. Are you having similar issues with any of the other checks defined? CheckLogFile_TSGActiveMQ for example.

https://docs.nsclient.org/howto/external_scripts/ has some scripts that you can test with. I'd be interested to know if a .bat works or something like this:

Code: Select all

list_file=cmd /c "dir c:\\"
Check the nsclient.log file as well which may have some more information to work with in regards to the failures.

Re: Observing "returned an invalid return code: 255" for win

Posted: Fri Dec 04, 2020 10:39 am
by Amit_Alone
I didn't see any issue with CPU, memory, uptime and services on the same server.

However, I can observed issue is with only command name starting checkLogFile_* and as requested I do have .bat file which which is working as expected. This script help to start the service incase it get stop.

Code: Select all

@echo off
net stop %1
net start %1
@exit 0
Could you please assist with the location for nsclient.log file.

Re: Observing "returned an invalid return code: 255" for win

Posted: Fri Dec 04, 2020 5:46 pm
by cdienger
What version of the check_log3 executable are you using? You can run it with the "-v" flag to get that info.

Would it be possible to provide me with a sample of the log as well as the pattern file that one of the checks is using? I haven't been able to produce the same behavior and wonder if something in these files may be causing it.

You can also try running the command directly from the Windows machine. Go to the C:\program files\nsclient++\ directory and run:

nscp test

after it is done printing info to the screen you'll be able to enter commands. Type:

Code: Select all

CheckLogFile_Hibernate
Hit enter, and record the results.

Re: Observing "returned an invalid return code: 255" for win

Posted: Thu Dec 10, 2020 8:26 am
by Amit_Alone
Sorry for late reply @cidenger

As requested below is the plugin version.
check_log3.exe version 3.14

Regarding the pattern files and logs I have PM you.

Below is the o/p for the suggested command. As mentioned earlier it is working on the same server not sure what is affecting while communicating with Nagios XI server.

Code: Select all

C:\Program Files\NSClient++>nscp test
L client Module: CommandClient
L client Command:
L client Extra Query:
L client Mode: 3
L client Boot: 1
L client Load All: 0
L client Warning module and boot specified only THAT module will be loaded
L client Arguments:
D core NSClient++ 0.4.4.23 2016-04-05 x64 Loading settings and logger...
D core Settings not ready so we cant lookup: base-path
D core Settings not ready so we cant lookup: exe-path
D settings Boot.ini found in: C:\Program Files\NSClient++/boot.ini
D core Settings not ready so we cant lookup: shared-path
D settings Activating: ini://${shared-path}/nsclient.ini
D settings Creating instance for: ini://${shared-path}/nsclient.ini
D core Settings not ready so we cant lookup: shared-path
D settings Loading: C:\Program Files\NSClient++/nsclient.ini
D core NSClient++ 0.4.4.23 2016-04-05 x64 booting...
D core Booted settings subsystem...
D core On crash: restart: NSCP
D core Archiving crash dumps in: C:\Program Files\NSClient++/crash-dumps
D core booting::loading plugins
D core Found: CheckDisk
D core Found: CheckEventLog
D core Found: CheckExternalScripts
D core Found: CheckHelpers
D core Found: CheckSystem
D core Found: CheckWMI
D core Found: NRPEServer
D core Found: NSCAClient
D core Found: NSClientServer
D core C:\Program Files\NSClient++/modules\CheckDisk.dll.dll
D core adding C:\Program Files\NSClient++/modules\CheckDisk.dll
D core C:\Program Files\NSClient++/modules\CheckEventLog.dll.dll
D core adding C:\Program Files\NSClient++/modules\CheckEventLog.dll
D core C:\Program Files\NSClient++/modules\CheckExternalScripts.dll.dll
D core adding C:\Program Files\NSClient++/modules\CheckExternalScripts.dll
D core C:\Program Files\NSClient++/modules\CheckHelpers.dll.dll
D core adding C:\Program Files\NSClient++/modules\CheckHelpers.dll
D core C:\Program Files\NSClient++/modules\CheckSystem.dll.dll
D core adding C:\Program Files\NSClient++/modules\CheckSystem.dll
D core C:\Program Files\NSClient++/modules\CheckWMI.dll.dll
D core adding C:\Program Files\NSClient++/modules\CheckWMI.dll
D core C:\Program Files\NSClient++/modules\NRPEServer.dll.dll
D core adding C:\Program Files\NSClient++/modules\NRPEServer.dll
D core C:\Program Files\NSClient++/modules\NSCAClient.dll.dll
D core adding C:\Program Files\NSClient++/modules\NSCAClient.dll
D core C:\Program Files\NSClient++/modules\NSClientServer.dll.dll
D core adding C:\Program Files\NSClient++/modules\NSClientServer.dll
D core Loading plugin: CheckDisk
D core Loading plugin: CheckEventLog
D core Loading plugin: CheckExternalScripts
D ext-script No aliases found (adding default)
D core Loading plugin: CheckHelpers
D core Loading plugin: CheckSystem
D core Loading plugin: CheckWMI
D core Loading plugin: NRPEServer
D nrpe Allowed hosts definition: 127.0.0.1(255.255.255.255), 10.110.143.0(255.255.255.192)
D nrpe Binding to: [::]:5666(ipv6)
D nrpe Attempting to bind to: [::]:5666(ipv6)
D nrpe Binding to: 0.0.0.0:5666(ipv4), reopen: true, reuse: true
D nrpe Attempting to bind to: 0.0.0.0:5666(ipv4)
D core Loading plugin: NSCAClient
D core Loading plugin: NSClientServer
D check_nt Allowed hosts definition: 127.0.0.1(255.255.255.255), 10.110.143.0(255.255.255.192)
D check_nt Binding to: [::]:12489(ipv6)
D check_nt Attempting to bind to: [::]:12489(ipv6)
D check_nt Binding to: 0.0.0.0:12489(ipv4), reopen: true, reuse: true
D check_nt Attempting to bind to: 0.0.0.0:12489(ipv4)
D core NSClient++ - 0.4.4.23 2016-04-05 Started!
D core C:\Program Files\NSClient++/modules\CommandClient.dll.dll
D core adding C:\Program Files\NSClient++/modules\CommandClient.dll
D core Loading plugin: CommandClient.dll...
D cli Enter command to execute, help for help or exit to exit...
CheckLogFile_Hibernate
D ext-script Command line: scripts\check_log3.exe -l "C:\***\Logs\AGTSG\JBoss\hibernate.log" -P "C:\Program Files\NSClient++\PatternFiles\PatternTraxTSG.txt" --show-filename
L cli WARNING: WARNING: Found 10 lines (limit=1/0): 2020-11-30 12:54:39,031 [DefaultQuartzScheduler_Worker-3] ERROR org.hibernate.util.JDBCExceptionReporter - Unable to get managed connection for com.trax.hibernate.DataSource; - nested throwable: (javax.resource.ResourceException: Unable to get managed connection for com.trax.hibernate.DataSource) [C:\***\Logs\AGTSG\JBoss\hibernate.log]
L cliPerformance data: 'lines'=10

Re: Observing "returned an invalid return code: 255" for win

Posted: Thu Dec 10, 2020 5:59 pm
by cdienger
Thanks for the data. Run the nscp test on the command line again and then run the check_nrpe plugin. Provide the output that nscp test provides when the check_nrpe plugin is run.

Re: Observing "returned an invalid return code: 255" for win

Posted: Fri Dec 11, 2020 2:53 am
by Amit_Alone
Here is the o/p for the requested plugin.

Code: Select all

C:\Program Files\NSClient++>nscp test
L	client Module: CommandClient
L	client Command:
L	client Extra Query:
L	client Mode: 3
L	client Boot: 1
L	client Load All: 0
L	client Warning module and boot specified only THAT module will be loaded
L	client Arguments:
D	core NSClient++ 0.4.4.23 2016-04-05 x64 Loading settings and logger...
D	core Settings not ready so we cant lookup: base-path
D	core Settings not ready so we cant lookup: exe-path
D   settings Boot.ini found in: C:\Program Files\NSClient++/boot.ini
D	core Settings not ready so we cant lookup: shared-path
D   settings Activating: ini://${shared-path}/nsclient.ini
D   settings Creating instance for: ini://${shared-path}/nsclient.ini
D	core Settings not ready so we cant lookup: shared-path
D   settings Loading: C:\Program Files\NSClient++/nsclient.ini
D       core NSClient++ 0.4.4.23 2016-04-05 x64 booting...
D       core Booted settings subsystem...
D       core On crash: restart: NSCP
D       core Archiving crash dumps in: C:\Program Files\NSClient++/crash-dumps
D       core booting::loading plugins
D       core Found: CheckDisk
D       core Found: CheckEventLog
D       core Found: CheckExternalScripts
D       core Found: CheckHelpers
D       core Found: CheckSystem
D       core Found: CheckWMI
D       core Found: NRPEServer
D       core Found: NSCAClient
D       core Found: NSClientServer
D       core C:\Program Files\NSClient++/modules\CheckDisk.dll.dll
D       core adding C:\Program Files\NSClient++/modules\CheckDisk.dll
D       core C:\Program Files\NSClient++/modules\CheckEventLog.dll.dll
D       core adding C:\Program Files\NSClient++/modules\CheckEventLog.dll
D       core C:\Program Files\NSClient++/modules\CheckExternalScripts.dll.dll
D       core adding C:\Program Files\NSClient++/modules\CheckExternalScripts.dll
D       core C:\Program Files\NSClient++/modules\CheckHelpers.dll.dll
D       core adding C:\Program Files\NSClient++/modules\CheckHelpers.dll
D       core C:\Program Files\NSClient++/modules\CheckSystem.dll.dll
D       core adding C:\Program Files\NSClient++/modules\CheckSystem.dll
D       core C:\Program Files\NSClient++/modules\CheckWMI.dll.dll
D       core adding C:\Program Files\NSClient++/modules\CheckWMI.dll
D       core C:\Program Files\NSClient++/modules\NRPEServer.dll.dll
D       core adding C:\Program Files\NSClient++/modules\NRPEServer.dll
D       core C:\Program Files\NSClient++/modules\NSCAClient.dll.dll
D       core adding C:\Program Files\NSClient++/modules\NSCAClient.dll
D       core C:\Program Files\NSClient++/modules\NSClientServer.dll.dll
D       core adding C:\Program Files\NSClient++/modules\NSClientServer.dll
D       core Loading plugin: CheckDisk
D       core Loading plugin: CheckEventLog
D       core Loading plugin: CheckExternalScripts
D ext-script No aliases found (adding default)
D       core Loading plugin: CheckHelpers
D       core Loading plugin: CheckSystem
D       core Loading plugin: CheckWMI
D       core Loading plugin: NRPEServer
D       nrpe Allowed hosts definition: 127.0.0.1(255.255.255.255), 10.110.143.0(255.255.255.192)
D       nrpe Binding to: [::]:5666(ipv6)
D       nrpe Attempting to bind to: [::]:5666(ipv6)
D       nrpe Binding to: 0.0.0.0:5666(ipv4), reopen: true, reuse: true
D       nrpe Attempting to bind to: 0.0.0.0:5666(ipv4)
D       core Loading plugin: NSCAClient
D       core Loading plugin: NSClientServer
D   check_nt Allowed hosts definition: 127.0.0.1(255.255.255.255), 10.110.143.0(255.255.255.192)
D   check_nt Binding to: [::]:12489(ipv6)
D   check_nt Attempting to bind to: [::]:12489(ipv6)
D   check_nt Binding to: 0.0.0.0:12489(ipv4), reopen: true, reuse: true
D   check_nt Attempting to bind to: 0.0.0.0:12489(ipv4)
D       core NSClient++ - 0.4.4.23 2016-04-05 Started!
D       core C:\Program Files\NSClient++/modules\CommandClient.dll.dll
D       core adding C:\Program Files\NSClient++/modules\CommandClient.dll
D       core Loading plugin: CommandClient.dll...
D        cli Enter command to execute, help for help or exit to exit...
check_nrpe
E       core Unknown command(s): check_nrpe available commands: commands {, alias_cpu, alias_cpu_ex, alias_disk, alias_disk_loose, alias_event_log, alias_file_age, alias_file_size, alias_mem, alias_process, alias_process_count, alias_process_hung, alias_process_stopped, alias_sched_all, alias_sched_long, alias_sched_task, alias_service, alias_service_ex, alias_up, alias_volumes, alias_volumes_loose, check_always_critical, check_always_ok, check_always_warning, check_counter, check_cpu, check_critical, check_drivesize, check_eventlog, check_files, check_memory, check_multi, check_negate, check_ok, check_os_version, check_pagefile, check_pdh, check_process, check_service, check_timeout, check_uptime, check_version, check_warning, check_wmi, checkalwayscritical, checkalwaysok, checkalwayswarning, checkcounter, checkcpu, checkcritical, checkdrivesize, checkeventlog, checkfiles, checklogfile_activemq, checklogfile_hibernate, checklogfile_server, checklogfile_tsg-inventories, checklogfile_tsgactivemq, checklogfile_tsghibernate, checklogfile_tsgscheduler, checklogfile_tsgserver, checklogfile_tsgswift_connector, checklogfile_tsgswift_fileact, checklogfile_tsgswift_fin, checklogfile_tsgtransmission, checkmem, checkmultiple, checkok, checkprocstate, checkservicestate, checkuptime, checkversion, checkwarning, checkwmi, filter_perf, negate, nsca_submit, render_perf, restart_service, timeout, xform_perf}, plugins {, 0, 1, 2, 3, 4, 5, 7}
				c:\source\nscp\service\NSClient++.cpp:894
E        cli Failed to execute command
				c:\source\nscp\include\nscapi\nscapi_core_wrapper.cpp:159
E        cli Failed to execute command: check_nrpe
				c:\source\nscp\include\nscapi\nscapi_core_helper.cpp:95
L        cli UNKNOWN: Unknown command(s): check_nrpe

Re: Observing "returned an invalid return code: 255" for win

Posted: Fri Dec 11, 2020 4:03 pm
by cdienger
I'm working with check_nrpe 4.0.3, check_log3.exe 3.16.2(https://github.com/pmcaulay/nagios-plug ... k_log3.exe), and nsclient 5.2.35, and was able to get an error with running the plugin via check_nrpe:

Code: Select all

Unable to open 'C:\Program': No such file or directory
If I put the patterns file in a directory that does not contain spaces then the check_nrpe command gets a valid response. I think you're probably running into the same problem but seeing a different error message due to the versions in your environment.