tutorials questions & answers
by AlexB

SNMP Master Agent setup on Centos 7.4 and Ubuntu 17.04

TAGS:
  • linux
  • SNMP
  • network
  • monitoring
  • ubuntu
  • centos

Introduction

I hope you know what SNMP is. If not, feel free to read our guide about basic principals of SNMP. SNMP is a protocol, used to monitor and configure different network devices. First step to utilize such setup is to setup an agent, that will gather information about a desired machine and, master from which we will perform requests. To quickly setup such configurations, we will use a network of two linux machines, one will serv as agent, another one as master.

Prerequisites: 1) Centos 7.4 VPS server ( or local machine ) 2) Ubuntu 17.04 VPS server ( or local machine ) 3) Basic knowledge of how to install packages, change config files and run commands 4) Read basic principals of SNMP

Setup

Centos system: Centos system will serve as agent. We will send requests to it, to gather information about it. 1) Determine machine IP address and remember it, or write it down.

ip addr show

snmp1

2) Install SNMP agent package

yum -y install net-snmp

snmp2 3) check default config

grep -v '^$\|^\s*\#' /etc/snmp/snmpd.conf

snmp3 4) Backup original config

mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig

5) Create an empty /etc/snmp/snmpd.conf and fill it with the following content

rocommunity vpsservers 185.181.8.0/24
# setup info
syslocation  "my Centos VPS server"
syscontact  "My Contact name"
# open up
agentAddress  udp:161
# run as
agentuser  root
# dont log connection from UDP:
dontLogTCPWrappersConnects yes
# fix for larger then 2TB disks (raid!)
realStorageUnits 0

IMPORTANT : rocommunity vpsservers 185.181.8.0/24, define the name of network that connections from will be accepted, and network diapason, please set the network, from which you will be accessing the SNMP agent. snmp5

6) Now let's make SNMP service less verbose edit /etc/sysconfig/snmpd uncomment OPTIONS string and make it look like

OPTIONS="-Ls3d"

snmp6 7) Now let's start, enable service, and check that it is running OK

systemctl start snmpd
systemctl enable snmpd
systemctl status snmpd

snmp7

UBUNTU: I am using another VPS server for my ubuntu setup. 1) Let's install snmp and then snmp-mibs-downloader

apt-get install snmp
apt-get install snmp-mibs-downloader

snmp8

2) Now let's try to query some information from our agent:

snmpwalk -Os -c vpsservers -v1 185.181.8.68 SNMPv2-MIB::sysDescr.0

snmp9

snmpwalk -Os -c vpsservers -v1 185.181.8.68 SNMPv2-MIB::sysUpTime.0

snmp10

Conclusion:

Now you know how to setup a real-life SNMP master-agent setup, make a request to your SNMP agent and get the information. This is the first step in creating a fully monitored system. You can check /var/lib/snmp/mibs/ietf/SNMPv2-MIB for attributes you may query. For example:

sysDescr
sysObjectID
sysUpTime 
sysContact
sysName
sysLocation
sysServices
sysORLastChange
sysORTable
sysOREntry
sysORIndex
sysORID
sysORDescr
sysORUpTime
snmpInPkts
snmpInBadVersions
snmpInBadCommunityNames
snmpInBadCommunityUses
snmpInASNParseErrs
snmpEnableAuthenTraps
snmpSilentDrops
snmpProxyDrops
snmpTrapOID
snmpTrapEnterprise
snmpSetSerialNo
snmpOutPkts
snmpInTooBigs
snmpInNoSuchNames
snmpInBadValues
snmpInReadOnlys
snmpInGenErrs
snmpInTotalReqVars
snmpInTotalSetVars
snmpInGetRequests
snmpInGetNexts
snmpInSetRequests
snmpInGetResponses
snmpInTraps
snmpOutTooBigs
snmpOutNoSuchNames
snmpOutBadValues
snmpOutGenErrs
snmpOutGetRequests
snmpOutGetNexts
snmpOutSetRequests
snmpOutGetResponses
snmpOutTraps

comments (0)

    leave comment

    Please choose login or register to comment in this thread.

    Start now for as low as $4,99 a month!

    • 8 Characters
    • 1 Uppercase Atleast
    • 1 Number Atleast