1. Home
  2. Tutorials
  3. Networking
  4. SNMP
Yolinux.com Tutorial

Linux SNMP: Simple Network Management Protocol:

Installing and using SNMP on Linux

Free Information Technology Magazines and Document Downloads
TradePub link image

SNMP Description

SNMP or Simple Network Management Protocol, is a technology standard for alert messages (trap), monitoring (get), and configuring (set) network devices. SNMP comes in three varieties: v1, v2 and v3, of which v3 is the only version to be considered secure.

The variables associated with a network device configuration is defined in the Management Information Base, or MIB. The MIB is a collection of information for managing the network element and is comprised of managed objects identified by the Object Identifier (OID). Each OID is unique and identifies a special characteristic of the managed network device. SNMP is built upon a client (SNMP manager) - server (SNMP agent/network device) architecture pattern with a message schema defined by the MIB and sent over UDP port 161 (SNMP agent) and port 162 (SNMP manager). Each of the data values defined by the MIB are associated with an OID identified by a hierarchy of numbers separated by periods.

SNMP Linux Installation:


  • CentOS/RedHat: sudo yum install net-snmp-utils net-snmp net-snmp-devel
    (RPMs also included with CentOS/RHEL 6 and 7 install DVDs)
  • Ubuntu: sudo apt-get install snmp snmpd snmp-mibs-downloader


  • System file /etc/snmp/snmpd.conf
    This file default restricts access to localhost only.
  • User file ~/.snmp/snmp.conf


  • CentOS/RedHat:
    • sudo systemctl enable snmpd.service
    • sudo systemctl start snmpd.service
    • sudo systemctl status snmpd.service
       snmpd.service - Simple Network Management Protocol (SNMP) Daemon.
         Loaded: loaded (/usr/lib/systemd/system/snmpd.service; enabled; vendor preset: disabled)
         Active: active (running) since Tue 2019-07-02 17:03:02 PDT; 3s ago
       Main PID: 345 (snmpd)
         Memory: 6.8M
         CGroup: /system.slice/snmpd.service
                 └─345 /usr/sbin/snmpd -LS0-6d -f
      Jul 02 17:03:01 myhostname systemd[1]: Starting Simple Network Management Protocol (.....
      Jul 02 17:03:02 myhostname snmpd[345]: NET-SNMP version 5.7.2
      Jul 02 17:03:02 myhostname systemd[1]: Started Simple Network Management Protocol (S.....
      Hint: Some lines were ellipsized, use -l to show in full.
  • Ubuntu:
    • sudo systemctl enable snmpd.service
    • sudo systemctl start snmpd.service
    • sudo systemctl status snmpd.service


  • snmpwalk -v 1 localhost -c public .
  • snmpwalk -v 1 localhost -c public system
[Potential Pitfall]: open up the firewall rules:
  • Open firewall to everything (if using iptables): sudo iptables -F
  • if using firewald: sudo firewall-cmd --permanent --new-service=snmp
    this command will add service to directory /etc/firewalld/services/
Note: Ports 161 and 162 need to be available. See /etc/services:
snmp            161/tcp                         # Simple Net Mgmt Proto
snmp            161/udp                         # Simple Net Mgmt Proto
snmptrap        162/tcp                         # SNMPTRAP
snmptrap        162/udp         snmp-trap       # Traps for SNMP
cmip-man        163/tcp                         # ISO mgmt over IP (CMOT)

SNMP Command Examples:

  • RHEL 7: snmpget -v 1 -c public localhost sysDescr.0
    SNMPv2-MIB::sysDescr.0 = STRING: Linux myhostname 3.10.0-693.el7.x86_64 #1 SMP Thu Jul 6 19:56:57 EDT 2017 x86_64
    Ubuntu: snmpget -v 1 -c public localhost .
    iso. = STRING: "Linux myhostname 4.15.0-70-generic #79-Ubuntu SMP Tue Nov 12 10:36:11 UTC 2019 x86_64"
  • RHEL 7: snmptranslate -Tp | less
                |  |
                |  +--mib-2(1)
                |     |
                |     +--system(1)
                |     |  |
                |     |  +-- -R-- String    sysDescr(1)
                |     |  |        Textual Convention: DisplayString
                |     |  |        Size: 0..255
                |     |  +-- -R-- ObjID     sysObjectID(2)
                |     |  +-- -R-- TimeTicks sysUpTime(3)
                |     |  |  |
                |     |  |  +--sysUpTimeInstance(0)
                |     |  |
                |     |  +-- -RW- String    sysContact(4)
                |     |  |        Textual Convention: DisplayString
                |     |  |        Size: 0..255

    MIB files have to be installed on your system so that it understands the schema hierarchy of the system you want to query.

  • net-snmp-config --default-mibs --default-mibdirs

    Look in /usr/share/snmp/mibs/ for a full list of system MIB files.

  • Print table: snmptable -v 1 -c public localhost sysORTable
    (CentOS/RHEL only)
  • Print system uptime: snmpget -v 1 localhost -c public .
    iso. = Timeticks: (1310658) 3:38:26.58
  • Print CPU 15 minute load: snmpget -v 1 localhost -c public .
    iso. = STRING: "0.10"

SNMP Man Pages:
snmpcmd options and behavior common to most of the Net-SNMP command-line tools
snmpwalk retrieve a subtree of management values using SNMP GETNEXT requests
snmpget communicates with a network entity using SNMP GET requests
snmpset communicates with a network entity using SNMP SET requests
snmptrap sends an SNMP notification to a manager (also snmpinform)
snmpgetnext communicates with a network entity using SNMP GETNEXT requests to get the next variable that is lexicographically "next" in the remote entity's MIB
snmptable retrieve an SNMP table and display it in tabular form
snmpdelta Monitor delta differences in SNMP Counter values
snmptest flexible SNMP application that can monitor and manage information on a network entity
snmpdf display disk space usage on a network entity via SNMP
snmpusm creates and maintains SNMPv3 users on a network entity
snmpstatus retrieves a fixed set of management information from a network entity
snmpnetstat display networking status and configuration information from a network entity via SNMP
snmpbulkget SNMP application that uses the SNMP GETBULK request to query a network entity efficiently for information
snmpbulkwalk retrieve a subtree of management values using SNMP GETBULK requests
snmp.conf configuration files for the Net-SNMP applications
SNMP Variables Format of specifying variable names to SNMP tools


The Object Identifiers (OID)s are used to identify a specific characteristic of a managed device.

There are two types of Managed OIDs:
  1. Scalar: managed object with a single instance (a single key to a key-value pair)
  2. Tabular: multiple data instances such as the rows of a table (e.g. CPU with multiple cores each with its' own specific charateristics)

SNMP uses ASN.1 (Abstract Syntax Notation One) to define the data types used to build an SNMP message and uses Basic Encoding Rules (BER) to define the data types.

Two data types each with multiple sub-types:
  • Primitive Type: type/length(bytes)/data
    • integer
    • octet (byte, char)
    • string
    • null
    • boolean
    • OID
  • Complex Type: type/length/(type/length/data)(type/length/data)
    • sequence
    • SNMP PDU (Protocol Data Unit) - complex data types specific to SNMP
CPU Statistics
. 1 minute
. 5 minute
. 15 minute
. of user CPU time
. user cpu time
. of system CPU time
. system cpu time
. of idle CPU time
. idle cpu time
. nice cpu time
Memory Statistics
. Swap Size
. Swap Space
. RAM in machine
. RAM used
. RAM Free
. RAM Shared
. RAM Buffered
. Cached Memory
Disk Statistics
. path where disk is mounted
. of the device for the partition
. size of the disk/partition (kBytes)
. space on the disk
. space on the disk
. of space used on disk
. of inodes used on disk
System Statistics
. uptime
. name



  • CentOS/RedHat: sudo yum install net-snmp-gui
    (uses EPEL repository)
  • Ubuntu: sudo apt-get install tkmib

Run: tkmib localhost

Select the "walk" button to traverse the OIDs.

ASN.1Abstract Syntax Notation One
BERBasic Encoding Rules
MIBManagement Information Base (data schema for an SNMP device and its variables)
OIDObject Identifiers (period separated number notation used to define the SNMP device variables)
PDUProtocol Data Unit (SNMP packet construction definition)
SNMPSimple Network Management Protocol


Book imageBooks:

Net-SNMP On CentOS 7.x
by Steven Cortright
Kindle ebook


Bookmark and Share