cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 10

Execute External Program Via Alert Trigger Action

In the Alert Trigger Action, I am seeing an option to execute an external program. I am not sure what is the exact meaning of this. Let's say I have deployed an exe (created using Console application in .Net) on the Orion Web Server. Can I call this exe? Can I access the Alert variables inside an exe? Or execute an external program refers to calling a program installed on a node and not the Orion web server? Please help.

0 Kudos
6 Replies
Level 10

Hey there, you can call it with any of the items you normally use in E-Mails or notifications, including the reqults of an SQL query.  Here's what I call to put the results of a traceoute into an alert when a remote node goes down so we can see where the connection died.

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -Command "C:\SolarWindsScripts\tracert_in_alert.ps1 -AlertObjectID ${N=Alerting;M=AlertObjectID} -IP_Address ${SQL: SELECT top 1 IPAddress FROM [dbo].[NodeIPAddresses] where nodeid=${N=SwisEntity;M=NodeID}  and ipaddresstype='IPv4'}"

0 Kudos
Level 10

Would you care to share your script with us? Or is there documentation from SolarWinds on this?

0 Kudos
Level 10

Sure.  It's pretty basic, but it's useful IMO, so see how to shove stuff into an alert note.  Just like the top 10 processes guy, run this, give 1 minute or whatever for the tracert to complete and then put ${N=Alerting;M=Notes} in your alert

Param(

  [int32]$AlertObjectID,

  [string]$IP_Address

)

if (-not (Get-PSSnapin | where {$_.Name -eq "SwisSnapin"})) {

    Add-PSSnapin "SwisSnapin"

}

$swis = Connect-Swis –Trusted –Hostname localhost 

if ($ip_address)

{

$newnote = &"C:\Windows\System32\TRACERT.EXE" -w 500 -h 15 $IP_Address  2>&1 | out-string

}

else

{

$newnote = "No external IP address found"

}

$result = Invoke-SwisVerb $swis Orion.AlertActive AppendNote @( @( $AlertObjectID ), $newnote )

An issue has been detected at ${N=Alerting;M=AlertTriggerTime;F=DateTime} on ${N=SwisEntity;M=MachineType} device named ${N=SwisEntity;M=Caption} (IP: ${N=SwisEntity;M=IP_Address}, DNS: ${N=SwisEntity;M=DNS})

${N=Alerting;M=Notes}

Level 10

Ok. I figured out that I can call an exe. Now my question is how to pass Alert variables as parameters to this exe. Please let me know. I am able to pass hard coded strings as parameters to my exe, but not the Alert Variable. Please help.

0 Kudos
Level 10

But when called from multiple alerts concurrently, won't a lock be placed on the exe by the first caller?

0 Kudos
Level 10

I am also able to pass an argument like passing it to a regular exe, but param like AlertID, but not AlertDetailsURL. Please help

0 Kudos