Re: Got CPU Load incorrectly using script

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



thanks for your reply, but it is about two scripts. Only one script, it
returns normal value (or appears resonable).

but if run another after one, checkcpu.vbs first, checkmem.vbs got error
80041010 (but run chekmem.vbs only won't get error );

if checkmem.vbs first, checkcpu.vbs will not get error, but got unresonable
value of 100% all the time.

the scripts are very simple, so I think


'============checkcpu.vbs===============
strComputer = "."
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set wbemObjectSet = objWMIService.ExecQuery("Select * from
Win32_Processor",,48)
For Each wbemObject In wbemObjectSet
wscript.echo wbemObject.LoadPercentage
next
wscript.echo "0"
wscript.echo ""
wscript.echo ""
,=================end=====================

'============checkmem.vbs================
strComputer = "."
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set wbemObjectSet = objWMIService.ExecQuery("select * from
Win32_PerfFormattedData_PerfOS_Memory")
For Each wbemObject In wbemObjectSet
wscript.echo wbemObject.PercentCommittedBytesInUse
next
wscript.echo "0"
wscript.echo ""
wscript.echo ""
,=======================================


"Jim Vierra" <jvierra@xxxxxxx> дÈëÓʼþ
news:OEuJCVJaFHA.3808@xxxxxxxxxxxxxxxxxxxxxxx
> FYI - I ran your exact script on XPSP2 with NET 1.1 SP1 and NET 2.0
> Installed. Get 7% or less most of the time. Since this is an
instantaneous
> value it probably not much good. You need to use one of the "cooked"
> counters to get an average that is meaningful.
>
> I am not sure which is which but I am sure it is documented. Some
counters
> are for the system while the app is running and others are agnostic. I
> would read the SDK documentation very carefully to see which counter you
> really want and how to use it.
>
>
> --
> Jim Vierra
>
> "Yu Haitao David" <mshtyu@xxxxxxx> wrote in message
> news:%236Ruz7FaFHA.2288@xxxxxxxxxxxxxxxxxxxxxxx
> >I got this problem clearly after I install my .NET Framework 1.1 SP1:
> >
> > I have two scripts to check the CPU load and Memory usage, and I need to
> > run
> > them one by one to generate data for MRTG. After testing, I found this:
> >
> > 1. Run checkcpu.vbs first, it returns normal value, 5% for example.
There
> > appears a process named: wmiprvse.exe
> > 2. Run checkmem.vbs then, it gets error: 80041010
> >
> > if I kill the process wmiprvse.exe that appeared when doing step 1, I
> > change
> > the order of these two scripts:
> >
> > 1. Run checkmem.vbs first, it returns normally, another wmiprvse.exe
> > appears
> > 2. Run checkcpu.vbs then, it runs longer, and return 100% which is
> > incorrect
> >
> > anyone can help me on this?
> >
> >
> >
> > "Yu Haitao David" <davidyu@xxxxxxxxxxx> дÈëÓʼþ
> > news:OwSGKHBaFHA.2996@xxxxxxxxxxxxxxxxxxxxxxx
> >> Hi,
> >>
> >> I got my CPU load value of 100% whatever it really was in taskmgr.
> >>
> >> I tried using "Win32_Processor.LoadPercentage" and
> >> "Win32_PerfFormattedData_PerfOS_Processor_PercentProcessorTime", always
> >> 100%, while actually the load was below 20%.
> >>
> >> But the script works normally under win2k.
> >>
> >> My PC has winxp-sp1, and the script like the followings:
> >>
> >> '=================================
> >> On Error Resume Next
> >> strComputer = "."
> >> Set objWMIService = GetObject("winmgmts:\\" & strComputer &
> >> "\root\cimv2")
> >> Set colItems = objWMIService.ExecQuery("Select * from
> > Win32_Processor",,48)
> >>
> >> For Each objItem in colItems
> >> WScript.Echo "LoadPercentage: " & objItem.LoadPercentage
> >> Next
> >>
> >>
> >
> >
>
>


.



Relevant Pages

  • Re: Got CPU Load incorrectly using script
    ... counters to get an average that is meaningful. ... would read the SDK documentation very carefully to see which counter you ... > I have two scripts to check the CPU load and Memory usage, ... >> I got my CPU load value of 100% whatever it really was in taskmgr. ...
    (microsoft.public.windowsxp.wmi)
  • Re: Got CPU Load incorrectly using script
    ... This works just fine for me: Same scripts just throw out the extra garbage ... Set wbemObjectSet = objWMIService.ExecQuery("Select * from ... >> counters to get an average that is meaningful. ...
    (microsoft.public.windowsxp.wmi)
  • Re: Got CPU Load incorrectly using script
    ... I got this problem clearly after I install my .NET Framework 1.1 SP1: ... I have two scripts to check the CPU load and Memory usage, ...
    (microsoft.public.windowsxp.wmi)
  • Newbie question - calling perl from html
    ... various scripts which show how to do it (such as counters, ... display some text on a static web page. ... I have hello.cgi with the following (permissions are 755) ...
    (comp.lang.perl.misc)
  • Re: Got CPU Load incorrectly using script
    ... But I need to seperate the codes into different scripts to satisfy graphing ... > For Each wbemObject In wbemObjectSet ... >>> counters to get an average that is meaningful. ... >>> would read the SDK documentation very carefully to see which counter ...
    (microsoft.public.windowsxp.wmi)