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"
Perl script integrating to NSclient++
Re: Perl script integrating to NSclient++
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:
It seems like you have set up a wrapper for .pl files:
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:
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
Code: Select all
perl -v
Code: Select all
[/settings/external scripts/wrappings]
; Perl scripts
pl = "C:\\\\strawberry\\\\perl\\\\bin\\\\perl.exe" scripts\\\\%SCRIPT% %ARGS%
Code: Select all
# A list of wrapped scripts (ie. script using a template mechanism).
[/settings/external scripts/wrapped scripts]
https://docs.nsclient.org/reference/che ... ed-scripts
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
Re: Perl script integrating to NSclient++
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
[/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
- Attachments
-
- Output.txt
- output
- (219 Bytes) Downloaded 378 times
-
- test.pl
- perl script
- (3.49 KiB) Downloaded 406 times
Re: Perl script integrating to NSclient++
Try defining the command in the nsclient.ini like the following example and see if it works.
I think that the perl.exe is not in the path on the system, you need to put the full path in the command.
Code: Select all
HWHP = c:\strawberry\perl\bin\perl.exe "C:\Program Files\NSClient++\check_hpasm.pl -H 127.0.0.1"
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Perl script integrating to NSclient++
is there anyting which i can the last exit code from the perl script
Re: Perl script integrating to NSclient++
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?
When you are running the check, what is the exit code you are receiving?
Be sure to check out our Knowledgebase for helpful articles and solutions!