Passing Powershell script args to Nagios xi

This support forum board is for support questions relating to Nagios xi, our flagship commercial network monitoring solution.
G_Deshpande
Posts: 19
Joined: Tue Mar 17, 2020 1:50 pm

Passing Powershell script args to Nagios xi

Post by G_Deshpande »

Gents,

We have Powershell script to monitor folder & files within it present on windows server which has hard coded values of Directory/folder path, i want to pass these hard coded values present in script as an argument in Nagios xi while configuring/monitoring script.
Because every time i have to change code/path of folders in script on server, instead of that if i would have facility to pass in Nagios xi dynamically it would be great.

Sample Script of hard codded path-
param($Parentfolder='C:\Users\Desktop\projects',$subfolder='TEST',$flag='inclusion',$file_list=@('aaa','bbb','ccc'))
$searchfolder = $Parentfolder + '\' + $subfolder + '\'

I want to pass parent folder, Subfolder values & folder inclusion list in Nagios itself, how to achieve this?

Nagios xi- using 5.7.4 version
Using NRPE I am implementing powershell script

check_nrpe!Test_ps1!

I wish to pass folder path & folder inclusion list mentioned in the script to above syntax after check_nrpe!Test_ps1!
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Passing Powershell script args to Nagios xi

Post by benjaminsmith »

Hi @G_Deshpande,

You can achieve this by using either Macros or Custom Variables in Nagios xi to pass those directory paths. Below is a link to the documentation to help get you started. Let us know if you get it working or have any questions.

Understanding User Macros

Custom Object Variables

Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
G_Deshpande
Posts: 19
Joined: Tue Mar 17, 2020 1:50 pm

Re: Passing Powershell script args to Nagios xi

Post by G_Deshpande »

Thanks for revert.

Macros will be good option when an argument you are passing is constant value like $userx but in my case i will be using different directory paths & include, exclude folder name list as well.

I have used environment variables before but with event handlers, in my case i am not using any event handler to perform any action.

Can you suggest something easy to achieve approach where instead of mentioning different paths in scrip, i can pass in Nagios command?

Or do you have any example for this, how i can pass these values ?
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Passing Powershell script args to Nagios xi

Post by benjaminsmith »

Hi,

Normally, in this type of case, if I'm understanding the context correctly, this would be handled by the custom plugin or Test_ps1. You pass any required arguments to this script and then it would run the appropriate tests and return the results to Nagios.

For example,

Code: Select all

check_nrpe -H <ipaddress> -c test_ps1 -a <optional arguments 1,2,3....8>
Reference:
NRPE - Configuring NRPE Commands To Accept Arguments
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!