创建&在powershell脚本或命令行中编辑性能计数器 [英] Creating & Editing performance counters in a powershell script or command line

查看:241
本文介绍了创建&在powershell脚本或命令行中编辑性能计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想移动验证码,创建我的性能计数器组,计数器本身,从我的Web服务和在部署期间运行的PowerShell脚本。

I'm trying to move the verification & creation of my performance counter groups, and the counters themselves, out of my web service and into a powershell script that's run during deployment.

可以这样做吗?或者我被困住使用一个简单的应用程序来建立组&计数器?

Can this be done? Or am I stuck using a simple app to build the groups & counters?

感谢大家:)

推荐答案



这是我的解决方案:

Figured this out a while ago, but never posted.
Here's my solution:

//save out the type name for sanity's sake
$ccdTypeName = 'System.Diagnostics.CounterCreationData'
$CounterCollection = New-Object System.Diagnostics.CounterCreationDataCollection

//create as many counters as we'd like, and add them to the collection. here's just one:
$CounterCollection.Add( (New-Object $ccdTypeName "Counter Name", "Counter Description", NumberOfItems32) )

//create the category with the counter collection
[System.Diagnostics.PerformanceCounterCategory]::Create($perfCounterCategoryName, $perfCounterVersion, [Diagnostics.PerformanceCounterCategoryType]::SingleInstance, $CounterCollection); 

这篇关于创建&在powershell脚本或命令行中编辑性能计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