CoreAsp.SnmpRqst
- Last Updated: May 21, 2026
- 5 minute read
- WhatsUp Gold
- Version 2026
このオブジェクトは SNMP 要求をリモートデバイスに送信するために使用されます。
必ず [Initialize4] または [Initialize2] を呼び出してから他のメンバーを呼び出してください。
CoreAsp.SnmpRqst は三段階のプロセスを使用します。
[Initialize4]または[Initialize2]を呼び出し、特定のデバイスに対してオブジェクトを初期化します。- タイムアウトの値やポートなどのオプションのパラメータを設定します。
- デバイスに
[Get]、[GetNext]、[GetMultiple]または[Set]などの操作を行います。これらの操作によってComSnmpResponseオブジェクトが返されます。このオブジェクトには操作のステータスと値が含まれます (Failed/GetValue/GetOidを使用した場合、値は直接返され、GetPayloadを使用した場合、SNMP 変数バインディングのリストが XML データとして返されます)。
Initialize4 メソッドを使用する必要があります。メソッド |
説明 |
返す内容 |
|---|---|---|
|
Initialize4( |
指定したパラメータで指定されたデバイス ID を持つデバイスの
|
ComResult オブジェクト |
|
Initialize2( |
デバイスの IP アドレスおよび WhatsUp Gold に保存された認証情報を使用してデバイスへの接続を作成することで、
|
ComResult オブジェクト |
|
SetTimeoutMs( |
タイムアウト値をミリ秒単位で設定します。指定されない場合、タイムアウト値はデフォルトで 2000 ミリ秒になります。
|
ComResult オブジェクト |
|
SetNumRetries( |
タイムアウトした要求を再試行する回数を設定します。指定されない場合、失敗した要求の再試行回数は 1 回です。
1 要求当たり SNMP パケットを 1 つだけ送信するには、 |
ComResult オブジェクト |
|
SetPort( |
|
ComResult オブジェクト |
|
Get( |
指定オブジェクトの値を取得する SNMP Get コマンドを発行します。
|
ComSnmpResponse オブジェクト |
|
GetNext( |
辞書の順で指定オブジェクトの次に来るオブジェクトの値を取得する SNMP GetNext コマンドを発行します。
|
ComSnmpResponse オブジェクト |
|
GetMultiple( |
各指定オブジェクトの SNMP Get コマンドを発行します。
|
ComSnmpResponse オブジェクト |
|
Set( |
SNMP Set コマンドを発行し、デバイスに OID 値を設定します。
|
ComSnmpResponse オブジェクト |
デバイスに関連付けられた SNMP 認証情報に基づいて Initialize4 パラメータを自動設定する関数の例を次に示します。
|
' ***************** ' * ConnectSNMP * ' ***************** Sub ConnectSNMP() Dim bCredential : bCredential = 0 'Get SNMP Credential Data Dim sFirstCommunity : sFirstCommunity = Context.GetProperty("CredSnmpV1:ReadCommunity") Dim sSecondCommunity : sSecondCommunity = Context.GetProperty("CredSnmpV2:ReadCommunity") Dim sUsername : sUsername = Context.GetProperty("CredSnmpV3:Username") Dim sContext : sContext = Context.GetProperty("CredSnmpV3:Context") Dim sAuthPwd : sAuthPwd = Context.GetProperty("CredSnmpV3:AuthPassword") Dim sPrivPwd : sPrivPwd = Context.GetProperty("CredSnmpV3:EncryptPassword") Dim nAuthProto : nAuthProto = 0 Dim nPrivProto : nPrivProto = 0 'initialize snmp cred version Dim nSnmpVersion : nSnmpVersion = 1 Dim sCommunity : sCommunity = sFirstCommunity ' determine snmp cred version If Len(sFirstCommunity) = 0 Then If Len(sSecondCommunity) > 0 Then nSnmpVersion = 2 sCommunity = sSecondCommunity Else If Len(sUsername) > 0 Then nSnmpVersion = 3 Else Context.LogMessage "There are no SNMP credentials assigned to this device" bCredential = 1 End If End If End If If bCredential = 0 Then Dim rc, sOID, sOIDCore, sOIDtoLoop, sInstance 'Initialize and Test SNMP Connection Set rc = oSnmp.Initialize4(sAddress,nSnmpVersion,sCommunity,sUsername,sContext,nAuthProto,sAuthPwd,nPrivProto,sPrivPwd) If rc.Failed Then sErrorMsg = rc.GetErrorMsg bSNMPResult = 1 bFail = 1 End If End If End Sub |