1. Overview
In this tutorial, we will extending the model initially created for the Tutorial: NMIS8, create a new model.
...
Warning | ||||
---|---|---|---|---|
| ||||
Opmantek VM has SNMPv2c enabled by default, the community used on this VM is: nmisGig8 This can be verified on the snmp configuration file that can be found in /etc/snmpd/snmpd.conf |
...
As we have seen in the previous tutorial, we need to obtain the relevant information about the objects to model it for the device. We could get these details directly from the vendor or if the objects are more common, we can search online to obtain more details about them. In this case, we need to model relevant Objects from the Mib 2 - IP MIB Group 1.3.6.1.2.1.4 iso(1). org(3). dod(6). internet(1). mgmt(2). mib-2(1). ip(4).
IP | GROUP | 1.3.6.1.2.1.4 iso(1). org(3). dod(6). internet(1). mgmt(2). mib-2(1). ip(4) | ||||
ipForwarding | SCALAR | read-write | INTEGER | 1.3.6.1.2.1.4.1 | ||
ipDefaultTTL | SCALAR | read-write | INTEGER | 1.3.6.1.2.1.4.2 | ||
ipInReceives | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.3 | ||
ipInHdrErrors | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.4 | ||
ipInAddrErrors | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.5 | ||
ipForwDatagrams | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.6 | ||
ipInUnknownProtos | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.7 | ||
ipInDiscards | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.8 | ||
ipInDelivers | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.9 | ||
ipOutRequests | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.10 | ||
ipOutDiscards | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.11 | ||
ipOutNoRoutes | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.12 | ||
ipReasmTimeout | SCALAR | read-only | INTEGER | 1.3.6.1.2.1.4.13 | ||
ipReasmReqds | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.14 | ||
ipReasmOKs | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.15 | ||
ipReasmFails | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.16 | ||
ipFragOKs | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.17 | ||
ipFragFails | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.18 | ||
ipFragCreates | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.19 | ||
ipAddrTable | TABLE | not-accessible | SEQUENCE OF | 1.3.6.1.2.1.4.20 | ||
| ipAddrEntry | ENTRY | not-accessible | IpAddrEntry | 1.3.6.1.2.1.4.20.1 | |
| ipAdEntAddr | TABULAR | read-only | IpAddress | 1.3.6.1.2.1.4.20.1.1 | |
ipAdEntIfIndex | TABULAR | read-only | INTEGER | 1.3.6.1.2.1.4.20.1.2 | ||
ipAdEntNetMask | TABULAR | read-only | IpAddress | 1.3.6.1.2.1.4.20.1.3 | ||
ipAdEntBcastAddr | TABULAR | read-only | INTEGER | 1.3.6.1.2.1.4.20.1.4 | ||
ipAdEntReasmMaxSize | TABULAR | read-only | INTEGER ( 0..65535 ) | 1.3.6.1.2.1.4.20.1.5 | ||
ipRouteTable | TABLE | not-accessible | SEQUENCE OF | 1.3.6.1.2.1.4.21 | ||
| ipRouteEntry | ENTRY | not-accessible | IpRouteEntry | 1.3.6.1.2.1.4.21.1 | |
| ipRouteDest | TABULAR | read-write | IpAddress | 1.3.6.1.2.1.4.21.1.1 | |
ipRouteIfIndex | TABULAR | read-write | INTEGER | 1.3.6.1.2.1.4.21.1.2 | ||
ipRouteMetric1 | TABULAR | read-write | INTEGER | 1.3.6.1.2.1.4.21.1.3 | ||
ipRouteMetric2 | TABULAR | read-write | INTEGER | 1.3.6.1.2.1.4.21.1.4 | ||
ipRouteMetric3 | TABULAR | read-write | INTEGER | 1.3.6.1.2.1.4.21.1.5 | ||
ipRouteMetric4 | TABULAR | read-write | INTEGER | 1.3.6.1.2.1.4.21.1.6 | ||
ipRouteNextHop | TABULAR | read-write | IpAddress | 1.3.6.1.2.1.4.21.1.7 | ||
ipRouteType | TABULAR | read-write | INTEGER | 1.3.6.1.2.1.4.21.1.8 | ||
ipRouteProto | TABULAR | read-only | INTEGER | 1.3.6.1.2.1.4.21.1.9 | ||
ipRouteAge | TABULAR | read-write | INTEGER | 1.3.6.1.2.1.4.21.1.10 | ||
ipRouteMask | TABULAR | read-write | IpAddress | 1.3.6.1.2.1.4.21.1.11 | ||
ipRouteMetric5 | TABULAR | read-write | INTEGER | 1.3.6.1.2.1.4.21.1.12 | ||
ipRouteInfo | TABULAR | read-only | OBJECT IDENTIFIER | 1.3.6.1.2.1.4.21.1.13 | ||
ipNetToMediaTable | TABLE | not-accessible | SEQUENCE OF | 1.3.6.1.2.1.4.22 | ||
| ipNetToMediaEntry | ENTRY | not-accessible | IpNetToMediaEntry | 1.3.6.1.2.1.4.22.1 | |
| ipNetToMediaIfIndex | TABULAR | read-write | INTEGER | 1.3.6.1.2.1.4.22.1.1 | |
ipNetToMediaPhysAddress | TABULAR | read-write | PhysAddress | 1.3.6.1.2.1.4.22.1.2 | ||
ipNetToMediaNetAddress | TABULAR | read-write | IpAddress | 1.3.6.1.2.1.4.22.1.3 | ||
ipNetToMediaType | TABULAR | read-write | INTEGER | 1.3.6.1.2.1.4.22.1.4 | ||
ipRoutingDiscards | SCALAR | read-only | Counter | 1.3.6.1.2.1.4.23 |
Now get the devices snmp data using snmpwalk. We will request data from the OID:
...
To make the returned data more useful and easier to interprete, we put the results in a table that shows the OID, the numerical OID and the value.
OID | Numerical OID | Value |
IP-MIB::ipForwarding.0 | .1.3.6.1.2.1.4.1.0 | INTEGER: 2 |
IP-MIB::ipDefaultTTL.0 | .1.3.6.1.2.1.4.2.0 | INTEGER: 64 |
IP-MIB::ipInReceives.0 | .1.3.6.1.2.1.4.3.0 | Counter32: 1137737 |
IP-MIB::ipInHdrErrors.0 | .1.3.6.1.2.1.4.4.0 | Counter32: 0 |
IP-MIB::ipInAddrErrors.0 | .1.3.6.1.2.1.4.5.0 | Counter32: 170 |
IP-MIB::ipForwDatagrams.0 | .1.3.6.1.2.1.4.6.0 | Counter32: 0 |
IP-MIB::ipInUnknownProtos.0 | .1.3.6.1.2.1.4.7.0 | Counter32: 0 |
IP-MIB::ipInDiscards.0 | .1.3.6.1.2.1.4.8.0 | Counter32: 0 |
IP-MIB::ipInDelivers.0 | .1.3.6.1.2.1.4.9.0 | Counter32: 1137567 |
IP-MIB::ipOutRequests.0 | .1.3.6.1.2.1.4.10.0 | Counter32: 1150410 |
IP-MIB::ipOutDiscards.0 | .1.3.6.1.2.1.4.11.0 | Counter32: 0 |
IP-MIB::ipOutNoRoutes.0 | .1.3.6.1.2.1.4.12.0 | Counter32: 43108 |
IP-MIB::ipReasmTimeout.0 | .1.3.6.1.2.1.4.13.0 | INTEGER: 0 |
IP-MIB::ipReasmReqds.0 | .1.3.6.1.2.1.4.14.0 | Counter32: 0 |
IP-MIB::ipReasmOKs.0 | .1.3.6.1.2.1.4.15.0 | Counter32: 0 |
IP-MIB::ipReasmFails.0 | .1.3.6.1.2.1.4.16.0 | Counter32: 0 |
IP-MIB::ipFragOKs.0 | .1.3.6.1.2.1.4.17.0 | Counter32: 0 |
IP-MIB::ipFragFails.0 | .1.3.6.1.2.1.4.18.0 | Counter32: 0 |
IP-MIB::ipFragCreates.0 | .1.3.6.1.2.1.4.19.0 | Counter32: 0 |
IP-MIB::ipAdEntAddr.127.0.0.1 | .1.3.6.1.2.1.4.20.1.1.127.0.0.1 | IpAddress: 127.0.0.1 |
IP-MIB::ipAdEntAddr.192.168.1.100 | .1.3.6.1.2.1.4.20.1.1.192.168.1.100 | IpAddress: 192.168.1.100 |
IP-MIB::ipAdEntIfIndex.127.0.0.1 | .1.3.6.1.2.1.4.20.1.2.127.0.0.1 | INTEGER: 1 |
IP-MIB::ipAdEntIfIndex.192.168.1.100 | .1.3.6.1.2.1.4.20.1.2.192.168.1.100 | INTEGER: 2 |
IP-MIB::ipAdEntNetMask.127.0.0.1 | .1.3.6.1.2.1.4.20.1.3.127.0.0.1 | IpAddress: 255.0.0.0 |
IP-MIB::ipAdEntNetMask.192.168.1.100 | .1.3.6.1.2.1.4.20.1.3.192.168.1.100 | IpAddress: 255.255.255.0 |
IP-MIB::ipAdEntBcastAddr.127.0.0.1 | .1.3.6.1.2.1.4.20.1.4.127.0.0.1 | INTEGER: 0 |
IP-MIB::ipAdEntBcastAddr.192.168.1.100 | .1.3.6.1.2.1.4.20.1.4.192.168.1.100 | INTEGER: 1 |
IP-MIB::ip.21.1.1.192.168.1.0 | .1.3.6.1.2.1.4.21.1.1.192.168.1.0 | IpAddress: 192.168.1.0 |
IP-MIB::ip.21.1.2.192.168.1.0 | .1.3.6.1.2.1.4.21.1.2.192.168.1.0 | INTEGER: 2 |
IP-MIB::ip.21.1.3.192.168.1.0 | .1.3.6.1.2.1.4.21.1.3.192.168.1.0 | INTEGER: 0 |
IP-MIB::ip.21.1.7.192.168.1.0 | .1.3.6.1.2.1.4.21.1.7.192.168.1.0 | IpAddress: 0.0.0.0 |
IP-MIB::ip.21.1.8.192.168.1.0 | .1.3.6.1.2.1.4.21.1.8.192.168.1.0 | INTEGER: 3 |
IP-MIB::ip.21.1.9.192.168.1.0 | .1.3.6.1.2.1.4.21.1.9.192.168.1.0 | INTEGER: 2 |
IP-MIB::ip.21.1.11.192.168.1.0 | .1.3.6.1.2.1.4.21.1.11.192.168.1.0 | IpAddress: 255.255.255.0 |
IP-MIB::ip.21.1.13.192.168.1.0 | .1.3.6.1.2.1.4.21.1.13.192.168.1.0 | OID: .0.0 |
IP-MIB::ipNetToMediaIfIndex.2.192.168.1.59 | .1.3.6.1.2.1.4.22.1.1.2.192.168.1.59 | INTEGER: 2 |
IP-MIB::ipNetToMediaPhysAddress.2.192.168.1.59 | .1.3.6.1.2.1.4.22.1.2.2.192.168.1.59 | STRING: 50:eb:71:57:ee:a5 |
IP-MIB::ipNetToMediaNetAddress.2.192.168.1.59 | .1.3.6.1.2.1.4.22.1.3.2.192.168.1.59 | IpAddress: 192.168.1.59 |
IP-MIB::ipNetToMediaType.2.192.168.1.59 | .1.3.6.1.2.1.4.22.1.4.2.192.168.1.59 | INTEGER: 3 |
IP-MIB::ipRoutingDiscards.0 | .1.3.6.1.2.1.4.23.0 | Counter32: 0 |
After carefully analysing the object that are useful for our case, we have decided to add these objects: "ipForwDatagrams", "ipFragCreates", "ipFragFails", "ipFragOKs", "ipInAddrErrors", "ipInDelivers", "ipInDiscards", "ipInHdrErrors", "ipInReceives", "ipInUnknownProtos", "ipOutDiscards", "ipOutRequests", "ipReasmFails", "ipReasmOKs" and "ipReasmReqds. This table only shows these selected objects.
OID | Numerical OID | Value | Description |
IP-MIB::ipInReceives.0 | .1.3.6.1.2.1.4.3.0 | Counter32: 1137737 | The total number of input datagrams received from interfaces, including those received in error. |
IP-MIB::ipInHdrErrors.0 | .1.3.6.1.2.1.4.4.0 | Counter32: 0 | The number of input datagrams discarded due to errors in their IPv4 headers, including bad checksums, version number mismatch, other format errors, time-to-live exceeded, errors discovered in processing their IPv4 options, etc. |
IP-MIB::ipInAddrErrors.0 | .1.3.6.1.2.1.4.5.0 | Counter32: 170 | The number of input datagrams discarded because the IPv4 address in their IPv4 header's destination field was not a valid address to be received at this entity. This count includes invalid addresses (e.g., 0.0.0.0) and addresses of unsupported Classes (e.g., Class E). For entities which are not IPv4 routers, and therefore do not forward datagrams, this counter includes datagrams discarded because the destination address was not a local address. |
IP-MIB::ipForwDatagrams.0 | .1.3.6.1.2.1.4.6.0 | Counter32: 0 | The number of input datagrams for which this entity was not their final IPv4 destination, as a result of which an attempt was made to find a route to forward them to that final destination. In entities which do not act as IPv4 routers, this counter will include only those packets which were Source-Routed via this entity, and the Source-Route option processing was successful. |
IP-MIB::ipInUnknownProtos.0 | .1.3.6.1.2.1.4.7.0 | Counter32: 0 | The number of locally-addressed datagrams received successfully but discarded because of an unknown or unsupported protocol. |
IP-MIB::ipInDiscards.0 | .1.3.6.1.2.1.4.8.0 | Counter32: 0 | The number of input IPv4 datagrams for which no problems were encountered to prevent their continued processing, but which were discarded (e.g., for lack of buffer space). Note that this counter does not include any datagrams discarded while awaiting re-assembly. |
IP-MIB::ipInDelivers.0 | .1.3.6.1.2.1.4.9.0 | Counter32: 1137567 | The total number of input datagrams successfully delivered to IPv4 user-protocols (including ICMP). |
IP-MIB::ipOutRequests.0 | .1.3.6.1.2.1.4.10.0 | Counter32: 1150410 | The total number of IPv4 datagrams which local IPv4 user protocols (including ICMP) supplied to IPv4 in requests for transmission. Note that this counter does not include any datagrams counted in ipForwDatagrams. |
IP-MIB::ipOutDiscards.0 | .1.3.6.1.2.1.4.11.0 | Counter32: 0 | The number of output IPv4 datagrams for which no problem was encountered to prevent their transmission to their destination, but which were discarded (e.g., for lack of buffer space). Note that this counter would include datagrams counted in ipForwDatagrams if any such packets met this (discretionary) discard criterion. |
IP-MIB::ipReasmReqds.0 | .1.3.6.1.2.1.4.14.0 | Counter32: 0 | The number of IPv4 fragments received which needed to be reassembled at this entity. |
IP-MIB::ipReasmOKs.0 | .1.3.6.1.2.1.4.15.0 | Counter32: 0 | The number of IPv4 datagrams successfully re-assembled. |
IP-MIB::ipReasmFails.0 | .1.3.6.1.2.1.4.16.0 | Counter32: 0 | The number of failures detected by the IPv4 re-assembly algorithm (for whatever reason: timed out, errors, etc). |
IP-MIB::ipFragOKs.0 | .1.3.6.1.2.1.4.17.0 | Counter32: 0 | The number of IPv4 datagrams that have been successfully fragmented at this entity. |
IP-MIB::ipFragFails.0 | .1.3.6.1.2.1.4.18.0 | Counter32: 0 | The number of IPv4 datagrams that have been discarded because they needed to be fragmented at this entity but could not be, e.g., because their Don't Fragment flag was set. |
IP-MIB::ipFragCreates.0 | .1.3.6.1.2.1.4.19.0 | Counter32: 0 | The number of IPv4 datagram fragments that have been generated as a result of fragmentation at this entity. |
4. Model Implementation
This time, we will be mapping the Numeric OIDs to a more descriptive name, in this case, we call them as it is specified on the MIB. To do this, we have to edit the /usr/local/nmis8/mibs/nmis_mibs.oid file and add the entries. Once we have done this, the NMIS will be able to identify the name and replace it by the numeric OID.
...
In similar fashion, we add the other objects to the model. Also, remember to temporarily use 'no_graphs'
=>
'1'
inside the "mib2ip" section before testing our implementation to avoid errors related to graphs for this section. Once we have done that, the "mib2ip" section may look as follows:
...
'GPRINT:ipInReceives:AVERAGE:Avg %6.0lf \\n',
GPRINT:variable:CF:Format
variable: To specify the data that is associated with.
CF: Consolidation Function, can be AVERAGE, MINIMUM, MAXIMUM, and LAST
Format: The description shown, the number format and line formatting.
e.g: "Avg %6.0lf \\n" → "Avg" is the textual description, "%6.0lf" is the placeholder for the returned value, the value on the left side of the "." indicates the number of whole digits to show(6) and on the right side of the ".", the amount of decimal digits, in this case (0). "\\n" specify a line return".
Code Block |
---|
%hash = ( 'title' => { 'standard' => '$node - $length from $datestamp_start to $datestamp_end', 'short' => '$node - $length' }, 'vlabel' => { 'standard' => 'IP Packet Statistics', 'short' => 'IP Packet Stats' }, 'option' => { 'standard' => [ 'DEF:ipInReceives=$database:ipInReceives:AVERAGE', 'DEF:ipInDelivers=$database:ipInDelivers:AVERAGE', 'DEF:ipOutRequests=$database:ipOutRequests:AVERAGE', 'DEF:ipForwDatagrams=$database:ipForwDatagrams:AVERAGE', 'LINE1:ipInReceives#ff0000:IP Packets Received', 'GPRINT:ipInReceives:AVERAGE:Avg %6.0lf\\n', 'LINE1:ipInDelivers#000000:IP Packets Local', 'GPRINT:ipInDelivers:AVERAGE:Avg %6.0lf\\n', 'LINE1:ipOutRequests#00FF7F:IP Packets Sent', 'GPRINT:ipOutRequests:AVERAGE:Avg %6.0lf\\n', 'LINE1:ipForwDatagrams#40E0D0:IP Packets Forwarded', 'GPRINT:ipForwDatagrams:AVERAGE:Avg %6.0lf\\n', ] } ); |
...
CDEF: Indicates the Calculation Definition. More details about the RRDtool's CDEF language.
NewVariable= Is the assignation of a new variable to hold the result performed by the calculation.
RPN_expression The Reverse Polish Notation expression used to calculate the new value. More info here.
...