Page 1 of 1

Perl script integrating to NSclient++

Posted: Fri Apr 21, 2017 4:00 am
by bosco
Perl script integrating to NSclient++

Hi i have a Perl script for checking the date in a .ini file and service status and if not running will throw critical alert. i would like to know how to integrate that script in nsclient++.cfg file as i am first time using perl script and i know its similar to the pwershell integration,can you share from below which is the right method for intgrating this in nsclient++.cfg file

[/settings/external scripts/wrappings]
; Perl scripts
pl = "C:\\\\strawberry\\\\perl\\\\bin\\\\perl.exe" scripts\\\\%SCRIPT% %ARGS%


[External Scripts]
[...]
check_oracle_cman=perl scripts\check_oracle_cman.pl --mode="$ARG1$" --environment="C:\oracle\client11g"

Re: Perl script integrating to NSclient++

Posted: Fri Apr 21, 2017 1:10 pm
by mcapra
The biggest obstacle is getting Perl to run correctly in the Windows environment. Does perl resolve correctly? What's the output from command prompt when you type:

Code: Select all

perl -v
It seems like you have set up a wrapper for .pl files:

Code: Select all

[/settings/external scripts/wrappings]
; Perl scripts
pl = "C:\\\\strawberry\\\\perl\\\\bin\\\\perl.exe" scripts\\\\%SCRIPT% %ARGS%
But aren't defining your perl script as a "wrapped script". In order for the wrapping to apply, you will need to define your external script under the "wrapped scripts" section like so:

Code: Select all

# A list of wrapped scripts (ie. script using a template mechanism).
[/settings/external scripts/wrapped scripts]
Refer to this section of the NSClient++ documentation to get your wrapping to apply to your .pl script:
https://docs.nsclient.org/reference/che ... ed-scripts

Re: Perl script integrating to NSclient++

Posted: Wed Apr 26, 2017 4:33 am
by bosco
I have attached the perl script i am using,it works fine from the machine and give the result in output.txt(attached),now i want Perl script to be run from nagios by integrating to Nsclient.cfg,can you please see how this to bee added anything simialir to wehat i previously did for powershell

[/settings/external scripts/scripts]
check_file-exist = cmd /c echo scripts\filecheckps.ps1; exit($LastExitCode) | powershell.exe -command -

[/settings/external scripts/wrapped scripts]

pl = perl\bin\perl

[/settings/external scripts/scripts]
HWHP = "perl\\bin\\perl scripts\\check_hpasm.pl -H 127.0.0.1"

I drilled down this URL and could not find the apt one

https://docs.nsclient.org/howto/externa ... ower-shell

last got some info from this URL

https://www.thomas-krenn.com/de/wiki/In ... ntegrieren

Re: Perl script integrating to NSclient++

Posted: Wed Apr 26, 2017 3:33 pm
by tgriep
Try defining the command in the nsclient.ini like the following example and see if it works.

Code: Select all

HWHP = c:\strawberry\perl\bin\perl.exe  "C:\Program Files\NSClient++\check_hpasm.pl -H 127.0.0.1"
I think that the perl.exe is not in the path on the system, you need to put the full path in the command.

Re: Perl script integrating to NSclient++

Posted: Thu Apr 27, 2017 3:59 am
by bosco
is there anyting which i can the last exit code from the perl script

Re: Perl script integrating to NSclient++

Posted: Thu Apr 27, 2017 9:58 am
by tgriep
In my test system, the exit code is returned to the Nagios system correctly using the example from my earlier post.
When you are running the check, what is the exit code you are receiving?