Fabien OPs (Customer) asked a question.

Powershell Active Monitor for CPU, RAM, Disks... with SNMP API?

Hello guys,

 

I want to create some Powershell Active Monitors for checking my Disks, CPU and RAM on my servers through SNMP. I know that Performance Monitors are making this job, but i want to execute an other Powershell script when the monitor goes down, and, as i know, Performance monitors only send mail or sms. (Maybe i'm wrong)

 

So, i made a script. it started with :

  1. # Create SNMP Object
  2. $oSnmp = New-Object -ComObject CoreAsp.SnmpRqst
  3. $nDeviceID = $Context.GetProperty("DeviceID")
  4. $oSnmp.Initialize($nDeviceID)

It works well but, when i enable it on two differents servers. I have this error :

  1. COM object that has been separated from its underlying RCW cannot be used. The COM object was released while it was still in use on another thread.

And the monitor goes up and down many times randomly. It's like WUG can't manage two ComObject in the same time. Or i don't use it as i should.

 

 

I also tried to create a PowerShell Active monitor without SNMP API, but, wug doesn't recognized "snmpwalk" & "snmpget" commands when i enable the monitor. However, they are installed on the wug server, and i can use it on powershell ?

 

Do you have any idea please?

 

Thanks

 


  • Fabien OPs (Customer)

    I finally figured it out.

     

    It was very simple indeed. I copied my commands (snmpwalk.exe and snmpget.exe) into the execution monitor folder : "C:\Program Files (x86)\Ipswitch\WhatsUp". Then, in my PowerShell Active monitor script, i executed them with ".\snmpget.exe". It works properly! :)

    Selected as Best
  • Mike Rockwell (Progress Software)

    One way we've been able to work around the Limitations of actions for Alert Center, is to use the API to pull the report information from the db, and then report on those via an action. The way I have done it is to use a PowerShell Script to collect the data from the API, write it to a CSV file. Then with a PowerShell Active Monitor, read the CSV file and report on it up or down and then fire any action in the library.

     

    The CoreAsp.SnmpRqst has issues. It doesn't clean up after its self well and will run out of threads if run too often.

     

    The good news it, in a future release, I don't know when but in a coming version, there are more actions being added to Alert Center.

  • Fabien OPs (Customer)

    Thanks Mike! :)

    Do you have an example of PowerShell Script to collect the data from the API please?

     

    And do you know why my Powershell Monitor doesn't recognize my cmdlets while the PowserShell of the WUG server does ?

    • Mike Rockwell (Progress Software)

      The WUG specific things "$Context....." only work in WUG.

       

      Go Here and install the WhatsUpGoldPS It makes using the API easier in PowerShell.

      • Fabien OPs (Customer)

        Thanks Mike.

        But i don't really need that module. I want that my PowerShell Monitor would be able to execute the same cmdlets as the server where it's installed. :(

  • Fabien OPs (Customer)

    I finally figured it out.

     

    It was very simple indeed. I copied my commands (snmpwalk.exe and snmpget.exe) into the execution monitor folder : "C:\Program Files (x86)\Ipswitch\WhatsUp". Then, in my PowerShell Active monitor script, i executed them with ".\snmpget.exe". It works properly! :)

    Selected as Best