Sign in to follow this  
Followers 0
Julius Ramos

How to log the over all cpu usage

12 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

[center]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.[/center]

Share this post


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

Share this post


Link to post
Share on other sites

what is the value of $wbemFlagReturnImmediately


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

Share this post


Link to post
Share on other sites

what is the value of $wbemFlagReturnImmediately

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

$wbemFlagReturnImmediately = 0x10

[center]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.[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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


[center]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.[/center]

Share this post


Link to post
Share on other sites

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


[center]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.[/center]

Share this post


Link to post
Share on other sites

is this code support also win 9x ?

The code quoted relies on WMI functionality, which if I recall is not installed by default on Win9x machines by default.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0