Windows Service and Performance Info using C#
We have hundreds of database and application servers in our datacenter and we are currently using various third party tools to monitor. All appear to have their stengths and weaknesses.
I would like to create a simple Windows Service using C# that can check the most common performance counters on a Windows system every 5 mins or so and upload the results to a WCF service.
My questions are:
1) Having never worked with Performance Counters in .NET, is this something that is fairly simple to do?
2) Are there any permission issues I need to concern myself with? The service 开发者_如何学Gowill likely be running under "localsystem" or a domain user account.
3) What are the common performance counters I should be looking for... Memory, CPU, Disk?
4) Has anyone else written code similar to this and do they have any examples to get me started?
Any help would be appreciated.
Monitoring performance counters isn't hard using .NET however I recommend using existing tools (such as SCOM) that will do exactly this for you.
In case others may find this useful (or myself in the future) ;)
- Yes - Performance Counters
- Unfortunately I don't know the answer to this one, but I'll update if I learn it. :D
- This will depend on the context. You will likely want to monitor slightly different counters for Database servers vs Application servers. There are many excellent resources on this.
- Here are a couple key files I found on various projects on Github. They may not be ideal, or reflect the above articles, but they give an idea on the structure. You can also refer to the examples in the official documentation on the PerformanceCounter Class.
- TelemetryInstrumentService.cs by Scott DeHaan
- CounterWatcher.cs by CryptonZylog
精彩评论