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:
view   systemonly  included   .
view   systemonly  included   .
view   systemonly  included   .
 rocommunity public  default    -V systemonly
 rocommunity6 public  default   -V systemonly
 rwcommunity private
pass .  /snmp/set/value
 rouser   authOnlyUser
sysLocation    Sitting on the Dock of the Bay
sysContact     Me <>
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 

$ 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: .
5 minute Load: .
15 minute Load: .
percentage of user CPU time: .
raw user cpu time: .
percentages of system CPU time: .
raw system cpu time: .
percentages of idle CPU time: .
raw idle cpu time: .
raw nice cpu time: .

- memory related
Total Swap Size: .
Available Swap Space: .
Total RAM in machine: .
Total RAM used: .
Total RAM Free: .
Total RAM Shared: .
Total RAM Buffered: .
Total Cached Memory: .

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

sys uptime

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

the only will be stored in

*** tips

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

No comments:

Post a Comment