### SNMP Walk Command Example Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md This is an example of how to use the snmpwalk command-line tool to query SNMP data from localhost. ```bash snmpwalk -v 2c -c public localhost 1.3.6.1 ``` -------------------------------- ### GetBulkRequest-PDU Example Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v3/rfc3416.txt An example of a GetBulkRequest-PDU with specified non-repeaters and max-repetitions parameters. ```text GetBulkRequest [ non-repeaters = 1, max-repetitions = 2 ] ( sysUpTime, ipNetToMediaPhysAddress, ipNetToMediaType ) ``` -------------------------------- ### Install node-net-snmp Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Install the node-net-snmp module using npm. This is the first step before requiring it in your project. ```bash npm install net-snmp ``` -------------------------------- ### Table Data Example Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Shows the hierarchical structure of an SNMP table, including the table itself, its entry, columns, and rows. This example uses a portion of the ifTable. ```text 1.3.6.1.2.1.2.2 <= ifTable (table) 1.3.6.1.2.1.2.2.1 <= ifEntry (table entry) 1.3.6.1.2.1.2.2.1.1 <= ifIndex (column 1) 1.3.6.1.2.1.2.2.1.1.1 = Integer: 1 <= ifIndex row 1 value = 1 1.3.6.1.2.1.2.2.1.1.2 = Integer: 2 <= ifIndex row 2 value = 2 ``` -------------------------------- ### Clone and configure repository Source: https://github.com/markabrahams/node-net-snmp/blob/master/CONTRIBUTING.md Initial setup for a local development environment by cloning a fork and adding the upstream remote. ```bash # Clone your fork of the repo into the current directory git clone https://github.com//node-net-snmp # Navigate to the newly cloned directory cd node-net-snmp # Assign the original repo to a remote called "upstream" git remote add upstream https://github.com/markabrahams/node-net-snmp ``` -------------------------------- ### Response-PDU Example Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v3/rfc3416.txt The corresponding Response-PDU generated by the command responder application. ```text Response (( sysUpTime.0 = "123456" ), ( ipNetToMediaPhysAddress.1.9.2.3.4 = "000010543210" ), ( ipNetToMediaType.1.9.2.3.4 = "dynamic" ), ( ipNetToMediaPhysAddress.1.10.0.0.51 = "000010012345" ), ( ipNetToMediaType.1.10.0.0.51 = "static" )) ``` -------------------------------- ### SNMP Response-PDU Example Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v3/rfc3416.txt Illustrates a typical SNMP Response-PDU with variable bindings indicating the end of a table. ```text Response (( sysUpTime.0 = "123466" ), ( ipNetToMediaPhysAddress.2.10.0.0.15 = "000010987654" ), ( ipNetToMediaType.2.10.0.0.15 = "dynamic" ), ( ipNetToMediaNetAddress.1.9.2.3.4 = "9.2.3.4" ), ( ipRoutingDiscards.0 = "2" )) ``` -------------------------------- ### Creating an Agent with Simple Access Control Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Instantiate an Agent with the Simple Access Control Model. This example demonstrates adding communities and users, then setting their access levels. ```javascript var agent = snmp.createAgent({ accessControlModelType: snmp.AccessControlModelType.Simple }, function (error, data) { // null callback for example brevity }); var authorizer = agent.getAuthorizer (); authorizer.addCommunity ("public"); authorizer.addCommunity ("private"); authorizer.addUser ({ name: "fred", level: snmp.SecurityLevel.noAuthNoPriv }); var acm = authorizer.getAccessControlModel (); // Since read-only is the default, explicitly setting read-only access is not required - just shown here as an example acm.setCommunityAccess ("public", snmp.AccessLevel.ReadOnly); acm.setCommunityAccess ("private", snmp.AccessLevel.ReadWrite); acm.setUserAccess ("fred", snmp.AccessLevel.ReadWrite); ``` -------------------------------- ### Send Generic Cold-Start Inform with session.inform Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Send a generic cold-start SNMP inform message to a remote host using session.inform. This example does not include custom varbinds. ```js session.inform (snmp.TrapType.ColdStart, function (error) { if (error) console.error (error); }); ``` -------------------------------- ### Example Table Structure Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Illustrates the expected object structure for fetched table data, keyed by row index and then by column number. ```javascript var table = { // Rows keyed by ifIndex (1 and 2 are shown) 1: { // ifDescr (column 2) and ifType (columnd 3) are shown 2: "interface-1", 3: 6, ... }, 2: { 2: "interface-2", 3: 6, ... }, ... } ``` -------------------------------- ### Legal SMIv2 Sub-typing Examples Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v2c/rfc2578.txt Valid syntax for applying range and size constraints to Integer32, OCTET STRING, and other types. ```SMIv2 Integer32 (-20..100) Integer32 (0..100 | 300..500) Integer32 (300..500 | 0..100) Integer32 (0 | 2 | 4 | 6 | 8 | 10) OCTET STRING (SIZE(0..100)) OCTET STRING (SIZE(0..100 | 300..500)) OCTET STRING (SIZE(0 | 2 | 4 | 6 | 8 | 10)) SYNTAX TimeInterval (0..100) SYNTAX DisplayString (SIZE(0..32)) ``` -------------------------------- ### SNMP SetRequest-PDU 'tooBig' Response Example Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v3/rfc3416.txt Shows the structure of an alternate Response-PDU generated when a SetRequest-PDU would result in a message exceeding size constraints. ```text Response-PDU having the same values in its request-id and variable-bindings fields as the received SetRequest-PDU, and the largest possible sizes of the error-status and error-index fields. If the determined message size is greater than either a local constraint or the maximum message size of the originator, then an alternate Response-PDU is generated, transmitted to the originator of the SetRequest-PDU, and processing of the SetRequest-PDU terminates immediately thereafter. This alternate Response-PDU is formatted with the same values in its request-id field as the received SetRequest-PDU, with the value of its error-status field set to "tooBig", the value of its error-index field set to zero, and an empty variable-bindings field. ``` -------------------------------- ### SNMP GetResponse PDU Example Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v1/rfc1098.txt Illustrates a GetResponse PDU containing route information. This is typically sent by an SNMP agent in response to a GetRequest. ```text GetResponse (( ipRouteDest.9.1.2.3 = "9.1.2.3" ), ( ipRouteNextHop.9.1.2.3 = "99.0.0.3" ), ( ipRouteMetric1.9.1.2.3 = 3 )) ``` ```text GetResponse (( ipRouteDest.10.0.0.51 = "10.0.0.51" ), ( ipRouteNextHop.10.0.0.51 = "89.1.1.42" ), ( ipRouteMetric1.10.0.0.51 = 5 )) ``` ```text GetResponse (( ipRouteDest.10.0.0.99 = "10.0.0.99" ), ( ipRouteNextHop.10.0.0.99 = "89.1.1.42" ), ( ipRouteMetric1.10.0.0.99 = 5 )) ``` -------------------------------- ### SNMP Notification Structure Example Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Illustrates the structure of a notification object received by the callback function, including PDU details and sender information. ```json { "pdu": { "type": 166, "id": 45385686, "varbinds": [ { "oid": "1.3.6.1.2.1.1.3.0", "type": 67, "value": 5 }, { "oid": "1.3.6.1.6.3.1.1.4.1.0", "type": 6, "value": "1.3.6.1.6.3.1.1.5.2" } ], "scoped": false }, "rinfo": { "address": "127.0.0.1", "family": "IPv4", "port": 43162, "size": 72 } } ``` -------------------------------- ### Simple OID String Example Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md This demonstrates how to represent a simple Object Identifier (OID) as a string. This format is accepted by some parts of the module for specifying OIDs. ```javascript var oid = "1.3.6.1.2.1.1.5.0"; ``` -------------------------------- ### String Size Constraint Example Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Limits the length of strings using an array of min/max size range objects, similar to integer ranges. ```javascript constraints: { sizes: [ { min: 1, max: 3 }, { min: 5 } ] } ``` -------------------------------- ### SNMP GetNextRequest PDU Example Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v1/rfc1098.txt Shows a GetNextRequest PDU used to retrieve the next sequential variable binding. This is often used for table traversal. ```text GetNextRequest ( ipRouteDest.9.1.2.3, ipRouteNextHop.9.1.2.3, ipRouteMetric1.9.1.2.3 ) ``` ```text GetNextRequest ( ipRouteDest.10.0.0.51, ipRouteNextHop.10.0.0.51, ipRouteMetric1.10.0.0.51 ) ``` ```text GetNextRequest ( ipRouteDest.10.0.0.99, ipRouteNextHop.10.0.0.99, ipRouteMetric1.10.0.0.99 ) ``` -------------------------------- ### SNMPv1 Error Handling in Callback Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Example of handling a GET request in SNMPv1. Assumes varbinds will have values if no error object is passed to the callback. ```javascript var oids = ["1.3.6.1.2.1.1.5.0", "1.3.6.1.2.1.1.6.0"]; session.get (oids, function (error, varbinds) { if (error) { console.error (error.toString ()); } else { var sysName = varbinds[0].value; // this WILL have a value } }); ``` -------------------------------- ### Create Module Store with Custom Base Modules Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Demonstrates creating a ModuleStore instance and specifying a custom list of base modules to load, which can help avoid type overrides. ```javascript // Example of selecting only SNMPv2 MIBs const store = snmp.createModuleStore({ baseModules: [ 'SNMPv2-SMI', 'SNMPv2-CONF', 'SNMPv2-TC', 'SNMPv2-MIB', ], }); ``` -------------------------------- ### Perform SNMP GET Request Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Create an SNMP session to a remote host and perform a GET request for specified OIDs. Handles errors and prints results. ```javascript var session = snmp.createSession ("127.0.0.1", "public"); var oids = ["1.3.6.1.2.1.1.5.0", "1.3.6.1.2.1.1.6.0"]; session.get (oids, function (error, varbinds) { if (error) { console.error (error); } else { for (var i = 0; i < varbinds.length; i++) { if (snmp.isVarbindError (varbinds[i])) { console.error (snmp.varbindError (varbinds[i])); } else { console.log (varbinds[i].oid + " = " + varbinds[i].value); } } } session.close (); }); ``` -------------------------------- ### Load MIB, Create Agent, and Manipulate MIB Values Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md This snippet demonstrates creating a module store, loading a MIB file, fetching its JSON representation, and then creating an agent to register MIB providers and manipulate scalar values and table rows. ```javascript var store = snmp.createModuleStore (); store.loadFromFile ("/path/to/your/mibs/SNMPv2-MIB.mib"); var jsonModule = store.getModule ("SNMPv2-MIB"); // Fetch MIB providers, create an agent, and register the providers with your agent var providers = store.getProvidersForModule ("SNMPv2-MIB"); // Not recommended - but authorization and callback turned off for example brevity var agent = snmp.createAgent ({disableAuthorization: true}, function (error, data) {}); var mib = agent.getMib (); mib.registerProviders (providers); // Start manipulating the MIB through the registered providers using the `Mib` API calls mib.setScalarValue ("sysDescr", "The most powerful system you can think of"); mib.setScalarValue ("sysName", "multiplied-by-six"); mib.addTableRow ("sysOREntry", [1, "1.3.6.1.4.1.47491.42.43.44.45", "I've dreamed up this MIB", 20]); ``` -------------------------------- ### Example MIB Object Definitions Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v1/rfc1065.txt Illustrative definitions of MIB object types using the OBJECT-TYPE macro, including syntax, access, status, and OBJECT IDENTIFIER assignments. These examples show how to formally define managed objects like atIndex and atEntry. ```ASN.1 atIndex OBJECT-TYPE SYNTAX INTEGER ACCESS read-write STATUS mandatory ::= { atEntry 1 } ``` ```ASN.1 atPhysAddress OBJECT-TYPE SYNTAX OCTET STRING ACCESS read-write STATUS mandatory ::= { atEntry 2 } ``` ```ASN.1 atNetAddress OBJECT-TYPE SYNTAX NetworkAddress ACCESS read-write STATUS mandatory ::= { atEntry 3 } ``` ```ASN.1 atEntry OBJECT-TYPE SYNTAX AtEntry ACCESS read-write STATUS mandatory ::= { atTable 1 } ``` ```ASN.1 atTable OBJECT-TYPE SYNTAX SEQUENCE OF AtEntry ACCESS read-write STATUS mandatory ::= { at 1 } ``` -------------------------------- ### Fetch and Display ifTable Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Demonstrates fetching the ifTable using session.table and processing the response to print rows in a sorted order. Includes helper functions for numerical sorting. ```javascript var oid = "1.3.6.1.2.1.2.2"; function sortInt (a, b) { if (a > b) return 1; else if (b > a) return -1; else return 0; } function responseCb (error, table) { if (error) { console.error (error.toString ()); } else { // This code is purely used to print rows out in index order, // ifIndex's are integers so we'll sort them numerically using // the sortInt() function above var indexes = []; for (index in table) indexes.push (parseInt (index)); indexes.sort (sortInt); // Use the sorted indexes we've calculated to walk through each // row in order for (var i = 0; i < indexes.length; i++) { // Like indexes we sort by column, so use the same trick here, // some rows may not have the same columns as other rows, so // we calculate this per row var columns = []; for (column in table[indexes[i]]) columns.push (parseInt (column)); columns.sort (sortInt); // Print index, then each column indented under the index console.log ("row for index = " + indexes[i]); for (var j = 0; j < columns.length; j++) { console.log (" column " + columns[j] + " = " + table[indexes[i]][columns[j]]); } } } } var maxRepetitions = 20; // The maxRepetitions argument is optional, and will be ignored unless using // SNMP verison 2c session.table (oid, maxRepetitions, responseCb); ``` -------------------------------- ### GET ifDescr Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v1/rfc1066.txt Retrieves the description string for a specific network interface. ```APIDOC ## GET ifDescr ### Description A text string containing information about the interface, including manufacturer, product name, and hardware version. ### Method GET ### Endpoint ifEntry.ifDescr ### Response #### Success Response (200) - **ifDescr** (OCTET STRING) - Human-readable description of the interface. ``` -------------------------------- ### forwarder.dumpProxies Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Prints a console dump of all defined proxy configurations. ```APIDOC ## forwarder.dumpProxies () ### Description Prints a dump of all proxy definitions to the console for inspection. ``` -------------------------------- ### GET ifIndex Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v1/rfc1066.txt Retrieves the unique index for a specific network interface. ```APIDOC ## GET ifIndex ### Description A unique value for each interface. Its value ranges between 1 and the value of ifNumber. ### Method GET ### Endpoint ifEntry.ifIndex ### Response #### Success Response (200) - **ifIndex** (INTEGER) - Unique identifier for the interface. ``` -------------------------------- ### GET ifNumber Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v1/rfc1066.txt Retrieves the total number of network interfaces on the system. ```APIDOC ## GET ifNumber ### Description The number of network interfaces (regardless of their current state) on which this system can send/receive IP datagrams. ### Method GET ### Endpoint interfaces.ifNumber ### Response #### Success Response (200) - **ifNumber** (INTEGER) - The count of network interfaces. ``` -------------------------------- ### GET GetNextRequest-PDU Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v1/rfc1067.txt Defines the structure of the GetNextRequest-PDU, which is identical to the GetRequest-PDU structure. ```APIDOC ## GET GetNextRequest-PDU ### Description The GetNextRequest-PDU is used to retrieve the value of the next object in the MIB tree relative to the provided variable names. ### Request Body - **request-id** (RequestID) - Required - Unique identifier for the request. - **error-status** (ErrorStatus) - Required - Always 0 for requests. - **error-index** (ErrorIndex) - Required - Always 0 for requests. - **variable-bindings** (VarBindList) - Required - List of variable names to retrieve the next instance for. ### Request Example { "request-id": 12346, "error-status": 0, "error-index": 0, "variable-bindings": [{"name": "sysDescr", "value": null}] } ``` -------------------------------- ### Create a topic branch Source: https://github.com/markabrahams/node-net-snmp/blob/master/CONTRIBUTING.md Initializes a new branch for specific features or fixes. ```bash git checkout -b ``` -------------------------------- ### Get Authorizer Instance Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Obtain the singleton Authorizer instance for a receiver or agent. ```javascript receiver.getAuthorizer ().getCommunities (); ``` -------------------------------- ### SNMPv3 USM msgSecurityParameters with Sample Values Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v3/rfc3414.txt An example of msgSecurityParameters with concrete hexadecimal values, illustrating the encoding of various parameters including engine ID, boots, time, username, and sample digest/salt values. ```text 04 39 OCTET STRING, length 57 30 37 SEQUENCE, length 55 04 0c 80000002 msgAuthoritativeEngineID: IBM 01 IPv4 address 09840301 9.132.3.1 02 01 01 msgAuthoritativeEngineBoots: 1 02 02 0101 msgAuthoritativeEngineTime: 257 04 04 62657274 msgUserName: bert 04 0c 01234567 msgAuthenticationParameters: sample value 89abcdef fedcba98 04 08 01234567 msgPrivacyParameters: sample value 89abcdef ``` -------------------------------- ### Reference Simple Object Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v1/rfc1155.txt Example of referencing a simple object type within a table. ```text { atPhysAddress } ``` -------------------------------- ### SNMPv3 USM User Table Creation Procedure Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v3/rfc3414.txt Outlines the recommended procedure for creating a new user entry in the usmUserTable, involving the use of usmUserSpinLock and setting various user parameters like privacy and authentication protocols. ```text usmUserTable OBJECT-TYPE SYNTAX SEQUENCE OF UsmUserEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION "The table of users configured in the SNMP engine's Local Configuration Datastore (LCD). To create a new user (i.e., to instantiate a new conceptual row in this table), it is recommended to follow this procedure: 1) GET(usmUserSpinLock.0) and save in sValue. 2) SET(usmUserSpinLock.0=sValue, usmUserCloneFrom=templateUser, usmUserStatus=createAndWait) You should use a template user to clone from which has the proper auth/priv protocol defined. If the new user is to use privacy: 3) generate the keyChange value based on the secret privKey of the clone-from user and the secret key to be used for the new user. Let us call this pkcValue. 4) GET(usmUserSpinLock.0) and save in sValue. 5) SET(usmUserSpinLock.0=sValue, usmUserPrivKeyChange=pkcValue usmUserPublic=randomValue1) 6) GET(usmUserPulic) and check it has randomValue1. If not, repeat steps 4-6. If the new user will never use privacy: 7) SET(usmUserPrivProtocol=usmNoPrivProtocol) If the new user is to use authentication: 8) generate the keyChange value based on the secret authKey of the clone-from user and the secret key to be used for the new user. Let us call this akcValue. 9) GET(usmUserSpinLock.0) and save in sValue. 10) SET(usmUserSpinLock.0=sValue, usmUserAuthKeyChange=akcValue usmUserPublic=randomValue2) 11) GET(usmUserPulic) and check it has randomValue2. If not, repeat steps 9-11. If the new user will never use authentication: 12) SET(usmUserAuthProtocol=usmNoAuthProtocol) Finally, activate the new user: 13) SET(usmUserStatus=active) The new user should now be available and ready to be used for SNMPv3 communication. Note however that access to MIB data must be provided via configuration of the SNMP-VIEW-BASED-ACM-MIB. ``` -------------------------------- ### GET sysObjectID Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v1/rfc1066.txt Retrieves the vendor's authoritative identification of the network management subsystem. ```APIDOC ## GET sysObjectID ### Description The vendor's authoritative identification of the network management subsystem contained in the entity. This value is allocated within the SMI enterprises subtree (1.3.6.1.4.1). ### Method GET ### Endpoint system.2 ### Parameters - **Access** (read-only) - Mandatory - **Status** (mandatory) - Mandatory ### Response #### Success Response (200) - **sysObjectID** (OBJECT IDENTIFIER) - The unique identifier for the managed device type. ``` -------------------------------- ### GET GetRequest-PDU Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v1/rfc1067.txt Defines the structure of the GetRequest-PDU used to retrieve managed object values. ```APIDOC ## GET GetRequest-PDU ### Description The GetRequest-PDU is used by a protocol entity to request the values of specific managed objects. ### Request Body - **request-id** (RequestID) - Required - Unique identifier for the request. - **error-status** (ErrorStatus) - Required - Always 0 for requests. - **error-index** (ErrorIndex) - Required - Always 0 for requests. - **variable-bindings** (VarBindList) - Required - List of variable names to retrieve. ### Request Example { "request-id": 12345, "error-status": 0, "error-index": 0, "variable-bindings": [{"name": "sysDescr.0", "value": null}] } ``` -------------------------------- ### Require node-net-snmp Module Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Load the installed node-net-snmp module into your project using the require() function. ```javascript var snmp = require ("net-snmp"); ``` -------------------------------- ### Test Proxy Access via Net-SNMP CLI Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Demonstrates how to test the configured proxy using the Net-SNMP command-line tools. This command targets the local agent with a specific context, which should then be forwarded to the configured remote host. ```bash snmpget -v 3 -u fred -l noAuthNoPriv -n slatescontext localhost 1.3.6.1.2.1.1.1.0 ``` -------------------------------- ### Create SNMP Agent with Default Options Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Instantiates an SNMP agent using default options and a callback function for handling errors and data. Ensure to provide valid options and a callback. ```javascript // Default options var options = { port: 161, disableAuthorization: false, accessControlModelType: snmp.AccessControlModelType.None, engineID: "8000B98380XXXXXXXXXXXXXXXXXXXXXXXX", // where the X's are random hex digits address: null, transport: "udp4", mibOptions: {} }; var callback = function (error, data) { if ( error ) { console.error (error); } else { console.log (JSON.stringify(data, null, 2)); } }; agent = snmp.createAgent (options, callback); ``` -------------------------------- ### GET ipAddrTable Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v1/rfc1066.txt Retrieves the table of addressing information relevant to the entity's IP addresses. ```APIDOC ## GET ipAddrTable ### Description The table of addressing information relevant to this entity's IP addresses. ### Method GET ### Endpoint ipAddrTable { ip 20 } ### Response #### Success Response (200) - **ipAdEntAddr** (IpAddress) - The IP address to which this entry's addressing information pertains. - **ipAdEntIfIndex** (INTEGER) - The index value which uniquely identifies the interface. - **ipAdEntNetMask** (IpAddress) - The subnet mask associated with the IP address. - **ipAdEntBcastAddr** (INTEGER) - The value of the least-significant bit in the IP broadcast address. ``` -------------------------------- ### GET sysUpTime Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v1/rfc1066.txt Retrieves the time since the network management portion of the system was last re-initialized. ```APIDOC ## GET sysUpTime ### Description The time (in hundredths of a second) since the network management portion of the system was last re-initialized. ### Method GET ### Endpoint system.sysUpTime ### Response #### Success Response (200) - **sysUpTime** (TimeTicks) - The time in hundredths of a second since last re-initialization. ``` -------------------------------- ### Create SNMPv3 Session with Options Source: https://github.com/markabrahams/node-net-snmp/blob/master/README.md Instantiates an SNMPv3 session with default or custom options. Ensure `engineID` is correctly formatted with random hex digits. ```javascript // Default options for v3 var options = { port: 161, retries: 1, timeout: 5000, transport: "udp4", trapPort: 162, version: snmp.Version3, engineID: "8000B98380XXXXXXXXXXXXXXXXXXXXXXXX", // where the X's are random hex digits backwardsGetNexts: true, reportOidMismatchErrors: false, idBitsSize: 32, context: "", strictIntRangeChecks: false }; // Example user var user = { name: "blinkybill", level: snmp.SecurityLevel.authPriv, authProtocol: snmp.AuthProtocols.sha, authKey: "madeahash", privProtocol: snmp.PrivProtocols.des, privKey: "privycouncil" }; var session = snmp.createV3Session ("127.0.0.1", user, options); ``` -------------------------------- ### GET /usmStats Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v3/rfc3414.txt Retrieves various SNMP engine statistics related to packet drops and security errors. ```APIDOC ## GET /usmStats ### Description Retrieves counters for packets dropped by the SNMP engine due to various security failures. ### Method GET ### Endpoint /usmStats ### Response #### Success Response (200) - **usmStatsUnknownEngineIDs** (Counter32) - Packets dropped due to unknown snmpEngineID. - **usmStatsWrongDigests** (Counter32) - Packets dropped due to incorrect digest values. - **usmStatsDecryptionErrors** (Counter32) - Packets dropped due to decryption failures. ``` -------------------------------- ### MIB Object Definitions Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v1/rfc1155.txt Examples of MIB object definitions including atIndex, atPhysAddress, atNetAddress, atEntry, and atTable. ```APIDOC ## MIB Object Definitions ### Description Definitions for address translation table objects. ### Object Definitions - **atIndex**: INTEGER, read-write, mandatory, { atEntry 1 } - **atPhysAddress**: OCTET STRING, read-write, mandatory, { atEntry 2 } - **atNetAddress**: NetworkAddress, read-write, mandatory, { atEntry 3 } - **atEntry**: AtEntry, read-write, mandatory, { atTable 1 } - **atTable**: SEQUENCE OF AtEntry, read-write, mandatory, { at 1 } ### AtEntry Structure ``` AtEntry ::= SEQUENCE { atIndex INTEGER, atPhysAddress OCTET STRING, atNetAddress NetworkAddress } ``` ``` -------------------------------- ### SNMPv3 USM keyChange Result using MD5 Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v3/rfc3414.txt Sample keyChange result using MD5, showing the calculated new key, localized key, and the final value to be sent for keyChange, based on a given password and engineID. ```text '00 00 00 00 00 00 00 00 00 00 00 02'H '01 ad d2 73 10 7c 4e 59 6b 4b 00 f8 2b 1d 42 a7'H '87 02 1d 7b d9 d1 01 ba 05 ea 6e 3b f9 d9 bd 4a'H '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 88 05 61 51 41 67 6c c9 19 61 74 e7 42 a3 25 51'H ``` -------------------------------- ### Password to Key Sample Code for MD5 Source: https://github.com/markabrahams/node-net-snmp/blob/master/ref/rfc/v3/rfc3414.txt This C code snippet demonstrates the password to key algorithm using MD5, as specified in RFC 1321. It takes a password, engineID, and their lengths as input to generate a 16-octet key. ```c void password_to_key_md5( u_char *password, /* IN */ u_int passwordlen, /* IN */ u_char *engineID, /* IN - pointer to snmpEngineID */ u_int engineLength,/* IN - length of snmpEngineID */ u_char *key) /* OUT - pointer to caller 16-octet buffer */ { MD5_CTX MD; u_char *cp, password_buf[64]; u_long password_index = 0; u_long count = 0, i; MD5Init (&MD); /* initialize MD5 */ /**********************************************/ ```