Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Need some help. I'm trying to use a perfmon counter.

 

Imports System.Diagnostics.PerformanceCounter
Imports System.Diagnostics.CounterSampleCalculator

Dim WithEvents oPerfMon As New PerformanceCounter

    With oPerfMon
               .CategoryName = vcCategoryName
               .CounterName = vcCounterName
               .InstanceName = vcInstance
               .MachineName = vcServer
               .BeginInit()
           End With

Dim sTest As Single

           sTest = Math.Round(oPerfMon.NextValue)

 

this runs fine.. except the sTest is never getting a value. If i setup a breakpoint at the sTest portion, then run in the command windows

? math.round(oPerfmon.nextvalue)

I get a value... like 34, but sTest is never getting filled. I tried it without the round and oPerfmon.nextvalue gets data back, but still nothing in the sTest.

 

I made sTest a single cause when I mouse over the nextvalue, it shows up as a single. I tryied making it an int and using cType, but still no joy.

 

can someone point me in the right direction please

thanks

shannon

JvCoach23

VB.Net newbie

MS Sql Vet

Posted
I did some more playing with this. if i grab the counter info twice, on the second attempt it gets the info. So it's like it isn't starting the first time.. that help anyone to help me :)

JvCoach23

VB.Net newbie

MS Sql Vet

Posted
Which counter are you accessing? There is every possibility that if multiple values are being logged then the 1st may be 0.

 

 

thanks for the response. I decided to put in some counters that I am pretty sure are not zero. I started a disk defrag and set a counter for PhysicalDisk, % Disk Time on _Total instance. I fired up perfmon to watch both processor and %disk time. I have my counter doing a loop to grab both of these values. On perfmon running on the remote machine processor has had a low over 5, so it doesn't show any 0's. % Disk Time is up in the 75-100 range.. still only seeing zero's.

JvCoach23

VB.Net newbie

MS Sql Vet

Posted
I did some more checking.. I added Buffer Cache Hit Ratio counter to the mix.. it shows up.. 100 here on my test system.. still can't get the other two to display as anything but 0... hope that helps your thinking process out a bit more

JvCoach23

VB.Net newbie

MS Sql Vet

Posted

Progress

 

Well, i'm making a little progress on this one. I've found that if I put the oPerfmon.NextValue right into the web service portion and don't try to get it to equal anything, it seems to populate ok. Then in sql I do the rounding and such. Still not sure why I couldn't get

 

dim intValue as single

intValue = oPerfMon.NextValue

 

to work

anyway.. thougth I would update all

thanks

shannon

JvCoach23

VB.Net newbie

MS Sql Vet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...