Announcement

Collapse
No announcement yet.

VBScript help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    VBScript help

    Hey guys, I am trying to write a script and event to email me if free memory gets low on my system. I am using Jon00's performance monitoring script and it is recording System Physical Memory Available in device Z31. The value will usually read something like this: 2060.99 MB

    I am trying to write a little script based event to look at that value and shoot me an email in the event that the value goes below 1000 MB.

    What I put together is below, but does not seem to be working.

    Sub Main()
    Dim Mem_Usage
    Mem_Usage = hs.DeviceValue("Z31")
    If Mem_Usage < 1000 Then hs.SetDeviceValue "v4","On"
    If Mem_Usage < 1000 Then hs.SetDeviceString "V4","High"
    If Mem_Usage > 1000 Then hs.SetDeviceValue "v4","Off"
    If Mem_Usage > 1000 Then hs.SetDeviceString "V4","Normal"
    hs.SetDeviceLastChange "V4", now
    End Sub

    I then setup an event that watches V4 to see if it switches to On or High.

    Any thoughts?

    #2
    This is HS2 yeah or HS3? a device value can only be an integer and you are trying to set it to a string, not sure if it lets you do that or not but in any case an event would not trigger if you did. You have a number of options that could be personal choice

    If Mem_Usage < 1000 Then hs.SetDeviceValue "V4", 1
    If Mem_Usage < 1000 Then hs.SetDeviceString "V4","High", True
    If Mem_Usage > 1000 Then hs.SetDeviceValue "v4", 0
    If Mem_Usage > 1000 Then hs.SetDeviceString "V4","Normal", True

    The true at the end of the statement will eliminate the need to use the setdevicelastchange. You could then trigger on V4's value being 1 or 0.

    Comment


      #3
      Chewie,

      Why not use the built in triggering feature which prevents multiple triggering if it hovers around the trigger parameter?

      If you wish to do so, go to your Jon00PerfMon.ini file. Look for [System Physical Memory Available] heading. Beneath, change the following:

      LowValueTrigger=-99999 To LowValueTrigger=1000
      LowValueReset=-1 To LowValueReset=1100
      RunEventLow="Not set" to RunEventLow="<name of the event you wish to trigger>"

      In this example, the event is triggered when the value drops to 1000 or below. It will not re-trigger until the value increases to 1100 or above and then back down to 1000 or lower again.
      Jon

      Comment


        #4
        Oh wow, thanks Jon, I did not realize that was built into the script already!

        Thanks for the follow up guys!

        Comment

        Working...
        X