Sunday, July 23, 2017

setup snmp agent on linux system

1- install snmp agent
$ sudo apt-get install snmpd

2- modified its configuration file /etc/snmp/snmp.conf as below, so that we can
- get wider accessible to system information for public community string
-  rw community strings : private

agentAddress  udp:127.0.0.1:161
view   systemonly  included   .1.3.6.1.2.1.1
view   systemonly  included   .1.3.6.1.2.1.25.1
view   systemonly  included   .1.3.6.1.4.1
 rocommunity public  default    -V systemonly
 rocommunity6 public  default   -V systemonly
 rwcommunity private
pass .1.3.6.1.4.1.8072.2.255  /snmp/set/value
 rouser   authOnlyUser
sysLocation    Sitting on the Dock of the Bay
sysContact     Me <me@example.org>
sysServices    72
proc  mountd
proc  ntalkd    4
proc  sendmail 10 1
disk       /     10000
disk       /var  5%
includeAllDisks  10%
load   12 10 5
 trapsink     localhost public
iquerySecName   internalUser      
rouser          internalUser
defaultMonitors          yes
linkUpDownNotifications  yes
 extend    test1   /bin/echo  Hello, world!
 extend-sh test2   echo Hello, world! ; echo Hi there ; exit 35
 master          agentx



- restart the service
$ sudo /etc/init.d/snmpd restart


3- to get the whole info
- partial
$ snmpwalk -v 2c -c public localhost 

-all
$ snmpwalk -v 2c -c private localhost 

-to get mibs des
$ snmpwalk -v 2c -c private localhost -m All

-to get number only
$ snmpwalk -v 2c -c private -On localhost


- cpu related
1 minute Load: .1.3.6.1.4.1.2021.10.1.3.1
5 minute Load: .1.3.6.1.4.1.2021.10.1.3.2
15 minute Load: .1.3.6.1.4.1.2021.10.1.3.3
percentage of user CPU time: .1.3.6.1.4.1.2021.11.9.0
raw user cpu time: .1.3.6.1.4.1.2021.11.50.0
percentages of system CPU time: .1.3.6.1.4.1.2021.11.10.0
raw system cpu time: .1.3.6.1.4.1.2021.11.52.0
percentages of idle CPU time: .1.3.6.1.4.1.2021.11.11.0
raw idle cpu time: .1.3.6.1.4.1.2021.11.53.0
raw nice cpu time: .1.3.6.1.4.1.2021.11.51.0

- memory related
Total Swap Size: .1.3.6.1.4.1.2021.4.3.0
Available Swap Space: .1.3.6.1.4.1.2021.4.4.0
Total RAM in machine: .1.3.6.1.4.1.2021.4.5.0
Total RAM used: .1.3.6.1.4.1.2021.4.6.0
Total RAM Free: .1.3.6.1.4.1.2021.4.11.0
Total RAM Shared: .1.3.6.1.4.1.2021.4.13.0
Total RAM Buffered: .1.3.6.1.4.1.2021.4.14.0
Total Cached Memory: .1.3.6.1.4.1.2021.4.15.0

-disk related
Path where the disk is mounted: .1.3.6.1.4.1.2021.9.1.2.1
Path of the device for the partition: .1.3.6.1.4.1.2021.9.1.3.1
Total size of the disk/partion (kBytes): .1.3.6.1.4.1.2021.9.1.6.1
Available space on the disk: .1.3.6.1.4.1.2021.9.1.7.1
Used space on the disk: .1.3.6.1.4.1.2021.9.1.8.1
Percentage of space used on disk: .1.3.6.1.4.1.2021.9.1.9.1
Percentage of inodes used on disk: .1.3.6.1.4.1.2021.9.1.10.1

sys uptime
.1.3.6.1.2.1.1.3.0


4- now to write to snmp agent, sysName, .1.3.6.1.2.1.1.5.0
- set the name to new-sys
$ snmpset  -v 2c -c private localhost .1.3.6.1.2.1.1.5.0 s new-sys

the only will be stored in
/var/lib/snmp/snmpd.conf



*** tips

if you want ond oid and what to translated from mib
$ snmptranslate -m All .1.3.6.1.2.1.1.5.0
Bad operator (INTEGER): At line 73 in /usr/share/snmp/mibs/ietf/SNMPv2-PDU
RFC1213-MIB::sysName.0




No comments:

Post a Comment