Click here to Skip to main content
15,942,149 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to store the CPU and Memory Utilization of all the individual tasks after every 5 mins. from the task manager into a DB, say SQL Database. Is it possible to write a console application in C# which can accomplish this task and store the utilization in SQL Table.
Posted
Comments
Mike Meinz 22-Apr-13 10:20am    
You could try using the WMI Code Creator to create some code to get the values you need via WMI and then integrate that code into a program that puts the data retrieved into the database.
Sergey Alexandrovich Kryukov 22-Apr-13 12:10pm    
It would make a fair answer. Will you post it?
I just answered on another way, using performance counters...
—SA
Sergey Alexandrovich Kryukov 22-Apr-13 12:09pm    
Why? You should understand that the accuracy of Task Manager data is very low. And of course, you cannot get this data from Task Manager, but you can request if from OS.
—SA
Abhik03 23-Apr-13 1:20am    
Thanks for you suggetsion Sergey and Mike, I'll try them and will get back to you in case of any doubts. :)
Sergey Alexandrovich Kryukov 23-Apr-13 9:47am    
I suggest you can accept the answers formally (green button) — thanks.
—SA

You can get this information is you use System.Diagnostics.PerformanceCounter:
http://msdn.microsoft.com/en-us/library/system.diagnostics.performancecounter.aspx[^].

You can use this introductory CodeProject article to see how to do things: An Introduction To Performance Counters[^].

—SA
 
Share this answer
 
Actually all the information you got so far is correct:
- Task manager is just a tool to display data. It is not collecting anything
- In the background of task manager (and others like this) are system level tools, like WMI, as Mike Meinz highlighted.
- And you can access them easily also with performance counter tools provided by the .net framework as Sergey suggested.

Still, I would like to draw your attention towards built-in features you can use to achieve much the same result with no code at all from your side. The well-known PerfMon tool has features you can use to store your results into a database. Please see following article: http://www.sepago.de/e/nicholas/2009/11/02/performance-monitoring-part-7-using-performance-monitor-with-a-database[^].
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 22-Apr-13 15:35pm    
Agree, a 5.
—SA
Zoltán Zörgő 22-Apr-13 17:03pm    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900