This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Multiple output from Powershell Script Monitor

In the PowerShell Script Monitor, is it possible to get multiple output? If so, how? Also, is it possible to assign value from the output of a PowerShell Script Monitor to a custom property or if it has to be assigned within the script, can anyone please provide a sample? Will it be saved to the custom property, if assigned like that? Please provide examples with snippets.

  • Have a look in your  Powershell examples folder - Program Files (x86)\SolarWinds\Orion\APM\SampleScriptMonitors\PowerShellScripts emoticons_wink.png

  • Thanks for the quick response. But you haven't answered my other questions. Also, is the Statistic always mandatory? Looks like Statistic accepts only numeric values.

  • With a script monitor, you can return up to ten statistic/message pairs per script. And, yes, the statistic is mandatory and can only be a numeric value as you mentioned above.  The message part is optional.  In the instance where you are more interested in the message field, which can contain text, you can simply return a static number for the statistic field.

    Here is a good post about the various script monitors available in SAM:

    https://thwack.solarwinds.com/docs/DOC-188909

    1. In the PowerShell Script Monitor, is it possible to get multiple output? If so, how?

    Have a look in your  Powershell examples folder - Program Files (x86)\SolarWinds\Orion\APM\SampleScriptMonitors\PowerShellScript

       2. Also, is it possible to assign value from the output of a PowerShell Script Monitor to a custom property or if it has to be assigned within the script, can anyone please provide a sample?

    Not exactly sure what you mean here, the value (statistic and/or message) is stored in the database, against the application monitor and the device.

    Why would you want to assign to a custom property?

    If you are looking to set an alert on the statistic value, use a Component trigger and select the component's name and statistic data:

    pastedImage_2.png

    Have at look at the APM_Component table, this will tell you what is available and give you an idea of the data formats.

    And finally yes, the script must return at least one Statistic value which is a numeric value, Message is optional.

    If your script returns a string, then set the Statistic to a fixed value (e.g. Write-Host "Statistic: 1" ) and then ignore it (set no thresholds or alerts based of it), then you can use the Message to collect and store the collect string into your database.

  • Thanks again. What I am looking for is to be able to assign the Message to a Custom Property within the script and save the value of the custom property. Is this possible. I want to use that custom property in some custom dashboard.

  • Thank you. Is it possible to assign the value of Message to a custom property and save it from within the script?

  • Also, which table in DB stores the message text. If there is more than one message pair, where do they get stored (in which table)?

  • So, that is kind of a tricky question.  Technically, yes, you could set the custom property directly from the PowerShell script.  But, to do so would require using the Orion PowerShell snapin from the SDK.  And, if you are running the scripts on a remote host, each one would need the SDK installed, or alternatively use REST calls.

    An alternative to this would be to create an alert, like yaquaholic referenced above, that uses the "Change Custom Property' action to set the value equal to the value in the component statistic or message field.  The limitation to this would be that it would have to be a component custom property and not a node custom property.

  • Brian, components don't have custom properties emoticons_sad.png

    I've worked around this before using custom swql alerts to alert on a "node" with a bunch of joined component conditions

  • The "Message" output from a Powershell Script Monitor cannot be assigned to a custom property since there's no such thing as a "Custom Properties for Component Monitors".