简体   繁体   English

使用C#的Windows服务和性能信息

[英]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. 我想使用C#创建一个简单的Windows服务,它可以每5分钟左右检查Windows系统上最常见的性能计数器,并将结果上传到WCF服务。

My questions are: 我的问题是:

1) Having never worked with Performance Counters in .NET, is this something that is fairly simple to do? 1)从未使用.NET中的性能计数器,这是一件相当简单的事情吗?

2) Are there any permission issues I need to concern myself with? 2)我需要关注自己的许可问题吗? The service will likely be running under "localsystem" or a domain user account. 该服务可能会在“localsystem”或域用户帐户下运行。

3) What are the common performance counters I should be looking for... Memory, CPU, Disk? 3)我应该寻找什么常见的性能计数器...内存,CPU,磁盘?

4) Has anyone else written code similar to this and do they have any examples to get me started? 4)是否有其他人编写了与此类似的代码,他们是否有任何示例让我开始?

Any help would be appreciated. 任何帮助,将不胜感激。

使用.NET监控性能计数器并不难,但我建议使用现有的工具(例如SCOM )来完成这项工作。

In case others may find this useful (or myself in the future) ;) 万一其他人可能会发现这有用(或将来我自己);)

  1. Yes - Performance Counters 是的 - 性能计数器
  2. Unfortunately I don't know the answer to this one, but I'll update if I learn it. 不幸的是我不知道这个的答案,但如果我学习它,我会更新。 :D :d
  3. 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. 这方面有很多优秀的资源。
  4. Here are a couple key files I found on various projects on Github. 以下是我在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 . 您还可以参考PerformanceCounter类的官方文档中的示例
    1. TelemetryInstrumentService.cs by Scott DeHaan Scott DeHaan的 TelemetryInstrumentService.cs
    2. CounterWatcher.cs by CryptonZylog CounterWatcher.cs by CryptonZylog

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM