Page 3 of 3
Re: VenMon - PC Monitoring Software
Posted: Thu Apr 26, 2018 2:27 pm
by Ventural
Lord wrote:Hm, nothing changed here. Still got CPU at 0%.
Wow! You must have an amazing cpu. For some reason, its not picking up Process / Handles / Threads on your computer. I loaded Windows 10 in a virtual computer, changed it to German (Deutschland) and ran the cpu code above and that is what I got:
https://i.imgur.com/In89niK.png
Then I ran Venmon 2.16 in Purebasic and it works there too:
https://i.imgur.com/Pe4wCQw.png
Will borrow a computer with Windows 7 Ultimate x64 so I change languages and to test some more in the next day or two.
Lord wrote:Another thought: I got one CPU with 4 cores, so tab "Processors" should display "Core x" instead of "CPU x".
Or do I have 4 CPU and I didn't realized 'til now?

That would maybe explain the low CPU load?
I wasn't sure if I should go with Cores or CPUs. I originally had "Cores", but I then started getting emails from AMD users that they didn't have a Intel "Core" chip, I couldn't tell if they were upset or just confused

so I switched it to "CPU" for now.
Edit: I just noticed in Windows 10, they use "CPU 0", "CPU 1", "CPU 2", etc. in Task Manager when you mouse over each graph:
https://i.imgur.com/Tu4flE0.png I guess I'll keep it the same as Windows.
Re: VenMon - PC Monitoring Software
Posted: Thu Apr 26, 2018 4:06 pm
by Lord
Ventural wrote:
I wasn't sure if I should go with Cores or CPUs. I originally had "Cores", but I then started getting emails from AMD users that they didn't have a Intel "Core" chip, I couldn't tell if they were upset or just confused

so I switched it to "CPU" for now.
...
Even AMD calls it "cores":

Cores are internal parts of a CPU.
Win7 Task-Manager doesn't have label for each core:

Re: VenMon - PC Monitoring Software
Posted: Thu Apr 26, 2018 4:52 pm
by Ventural
Hmm, guess the next question would be... If you have a Core i7-7700 processor that has four cores + hyper-threading that shows up as eight threads in Task Manager. Would that be considered eight "Cores"?
Intel i7-7700 Product Page:
https://ark.intel.com/products/97128/
Re: VenMon - PC Monitoring Software
Posted: Thu Apr 26, 2018 7:13 pm
by Lord
Ventural wrote:Hmm, guess the next question would be... If you have a Core i7-7700 processor that has four cores + hyper-threading that shows up as eight threads in Task Manager. Would that be considered eight "Cores"?
Intel i7-7700 Product Page:
https://ark.intel.com/products/97128/
No, its one CPU with 4 cores, two threads on each core.
But remember: look at my signature.

