Go to All Forums

Providing input parameters to plugins

It doesn't seem that I can have my plugin (PowerShell) read any files or user-defined environment variables on execution.

I have a plugin that returns stats about a folder. While the plugin is the same on each machine, the folder I want it to monitor differs on each. I tried setting an environment variable for the script to read ($env:<variable>) but it seems unable to do so. I've previously tried to get plugins to read from a configuration file and haven't had any luck there either.

I saw something about allowing a <plugin>.json file and it may be able to use it for some sort of input or configuration but I didn't see any details on how to use it or what was possible there. Is there a way to provide inputs or other machine-specific configuration into a plugin?

Like (2) Reply
Replies (1)

Re: Providing input parameters to plugins

Hi Kevin,

You can use system environment variable inside the script to get the value, but the agent cannot automatically read the user environment variables.

If you want the server agent to read the user environment variables, please follow the steps below:

  1. Site24x7 Windows Agent in services -> Right click -> Open ->Click Log On -> Choose This account and configure username and password. (PFA screenshots )
  2. Once the Log On option for the user is configured, it can access the user environment variables. Else you can configure it as System environment variables. 

<Plugin>.json file can be used to create multiple plugins from a single plugin to change only the input passed to the plugin script. It cannot handle environment variables. But you can tweak your plugin to read the environment variable names from the JSON and use a command to read the environment variable value and process that data.

For eg:

As you have mentioned you want to read some stats from a folder from different machines, you can change your plugin script to get inputs like hostname, username, and password to access, the folder path to monitor from the JSON like below.


"localhost":  {
  "user" : "test" ,
  "password", "***",
  "folderpath" : "ENVRONMENT-VARIABLE-NAME" },

"remotehost":  {
  "user" : "test" ,
  "password", "***",
  "folderpath" : "ENVRONMENT-VARIABLE-NAME" }

Inside the powershell script, define the variable used in the json


And you can use the variables $host,$user,$password,$env:$folderpath in your plugin script and access according to your requirement.

Let us know if this helps. If you have any queries, please comment in the below thread. 




Like (0) Reply

Was this post helpful?