Jump to content

How to log the over all cpu usage


Recommended Posts

i want to create a script that monitor the cpu usage. but i dont know how to start.

any can share there script is highly appreciated..

thank you in advanced.

julius

-----------------------------------------------------------BSECE, MCPAIM: juliusrmsYM: jivy_21@yahoo.comMSN: juliusLramos@hotmail.comMobile #: (Globe): +639167031989Web: http://www.trendmicro.com

Link to post
Share on other sites
  • Moderators

I think gary wrote this... guess you could just do a filewrite() to log everything.

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
While 1
    $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor", "WQL", _
            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If IsObj($colItems) Then
        For $objItem In $colItems
            If Int($objItem.LoadPercentage) <> 100 Then
          ; do something here
                ToolTip("Your CPU Usage is: " & $objItem.LoadPercentage & "%", 0, 0)
            EndIf
        Sleep(1000)
        Next
    EndIf
Sleep(100)
WEnd
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to post
Share on other sites

I think gary wrote this... guess you could just do a filewrite() to log everything.

$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
While 1
    $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor", "WQL", _
            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If IsObj($colItems) Then
        For $objItem In $colItems
            If Int($objItem.LoadPercentage) <> 100 Then
          ; do something here
                ToolTip("Your CPU Usage is: " & $objItem.LoadPercentage & "%", 0, 0)
            EndIf
        Sleep(1000)
        Next
    EndIf
Sleep(100)
WEnd
when i run this script i encountered an error.:

Variable used without being declared.:

$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor", "WQL",$wbemFlagReturnImmediately + $wbemFlagForwardOnly)

$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor", "WQL",^ ERROR

-----------------------------------------------------------BSECE, MCPAIM: juliusrmsYM: jivy_21@yahoo.comMSN: juliusLramos@hotmail.comMobile #: (Globe): +639167031989Web: http://www.trendmicro.com

Link to post
Share on other sites
  • Moderators

what is the value of $wbemFlagReturnImmediately

Oh you have to guess that... :P Lmao... just kidding

$wbemFlagReturnImmediately = 0x10

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to post
Share on other sites

I think gary wrote this... guess you could just do a filewrite() to log everything.

$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
While 1
    $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Processor", "WQL", _
            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If IsObj($colItems) Then
        For $objItem In $colItems
            If Int($objItem.LoadPercentage) <> 100 Then
         ; do something here
                ToolTip("Your CPU Usage is: " & $objItem.LoadPercentage & "%", 0, 0)
            EndIf
        Sleep(1000)
        Next
    EndIf
Sleep(100)
WEnd
is this code support also win 9x ? Edited by Julius Ramos

-----------------------------------------------------------BSECE, MCPAIM: juliusrmsYM: jivy_21@yahoo.comMSN: juliusLramos@hotmail.comMobile #: (Globe): +639167031989Web: http://www.trendmicro.com

Link to post
Share on other sites
  • Moderators

I don't know.. have you tried it to see?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to post
Share on other sites
  • Moderators

Hmmm, didn't look at the whole post :P? It was a bad copy and paste on my behalf... I'll edit the other one now.

http://www.autoitscript.com/forum/index.ph...ndpost&p=136885

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to post
Share on other sites
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...