Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: CPU activity Logging Software?  (Read 3388 times)

0 Members and 1 Guest are viewing this topic.

DaveLembke

    Topic Starter


    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
CPU activity Logging Software?
« on: March 25, 2018, 01:30:23 PM »
Was wondering if anyone knew of any software that monitored CPU usage and when CPU usage goes over a certain % of use it would log a date/time of when it reached that threshold and then when it went back to normal idle log date/time then too.

Thinking a service or program running sampling the CPU could be written that keeps an eye on CPU usage, so that the program doing the monitoring doesnt cause itself to detect itself as a false positive, but thats beyond my programing abilities as for I am not sure how I would import CPU utilization percentage value. I looked to see if there was any open source system monitoring code out there to use sections of someone elses code on how to monitor utilization of CPU, but none found. Tools out there that monitor CPU's just show real time and no logging.

I put the brakes on with coding up my own solution for this and figured I'd ask to see if anyone knows of a way to do this if some software or code already exists before I reinvent the wheel.  :) If anyone knows of some code to achieve this to point me in the right direction if it needs to be coded up as a service that would be cool too if software doesnt exist to do this or writing up code to do it makes more sense vs buying a product that does the same etc.

Trying to figure out how long processes take to complete that when the process completes it stays running, so its not as easy as putting an executable into a batch file and write the date time before the start of the EXE and then at then end of the EXE. Because the EXE is always running it will never get to the end time written to log of a batch.  :-\   For processes that run and close when done its easy to track how long a process took to complete, but an EXE that I dont have source code to adding logging to and I want to know how long its running against a CPU heavily for, the only way I can see this achieved is by monitoring CPU utilization and when the CPU goes over 90% to then log when this happened and then when it drops below 90% to log that date/time as well to know how long a process is taking.

Salmon Trout

  • Guest
Re: CPU activity Logging Software?
« Reply #1 on: March 25, 2018, 03:54:33 PM »
I use Efmer Tthrottle* because I have a i7 4790 with a stock cooler and if you max it out the temp will go to 100 C so I use this app to throttle it back to 20% cpu when the temp goes over 75, and release the throttle when it gets lower. I think it has some handy logging features. Maybe more what you are looking for is Speedfan which can log temps, fan speeds, etc at intervals you can select, and also do trigger actions at certain temps such as run a script or program. You can load the logs into Excel and get a graph too. If you want you can make Speedfan put its readings in shared memory and write an app to collect them. I think you can do it in Python.

*Often used with Boinc, which I see mentioned in your sig.

Tthrottle doing its thing with a CPU hog (notice the temp cycling between 60 and 75) if it wasn't running that upward slope would get right up to 100 and I'd be in thermal throttling.






DaveLembke

    Topic Starter


    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: CPU activity Logging Software?
« Reply #2 on: March 25, 2018, 04:50:36 PM »
Hi Salmon and thank you for sharing that info... Downloaded TThrottle to have in case I ever need to control thermal conditions.

I suppose I should have said more in my initial post. I am trying to figure out how long a CPU intensive process runs for that runs at a scheduled interval. I know the start time of it but no idea when it ends and instead of having to babysit the server to see how long it takes to complete, I figured there must me a software or scripted method of doing this. I figured knowing when the CPU is hit heavily that would be a starting point and when its done at greater than 90% use a date/time could be logged as well.

Your thermal info shared though is interesting because if there was a log that saved CPU temps with a Date/Time that too would be a way to log this to figure out how long it runs.

On my power hungry Phenom II x4 3.0Ghz it completes in about 12 minutes and I observed that myself because waiting 12 minutes isnt all that bad. But I wanted to drop my electric bill because the Phenom II x4 3.0Ghz runs at around 160 watts when the CPU is hit hard and around 110 watts idle when cool n' quiet kicks in to underclock the CPU.

