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.

How to run powershell script and monitor output

Hi,
I would like to monitor the amount of free licenses on some server. I wrote powershell script which output is a number. It works from powershell terminal. How can I run it by Solarwinds to trigger some alert if the number of free licenses is lower than the threshold?
Powershell script:
$command = "plink -l root -batch -pw password server_ip /path_to_script/licleft.sh"
Invoke-Expression -command $command
Exit(0);

  • All of the script components in SAM read the output to the host. You can have 10 items per component, each with a statistic and a message. 

    Here's an example I stole out of a PowerShell script component for a SaaS application. 

    Write-host "Message.Ping: Ping to $server"
    Write-host "Statistic.Ping: $Ping"
    Write-Host "Message.time: MS to pull 10 records from $server"
    Write-Host "Statistic.time: $time"
    Write-Host "Message.count: Number of records on $server"
    Write-Host "Statistic.count: $Count"

    You need to start with either Message or Statistic, and the second part can be however you want to group it. 

  • Thanks. That really helped me, I can see it in an SAM now.

    I tried to build swql query to create dashboard widget, but without success. I can't find SWQL parameter that is responsible of this script output value. Do You have any advice how can i do it? 

  • Here's something that should work to show the current component message and statistic with status icons and clickable links to the detail url's for both on a node details view. There may be a better way to pull in the status icons but that's what transpires at all hours of the night.

    Hope this helps. This query has also been posted here in the content exchange: thwack.solarwinds.com/.../2982

    SELECT 
         c.Name AS [Component]
        ,c.Application.Name AS [Application]
        ,c.ComponentAlert.ComponentMessage AS [Message]
        ,c.ComponentAlert.StatisticData AS [Statistic]
        ,c.Application.DetailsUrl AS [_LinkFor_Application]
        ,c.DetailsUrl AS [_LinkFor_Component]
        ,CONCAT('/Orion/images/StatusIcons/Small-', si1.StatusName, '.gif') AS [_IconFor_Component]
        ,CONCAT('/Orion/images/StatusIcons/Small-', si1.StatusName, '.gif') AS [_IconFor_Application]
    FROM Orion.APM.Component AS c
    LEFT JOIN Orion.StatusInfo AS si1 ON si1.StatusId = c.Status
    LEFT JOIN Orion.StatusInfo AS si2 ON si2.StatusId = c.Application.Status
    WHERE ( c.ComponentType = 45 
    AND c.Status != 27
    AND c.Application.Node.NodeID = ${NodeID} )

  • You should share this query in the Content Exchange / The Orion Platform / Custom Queries area for easy access.  Just add the tag "Node Details" so we know it's supposed to be on a Nice Details page.