Monitoring Automation Guide: Integrating PRTG with ScriptRunner

Author: | Reading time: 3 minutes | Category: Automation

Monitoring Automation mit PRTG und ScriptRunner

This article has been translated automatically.

In this technical guide we show you how to integrate the monitoring system PRTG into ScriptRunner. This starts the Monitoring Automation with PowerShell.

The integration of Paessler PRTG into ScriptRunner

Basic principle for integration with PRTG

  1. Sensor triggers a notification
  2. Notification starts a PowerShell caller script with parameter takeover from PRTG -> call via Execute Command structure of PRTG
  3. Script triggers a WebSvc POST call to ScriptRunner
  4. The POST call starts an action “Action name” on the ASR backend and gets the necessary parameters transferred.
  5. The script of the action can call further actions in ScriptRunner via WebSvc-POST -> Reaction Cascade
  6. A feedback function to the monitoring system can be accommodated in the script, e.g. an “Add Comment” function call and transfer of $SRXEnv.ResultMessage to the monitoring system.

Call via Execute Command

https://www.paessler.com/manuals/prtg/notifications

Configuring Notification

https://www.paessler.com/manuals/prtg/notifications

https://www.paessler.com/manuals/prtg/sensor_notifications_settings

https://www.paessler.com/manuals/prtg/settings

Available variables in PRTG

https://kb.paessler.com/en/topic/373-what-placeholders-can-i-use-with-prtg

Prerequisites

  • ScriptRunner must be installed and configured
  • PRTG must be installed and configured.
  • Connection between PRTG host and ScriptRunner host must be established.
  • The relevant local firewall must allow the Web service connection on the ASR port Inbound/Outbound.

Preparations

  • The permissions to run PowerShell scripts must be set on the PRTG host
    • execution policy
  • Target System: The permissions to run PowerShell scripts and the settings for PowerShell remoting must be configured.
    • The Config Wizard from the ScriptRunner Setup Zip can be used for this purpose.
    • The administrative account to run the script on the target system must be a member of the Remote Management Users group.
  • Active Directory
    • Creating an ASR Monitoring Group
    • Include the PRTG-AD user, in whose user context the caller script on the PRTG host is started by a notification, in the group “ASR-Monitoring”.
  • ScriptRunner Host
      • Create a new operator group in ScriptRunner and assign it to the AD group “ASR-Monitoring”; this ensures that only accounts that are stored in ASR-Monitoring can start the monitoring automation on dedicated assigned actions (see Delegate Functionality).

Example Automation

The example automation reacts to a manually stopped Windows service on a target system and restarts it there.

Commissioning of a sample automation system on PRTG

  • Copy the caller script “StartActionExt.ps1” from the ZIP package for PRTG to …NotificationEXE
  • Changes in the script
    • URL/Port of the ASR host
  • Application of the system to be monitored as well as the sensor to an example service (spooler, DPS, etc.)
  • Setup -> Notifications -> Add new Notification -> a trigger is created pw. state trigger

PRTG Integration Ac

  • Program file: Name of the caller script -> here “StartActionExt.ps1”.
  • Parameters: -ActionName Repair Service -ParamNames mysensor, mytarget, mystatus -ParamValues ´%sensor´, ´%server´, ´%status´
  • Domain or computer name: Domain of the calling user.
  • Username: User name of the calling user (this user must be a member of the previously created “ASR-Monitoring” group).
  • Password: Password of the calling user
  • Timeout: Time out for the call -> here you have to test how long it takes to start the action in the respective environment

Functionality of the Caller Script

  • Input – ActionName = Name of the action in ScriptRunner that is to be called -> here Repair-Service
  • Input – ParamNames = “Parameter names for the action script” -> here mysensor, mytarget, mystatus
  • Input – “ParamValues” = variable contents of PRTG -> here ‘%sensor’, ‘%server’, ‘%status’ in simple hock quotes
  • Output – Report ID, ResultMessage and Report; (corresponds to the output of the action script in ScriptRunner).
  • The ScriptRunner action with “ActionName” is called with -UseDefaultCredentials via WebService and the parameters are transmitted in JSON format to the called action.

Important information:

  1. Name of the monitoring sensor %sensor must correspond to the name of the monitored service for the example script.
  2. Action name when calling the caller script must correspond to the action name in ScriptRunner and be adapted accordingly on both sides. (here Repair-Service)
  3. ParamNames and ParamValues (green and yellow) form pairs that belong together. The names of the parameters in ParamNames must match those in the action script. The transferred ParamValues can then be further processed in the action script.

Commissioning of the automation on ScriptRunner

  • Copy the action script into the ScriptRunner script directory.
  • In ScriptRunner, configure an action for this script and release or authorize it for the ASR Monitoring group.
    • Without target system (Direct Local Execution)

Testing

Test steps on ScriptRunner

  • Start the Delegate App in the context of the caller (user entered in PRTG as calling user for the caller script).
    1. Shift-right mouse pointer -> execute as other user
    2. Delegate App starts in this user context
  • or:
    1. Log in as this user

  1. In the Delegate App, the action to be executed must appear as a tile, if not then
    1. check if the action is assigned to the ScriptRunner Operator group
    2. Check whether the caller was entered in the corresponding AD group.
  2. Simulation/test of the actuator
    1. Stopping the sensor-monitored service on the target system
    2. Start the action in the Delegate App
      1. Enter parameters
    3. Check whether the service was restarted on the target system.
  3. Simulation/Test of the WebSvc Call
    1. Copying the caller script to the ScriptRunner host
    2. Start ISE in the context of the caller (user entered as calling user in the PRTG notification / EXECUTE PROGRAM).
    3. Calling the caller script with the parameters in the ISE
      1. Check in ISE whether the caller script was executed without errors.
      2. Check in ScriptRunner Admin App whether the action to be executed was started or executed.
      3. In ScriptRunner Admin App, check the report about the execution.

If all these steps could be performed successfully, the ScriptRunner is set up for the Automation Case.

Test steps on PRTG

  1. Start the ISE in the user context of the user entered under EXECUTE PROGRAM.
  2. Simulation/Test of the WebSvc Call
    1. Stopping the sensor-monitored service on the target system
    2. Start the ISE in the context of the caller (user entered as calling user in the PRTG notification / EXECUTE PROGRAM).
    3. Calling the caller script with the parameters in the ISE
      1. Check in ISE whether the caller script was executed without errors.
      2. Check in ScriptRunner Admin App whether the action to be executed was started or executed.
      3. In ScriptRunner Admin App, check the report about the execution.
    • Check if connection is possible, the WebSvc port on the ScriptRunner host is enabled for inbound.
    • Check if the permission settings are correct
    • Check whether the execution policy for PowerShell has been configured on the PRTG host.
  3. Simulation/test of the actuator with notification
    1. Stopping the sensor-monitored service on the target system
    2. Waiting for alarm/trigger in PRTG
    3. If service in “Down” status enters PRTG Log Console
      1. Short overview of the log via popup
    4. Check the log. An entry about Start EXE with a message must appear
    5. Check for possible error messages
    6. Check if action was started in ScriptRunner
    7. Check whether the sensor-monitored service was restarted on the target system.

If you have questions about integrating PRTG with Scriptrunner please contact us!

These blog posts might also be interesting for you:

Secure Password Server, PowerShell
ScriptRunner 2019R1, Network, Multi-Team
ScriptRunner Version 2018R3