Skip to content

Commit 9a432a9

Browse files
committed
Added equivalent Net-SNMP commands.
1 parent d6f8b88 commit 9a432a9

File tree

1 file changed

+79
-2
lines changed

1 file changed

+79
-2
lines changed

library/tutorials/introduction.rst

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ for C# and .NET.
77
Basic SNMP operations (GET, SET and so on) you learn from elsewhere can be
88
easily translated to C# SNMP function calls.
99

10+
.. note::
11+
12+
The equivalent Net-SNMP command line is provided for each operation, so you
13+
can compare the two.
14+
1015
GET Operation
1116
-------------
1217
The following code shows how to send an SNMP v1 GET message to an SNMP agent
@@ -28,6 +33,14 @@ minute), and throw an exception (``TimeoutException``). If any error occurs, an
2833
The result returned is a list that matches the list of ``Variable`` objects
2934
sent. The ``Variable`` in this list contains the value of the OID.
3035

36+
.. note::
37+
38+
The equivalent Net-SNMP command line is
39+
40+
.. code-block:: bash
41+
42+
snmpget -v 1 -c public -t 60 192.168.1.2:161 1.3.6.1.2.1.1.1.0
43+
3144
SET Operation
3245
-------------
3346
The following code shows how to send an SNMP v1 SET message to an SNMP agent
@@ -42,6 +55,14 @@ located at ``192.168.1.2`` and set the value of OID ``1.3.6.1.2.1.1.6.0`` to
4255
new List<Variable>{new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.6.0"), new OctetString("Shanghai"))},
4356
60000);
4457
58+
.. note::
59+
60+
The equivalent Net-SNMP command line is
61+
62+
.. code-block:: bash
63+
64+
snmpset -v 1 -c public -t 60 192.168.1.2:161 1.3.6.1.2.1.1.6.0 s "Shanghai"
65+
4566
GET-NEXT Operation
4667
------------------
4768
The following code shows how to send an SNMP v1 GET-NEXT message to an SNMP
@@ -52,7 +73,7 @@ agent located at ``192.168.1.2`` and query on OID ``1.3.6.1.2.1.1.1.0``,
5273
GetNextRequestMessage message = new GetNextRequestMessage(0,
5374
VersionCode.V1,
5475
new OctetString("public"),
55-
new List<Variable>{new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.6.0"))});
76+
new List<Variable>{new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.1.0"))});
5677
ISnmpMessage response = message.GetResponse(60000, new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161));
5778
if (response.Pdu().ErrorStatus.ToInt32() != 0)
5879
{
@@ -64,6 +85,14 @@ agent located at ``192.168.1.2`` and query on OID ``1.3.6.1.2.1.1.1.0``,
6485
6586
var result = response.Pdu().Variables;
6687
88+
.. note::
89+
90+
The equivalent Net-SNMP command line is
91+
92+
.. code-block:: bash
93+
94+
snmpgetnext -v 1 -c public -t 60 192.168.1.2:161 1.3.6.1.2.1.1.1.0
95+
6796
GET-BULK Operation
6897
------------------
6998
The following code shows how to send an SNMP v2 GET-BULK message to an SNMP
@@ -76,7 +105,7 @@ agent located at ``192.168.1.2`` and query on OID ``1.3.6.1.2.1.1.1.0``,
76105
new OctetString("public"),
77106
0,
78107
10,
79-
new List<Variable>{new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.6.0"))});
108+
new List<Variable>{new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.1.0"))});
80109
ISnmpMessage response = message.GetResponse(60000, new IPEndPoint(IPAddress.Parse("192.168.1.2"), 161));
81110
if (response.Pdu().ErrorStatus.ToInt32() != 0)
82111
{
@@ -88,6 +117,14 @@ agent located at ``192.168.1.2`` and query on OID ``1.3.6.1.2.1.1.1.0``,
88117
89118
var result = response.Pdu().Variables;
90119
120+
.. note::
121+
122+
The equivalent Net-SNMP command line is
123+
124+
.. code-block:: bash
125+
126+
snmpbulkget -v 2c -c public -t 60 -Cn0 -Cr10 192.168.1.2:161 1.3.6.1.2.1.1.1.0
127+
91128
Walk Operation
92129
--------------
93130
Walk is not an atomic operation. That means, it utilizes several GET-NEXT (SNMP
@@ -105,6 +142,14 @@ walk on an SNMP agent located at ``192.168.1.2`` starting at ``1.3.6.1.2.1.1``,
105142
60000,
106143
WalkMode.WithinSubtree);
107144
145+
.. note::
146+
147+
The equivalent Net-SNMP command line is
148+
149+
.. code-block:: bash
150+
151+
snmpwalk -v 1 -c public -t 60 192.168.1.2:161 1.3.6.1.2.1.1
152+
108153
The result returned contains a list of all available OIDs (as ``Variable``) in
109154
this SNMP agent that under tree node of ``1.3.6.1.2.1.1``.
110155

@@ -131,6 +176,14 @@ built upon GET-BULK operations and provide better performance.
131176
null,
132177
null);
133178
179+
.. note::
180+
181+
The equivalent Net-SNMP command line is
182+
183+
.. code-block:: bash
184+
185+
snmpbulkwalk -v 2c -c public -t 60 -Cn0 -Cr10 192.168.1.2:161 1.3.6.1.2.1.1
186+
134187
TRAP Operation
135188
--------------
136189
It is usually an SNMP agent that sends out TRAP messages. The following code
@@ -148,6 +201,14 @@ manager located at ``192.168.1.3``,
148201
0,
149202
new List<Variable>());
150203
204+
.. note::
205+
206+
The equivalent Net-SNMP command line is
207+
208+
.. code-block:: bash
209+
210+
snmptrap -v 1 -c public 192.168.1.3:162 1.3.6.1.2.1.1 192.168.1.2 6 0 0
211+
151212
SNMP v2 and above introduces a simplified TRAP v2 message,
152213

153214
.. code-block:: csharp
@@ -160,6 +221,14 @@ SNMP v2 and above introduces a simplified TRAP v2 message,
160221
0,
161222
new List<Variable>());
162223
224+
.. note::
225+
226+
The equivalent Net-SNMP command line is
227+
228+
.. code-block:: bash
229+
230+
snmptrap -v 2c -c public 192.168.1.3:162 "" 1.3.6.1.2.1.1
231+
163232
INFORM Operation
164233
----------------
165234
It is usually an SNMP agent that sends out INFORM messages. The following code
@@ -179,6 +248,14 @@ shows how to send an empty INFORM message to an SNMP manager located at
179248
null,
180249
null);
181250
251+
.. note::
252+
253+
The equivalent Net-SNMP command line is
254+
255+
.. code-block:: bash
256+
257+
snmpinform -v 2c -c -t 2 public 192.168.1.3:162 "" 1.3.6.1.2.1.1
258+
182259
The manager should send back a reply to this INFORM message. Otherwise, a
183260
``TimeoutException`` occurs.
184261

0 commit comments

Comments
 (0)