Internal documentation only
This page has been marked as draft.
Infrastructure Agent - Windows Agent - PowerShell scripts
The Infrastructure Agent can be customised by adding your own plugins. These plugins can be written in any language supported by your OS.
To add in your own PowerShell based custom plugin into the Windows Infrastructure (Beta) agent, follow these steps
Prereqs Copied
- The Windows Infrastructure Agent has already been installed, configured and proven as working in the Opsview UI
- Your Server has a minimum of PowerShell 5 or later
Assumptions Copied
- The Windows server is called
MyWinSvr - The PowerShell script is called
check_my_psscript.ps1
Steps Copied
On the Windows server Copied
-
Place your PowerShell script in the directory
C:\Program Files\Infrastructure Agent\plugins\imported\ -
Ensure the script works correctly on the server using the PowerShell IDE or Command shell prompt
-
Create or amend
C:\Program Files\Infrastructure Agent\cfg\custom\agent.ymland add in the following code either at the bottom of the file or added into the existing “commands” section:commands: check_my_psscript: path: PowerShell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File C:/Program\ Files/Infrastructure\ Agent/plugins/imported/check_my_psscript.ps1 $ARG1$Note: you only need to specify
$ARG1$, regardless how many options the plugin uses -
Restart the
Infrastructure Agentusing theServicesapplication tool
In the Opsview UI Copied
- Go to
Menu bar => Configuration => Service Checks, locate theWindows - Drivecheck, click on the contextual menu button and selectClone - On the
Service Checkstab, amend theNameto beMy PS Scriptand set an appropriateDescription - On the
Plugin and Argumentstab, amend theArgumentsfield as follows, ensuring any quoting around options are preserved:- Change the
-coption fromnsc_checkdrivesizetocheck_my_psscript(to match theagent.ymlconfiguration) - Change the
-aoption fromDrive=%WINDOWS_DRIVE%: %WINDOWS_DRIVE:1%to the arguments required for your script
- Change the
- Go to
Menu bar => Configuration => Hosts => MyWinSvr, on theService Checkstab, expandOS => Windows Baseand select theMy PS ScriptServicecheck created in step 3. - Run an “Apply Changes”
Further Information Copied
Documentation for Infrastructure Agent is available here