例 - 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 パフォーマンスモニタの作成

デバイス固有の PowerShell スクリプトパフォーマンスモニタの作成

デバイス固有の SNMP パフォーマンスモニタの作成

デバイス固有のプリンタパフォーマンスモニタの作成

デバイス固有の SQL クエリのパフォーマンスモニタの作成

SQL クエリビルダ

デバイス固有の SSH パフォーマンスモニタの作成

デバイス固有の WMI フォーマット済みカウンタパフォーマンスモニタの作成

デバイス固有の WMI パフォーマンスモニタの作成

例:ルーター帯域幅の監視

例: ネットワーク接続が遅い問題のトラブルシューティング