Re: VenMon - PC Monitoring Software
Posted: Wed May 23, 2018 10:02 pm
by Ventural
Lord wrote:Hm, nothing changed here. Still got CPU at 0%.
Customer brought in a computer today because it was running very slow with a Core i7 on Windows 7 Home. I noticed that Venmon was not reading the processor usage. I opened up the built-in Windows Performance Monitor tool and it had errors. Opened up registry and went to:
Code: Select all
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009
and noticed that "Counter" key was blank or had a ton of blank lines in it. Did some research on it and found that you can rebuild the Windows Performance Counters registry by opening Command Prompt with Administrative privileges and type:
Code: Select all
cd c:\windows\system32
lodctr /R
cd c:\windows\syswow64
lodctr /R
I rebooted after this, but not sure if that was necessary. Afterwards both Venmon and Windows Performance Monitor were able to recognize cpu % usage.
Re: VenMon - PC Monitoring Software
Posted: Thu May 24, 2018 8:55 am
by Lord
Ventural wrote:Lord wrote:Hm, nothing changed here. Still got CPU at 0%.
Customer brought in a computer today because it was running very slow with a Core i7 on Windows 7 Home. I noticed that Venmon was not reading the processor usage. I opened up the built-in Windows Performance Monitor tool and it had errors. ...
I'm sorry, but my system runs fine and the built-in Windows Performance Monitor shows correct data.
Re: VenMon - PC Monitoring Software
Posted: Thu May 24, 2018 2:22 pm
by Ventural
ok, so you did those steps and it still doesn't work?
I've been working on a solution for you for awhile now. I just happened to run across a computer with the same symptoms that you mentioned and was hoping that would fix it.
Re: VenMon - PC Monitoring Software
Posted: Fri May 25, 2018 7:28 am
by Lord
Sorry, but still doesn't work.
Re: VenMon - PC Monitoring Software
Posted: Wed Jul 25, 2018 12:12 am
by Dude
Ventural wrote:QueryPerformanceCounter_ and QueryPerformanceFrequency_ = Uptime
Do you mind (please) sharing your equation for this? Every uptime equation I've seen is either too slow, gives incorrect results, or doesn't work on all versions of Windows. Thanks!
Re: VenMon - PC Monitoring Software
Posted: Wed Jul 25, 2018 2:12 am
by Ventural
The results of up time vary between PC to PC. The up time is suppose to match the one shown in the Windows Task Manager. Here's the computers I tested on just now:
Mini screenshots. VenMon program on top, task manger time below.
I'm sure there are ways to get a more accurate time, but I went with the simple solution:
Code: Select all
QPC.q ;QueryPerformanceCounter_ Output
QPF.q ;QueryPerformanceFrequency_ Output
UP_Days.q ;Uptime in Days
UP_Hour.q ;Uptime in Hours
UP_Mins.q ;Uptime in Minutes
UP_Secs.q ;Uptime in Seconds
DisplayText.s ;Output to Debug / Screen
Repeat
If QueryPerformanceCounter_(@QPC) ;Run If OS supports it. Windows 2000+
QueryPerformanceFrequency_(@QPF)
UP_Secs = QPC / QPF ;Returns seconds
UP_Days = UP_Secs / 86400 ;Days Uptime
UP_Secs - (UP_Days * 86400) ;Subtract days
UP_Hour = UP_Secs / 3600 ;Hours Uptime
UP_Secs - (UP_Hour * 3600) ;Subtract hours
UP_Mins = UP_Secs / 60 ;Minutes Uptime
UP_Secs - (UP_Mins * 60) ;Seconds Uptime
If UP_Days > 0
DisplayText = Str(UP_Days) + "d "
Else
DisplayText = ""
EndIf
If UP_Hour > 0
DisplayText + Str(UP_Hour) + "h "
EndIf
If UP_Mins > 0
DisplayText + Str(UP_Mins) + "m "
EndIf
Debug DisplayText + Str(UP_Secs) + "s"
EndIf
Delay(1000)
ForEver
Re: VenMon - PC Monitoring Software
Posted: Wed Jul 25, 2018 2:26 am
by Dude
Hmm, thanks, but I tried it but it doesn't match my Win 7 Task Manager at all:
I did reboot my PC 4 days ago, not 11 like your code says. That's what I mean when I say that I can never find a fast working solution.

