例 - PowerShell パフォーマンスモニタスクリプト

PowerShell パフォーマンスモニタスクリプトには、実行に成功するために利用できる 2 つのインスタンス化オブジェクトがあります。

コンテキスト変数

PowerShell パフォーマンスモニタスクリプトで使用できるコンテキスト変数は次のとおりです。

スクリプトタイムアウト

スクリプトタイムアウト値は、秒単位で設定できます。タイムアウト値が終了する前にスクリプトの実行が終了しなかった場合、スクリプトは中止されます。

最小:1

最大:60

デフォルト:60

スクリプト例 1

#

# This example looks for a process named 'outlook' and reports its

# current number of threads.

#

# Use the built-in cmdlet named 'Get-Process', also aliased as 'ps'

$processes = ps

$processName = "outlook"

$proc = $processes | where { $_.ProcessName -match $processName }

# Performance monitors must call Context.SetValue() to report results

$Context.SetValue($proc.Threads.Count)

スクリプト例 2

#

# This example uses a reference variable to look for idle time

# levels and logs the results

#

# Use available context variables

$resultText = "Address:" + $Context.GetProperty("Address");

# Access the reference variable

$monitorValue = $Context.GetReferenceVariable("IdleTime")

# Log if necessary

$resultText = $resultText + ", Idle time:" + $monitorValue.ToString()

$Logger.WriteLine($resultText)

# Always set the performance value

$Context.SetValue($monitorValue);

参照

パフォーマンスモニタの使用

パフォーマンスモニタの概要

パフォーマンスモニタライブラリの使用

パフォーマンスモニタの操作

アクティブスクリプトパフォーマンスモニタの追加および編集

APC UPS パフォーマンスモニタの追加および編集

JMX パフォーマンスモニタの追加および編集

PowerShell スクリプトパフォーマンスモニタの追加および編集

プリンタパフォーマンスモニタの追加および編集

SNMP パフォーマンスモニタの追加および編集

SQL クエリパフォーマンスモニタの追加および編集

SQL クエリビルダ

SSH パフォーマンスモニタの追加および編集

Windows パフォーマンスカウンタモニタの追加および編集

WMI フォーマット済みパフォーマンスモニタの追加および編集

WMI パフォーマンスモニタの追加および編集