プリンタインク使用率グラフの作成

メモ この例は説明のために示されているに過ぎず、実際にはサポートされていません。Ipswitch は、Context オブジェクト、SNMP API、およびスクリプティング環境については、テクニカルサポートを提供しますが、JScript、VBScript、およびアクティブスクリプトのモニタとアクションの開発とデバッグについては、サポートを提供しません。この例および自社独自のスクリプトを作成することに関する援助については、WhatsUp Gold ユーザーコミュニティにアクセスしてください。

このパフォーマンスモニタは、プリンタのインクレベル使用率 (%) をポーリングして計算するために 2 つの参照変数を使用し、後のグラフ作成に備えます。

メモ このスクリプトは HP MIB でテスト済みです。

SNMP MIB Walker ツールを実行して、2 つの参照変数の OID を調べ、最終的にはそれらのインスタンスを調整します (この例では 1.1)。

1.3.6.1.2.1.43.11.1.1.8.1.1 および 1.3.6.1.2.1.43.11.1.1.9.1.1.

// prtMarkerSuppliesLevel は snmp 参照変数であり、OID または 1.3.6.1.2.1.43.11.1.9 と 1.1 のインスタンスで定義されています。
// prtMarkerSuppliesMaxCapacity は snmp 参照変数であり、OID または 1.3.6.1.2.1.43.11.1.8 と 1.1 のインスタンスで定義されています。

Context.LogMessage("Print the current marker level");
var prtMarkerSuppliesLevel = Context.GetReferenceVariable("prtMarkerSuppliesLevel");
Context.LogMessage("Print the maximum marker level");
var prtMarkerSuppliesMaxCapacity = Context.GetReferenceVariable("prtMarkerSuppliesMaxCapacity");

if (prtMarkerSuppliesMaxCapacity == null || prtMarkerSuppliesLevel == null) {
Context.SetResult(0, "Failed to poll printer ink levels.");
}
else {
Context.LogMessage("marker lever successfully retrieved");
var nPercentMarkerUtilization = 100 * prtMarkerSuppliesLevel / prtMarkerSuppliesMaxCapacity;
Context.LogMessage("Percent utilization=" + nPercentMarkerUtilization + "%");
Context.SetValue(nPercentMarkerUtilization);

参照

アクティブスクリプトのパフォーマンスモニタの例

参照変数をポーリングして計算を実行する

温度モニタのグラフ化

SNMP GetNext の使用

複数の参照変数のポーリング