Re: VenMon - PC Monitoring Software
Posted: Wed Jul 25, 2018 3:07 am
by Ventural
Hmm... I never seen it off by that much. Interesting. If you type in Command Prompt:
Does it show boot up from 4 or 11 days ago?
Re: VenMon - PC Monitoring Software
Posted: Wed Jul 25, 2018 3:50 am
by Ventural
Threw this together real quick. Getting up time from Performance Monitor. This may not be reliable on all computers.
Code: Select all
Prototype PdhLookupPerfNameByIndex(szMachineName.s, dwNameIndex.l, *szNameBuffer, *pcchNameBufferSize)
Global PdhLookupPerfNameByIndex.PdhLookupPerfNameByIndex, MemSize.l
UP_Days.q ;Uptime in Days
UP_Hour.q ;Uptime in Hours
UP_Mins.q ;Uptime in Minutes
UP_Secs.q ;Uptime in Seconds
DisplayText.s ;Output to Debug / Screen
Structure PDH_FMT_COUNTERVALUE
CStatus.l; As Long
;' case Cardinal of
;' 0: (longValue: Integer);
;' 1: (doubleValue: Double);
;' 2: (largeValue: Int64);
;' 3: (AnsiStringValue: PChar);
;' 4: (WideStringValue: PWideChar);
padding.l; As Long
ulValueLow.l; As Long
ulValueHigh.l; As Long
EndStructure
#PerformanceLib = 8888 ;Temp #
If OpenLibrary(#PerformanceLib, "pdh.dll")
CompilerIf #PB_Compiler_Unicode
PdhLookupPerfNameByIndex = GetFunction(#PerformanceLib, "PdhLookupPerfNameByIndexW")
CompilerElse
PdhLookupPerfNameByIndex = GetFunction(#PerformanceLib, "PdhLookupPerfNameByIndexA")
CompilerEndIf
EndIf
hQuery.l
hCounter.l
RESULT.q = PdhOpenQuery_( 0, 1, @hQuery )
RESULT = PdhAddCounter_(hQuery, "\2\674", 0, @hCounter)
retcode.d
lpValue.PDH_FMT_COUNTERVALUE
RESULT = PdhCollectQueryData_(hQuery) ;Init
Delay(250)
Debug "--- Begin ---"
Repeat
RESULT = PdhCollectQueryData_(hQuery)
PdhGetFormattedCounterValue_(hCounter, $200 | $8000, @dwType.l, @lpValue)
CopyMemory(@lpValue\ulValueLow, @retcode, 8)
UP_Secs = Retcode ;Returns seconds
UP_Days = UP_Secs / 86400 ;Days Uptime
UP_Secs - (UP_Days * 86400) ;Subtract days
UP_Hour = UP_Secs / 3600 ;Hours Uptime
UP_Secs - (UP_Hour * 3600) ;Subtract hours
UP_Mins = UP_Secs / 60 ;Minutes Uptime
UP_Secs - (UP_Mins * 60) ;Seconds Uptime
If UP_Days > 0
DisplayText = Str(UP_Days) + "d "
Else
DisplayText = ""
EndIf
If UP_Hour > 0
DisplayText + Str(UP_Hour) + "h "
EndIf
If UP_Mins > 0
DisplayText + Str(UP_Mins) + "m "
EndIf
Debug Str(Retcode) + " = " + DisplayText + Str(UP_Secs) + "s"
Delay(1000)
ForEver
Re: VenMon - PC Monitoring Software
Posted: Wed Jul 25, 2018 5:19 am
by Dude
Ventural wrote:Does it show boot up from 4 or 11 days ago?
It shows from 4 days ago, which is correct:
Ventural wrote:Threw this together real quick. Getting up time from Performance Monitor. This may not be reliable on all computers.
This works, and matches both Task Manager and "systeminfo".

But in what way is it unreliable? I'm hesitant to use it in that case.
Is there really no 100% reliable solution for all PCs? Like I said, I've never seen one, and your Venmon uptime code will be wrong for me, unless you update it with your new code above... but then that new code will be unreliable on someone else's Windows. Getting the correct uptime on any given PC seems to be a real problem.
I could calc the time difference between now and the result of "boot time" from "systeminfo", but that brings the slowness that I mentioned in my post further back. Nobody wants to wait 10 seconds or more to see their uptime... it has to be realtime.
Re: VenMon - PC Monitoring Software
Posted: Wed Jul 25, 2018 6:37 am
by Ventural
This works, and matches both Task Manager and "systeminfo".

But in what way is it unreliable? I'm hesitant to use it in that case.

It's rare, but I've seen where a user's Performance Counters data has been corrupted in the registry or disabled. Sometimes its an easy fix by pointing them to websites such:
Solarwinds Website or
Microsoft Support and get them to reset it. Other times I can't figure out why their system won't retrieve the Performance Counters data. I've had some people say an first version of Windows 10 (build 1507?) didn't work right on old hardware, but once they updated Windows 10, all was good.
You can always add more code.
Code: Select all
RESULT.q = PdhOpenQuery_( 0, 1, @hQuery )
Debug Result
Debug hQuery
If result = #ERROR_SUCCESS
Debug "Good!"
;Put rest of Performance Counter Code here?
;Put more code in to test results before displaying them
Else
Debug "Uh oh!"
;https://docs.microsoft.com/en-us/windows/desktop/PerfCtrs/pdh-error-codes
;Insert Alternate Code?
EndIf