I noticed my netbook that I set off into storage when digging for something different and realized that why dont I repurpose that for my needs instead of this power hungry Phenom II x4 system. So I migrated over to an Intel Atom N280 1.66Ghz APU and I am trying to determine when this heavy hitter process ends so I can adjust the scheduled tasks and not have overlap of scheduled events, and with an event that runs independent of windows scheduled tasks, I'd like to know when that ends before I trigger another event. The Intel Atom N280 1.66Ghz runs on 13 watts idle and 27 watts when its running full tilt with the CPU heavy daily routine.

It comes out to a savings of about 2kW a day at 18 cents per kWh so I'm saving 36 cents a day which comes out to $131.40 a year in electric bill savings to beat on this Intel Atom N280 during sleep hours. And when this CPU intensive process is not going on it has plenty of processing power to do everything else I need which is to be a File Server ( NAS ) and Database Server.

With the Phenom II x4 3.0Ghz setting up the scheduled events was easy because I knew when a heavy hitter scheduled event was done, but last night I watched the heavy hitter event put the Intel Atom N280 1.66Ghz to 100% for over 1.5 hours and so I left it running and when i woke up in the morning it was done so i know that it took less than 6 hours and that it will save me money on electric bill using this, but I have no idea as to how long it took to complete. The benchmark of a N280 Atom is around the performance of a Pentium 4 2.53Ghz but far less power consumption. Quite the difference from that of a Phenom II x4 3.0Ghz  ;D

Salmon Trout

  • Guest
Re: CPU activity Logging Software?
« Reply #3 on: March 27, 2018, 11:41:23 AM »
If you know the name of the executable you want to monitor, and TASKLIST can see it, you can have a simple little script like this. The delay in secs is a bit approximate as you can see. If you have one of the sleep.exe commands (the Microsoft one in the Server 2003 res kit is good because it has an -m switch option e.g. sleep -m 250 for milliseconds) you could use that instead of good old ping.

https://www.microsoft.com/en-gb/download/details.aspx?id=17657

You can choose where to install the reskit, and maybe copy what you want somewhere on your PATH

Code: [Select]
C:\Batch\Reskit>sleep.exe /?
Usage:  sleep.exe      time-to-sleep-in-seconds
        sleep.exe [-m] time-to-sleep-in-milliseconds
        sleep.exe [-c] commited-memory ratio (1%-100%)

Code: [Select]
@echo off
set progname=notepad.exe
set delaysecs=5
set /a pingnum=%delaysecs%+1
:loop
tasklist | find "%progname%" >nul && (set isrunning=YES) || (set isrunning=NO)
echo %date% %time% %progname% running: %isrunning%
ping 127.0.0.1 -n %pingnum% > nul
goto loop

Code: [Select]
27/03/2018 18:32:03.61 notepad.exe running: NO
27/03/2018 18:32:08.84 notepad.exe running: NO
27/03/2018 18:32:14.07 notepad.exe running: NO
27/03/2018 18:32:19.31 notepad.exe running: YES
27/03/2018 18:32:24.55 notepad.exe running: YES
27/03/2018 18:32:29.77 notepad.exe running: YES
27/03/2018 18:32:35.01 notepad.exe running: YES
27/03/2018 18:32:40.24 notepad.exe running: NO
27/03/2018 18:32:45.45 notepad.exe running: NO
27/03/2018 18:32:50.67 notepad.exe running: NO

DaveLembke

    Topic Starter


    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: CPU activity Logging Software?
« Reply #4 on: March 29, 2018, 07:41:10 PM »
Thanks Salmon for putting this together. Going to play around with that.  8)

Salmon Trout

  • Guest
Re: CPU activity Logging Software?
« Reply #5 on: March 30, 2018, 01:39:12 AM »
Of course you can write the messages to a log file like this

echo %date% %time% %progname% running: %isrunning% >> logfile.txt

I expect (although I haven't tried it) that you could make a scheduled task to run every second or whenever maybe.