1 Reply Latest reply on Apr 2, 2015 12:10 PM by spkcadet

    VBScripting notification emails

    spkcadet

      So I have finally gotten tired of running in circles trying to track this down, and I imagine that someone out there is doing the same thing that I am attempting to do.  So we have this 350 line long VBScript that we used to run in WhatsUp Gold to send out alert emails dependent on the details listed on the device.  This should be a pretty simple transfer from the WUG instance to SolarWinds, however, I am clearly missing something here.  I cannot nail down the variables for SolarWinds to pull information.  I read somewhere to use ${name} however this obviously doesnt work because it isnt even valid VBScript syntax.  I also tried a suggestion somewhere that said to pull from WScript.Arguments and that doesnt work either.  Here is a small script that I was playing with (in this case using the WScript Arguments) to try and test this.  Please advise.

       

      option explicit


      dim strSMTPTo, strSMTPFrom, strSMTPSubject, strBody, strSMTPNARelay

      dim sHostname, objArgs

      dim objMessage

       

      Set objArgs = WScript.Arguments

      Set objMessage = CreateObject("CDO.Message")

       

      sHostname = objArgs.Item(0)

      strSMTPNARelay = "test.relay"

      strSMTPFrom = "solarwinds@domain.com"

      strSMTPTo = "admin@domain.com"

      strSMTPSubject = "Solarwinds Test Message"

      strBody = "This is the hostname or something... " & sHostname

       

      objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

      objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPNARelay

      objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

      objMessage.Configuration.Fields.Update

       

      objMessage.From = strSMTPFrom

      objMessage.To = strSMTPTo

      objMessage.Subject = strSMTPSubject

      objMessage.TextBody = strBody

       

      objMessage.Send

        • Re: VBScripting notification emails
          spkcadet

          Alright, I figured it out myself.

           

          Under alert manager you go to View -> Configure Alerts

           

          Browse to the alert that you would like to modify -> Edit

           

          Under the "Trigger Actions" tab you click on the "Edit Selection Actions" button and under the VBScript tab where the script sits to be executed you add the variables there like such:

           

          C:\Scripts\testscript.vbs "${SysName}" "${IP_Address}"

           

          The variables go in order that they are put in there, so in this instance "${SysName}" would sit in the (0) position, "${IP_Address}" would be in the (1) position and so forth.

           

          I also feel like this goes without saying, but still worth mentioning.  Make sure that your script interpreter is set to WScript.exe since an object was set to that specifically.