Re: Got CPU Load incorrectly using script
- From: "Yu Haitao David" <mshtyu@xxxxxxx>
- Date: Sat, 4 Jun 2005 08:00:49 +0800
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
> >>
> >>
> >
> >
>
>
.
- Follow-Ups:
- Re: Got CPU Load incorrectly using script
- From: Jim Vierra
- Re: Got CPU Load incorrectly using script
- References:
- Got CPU Load incorrectly using script
- From: Yu Haitao David
- Re: Got CPU Load incorrectly using script
- From: Yu Haitao David
- Re: Got CPU Load incorrectly using script
- From: Jim Vierra
- Got CPU Load incorrectly using script
- Prev by Date: Re: Login script with admin priveleges
- Next by Date: Re: Got CPU Load incorrectly using script
- Previous by thread: Re: Got CPU Load incorrectly using script
- Next by thread: Re: Got CPU Load incorrectly using script
- Index(es):
Relevant Pages
|