Pages

Wednesday 22 January 2014

SNMP configure to use PRTG

Subject: How to configure SNMP in Ubuntu (monitored by PRTG)

Step 1: Install SNMP

Step 2: Configure SNMP

1_ Configure file /etc/snmp/snmpd.conf

Run:
#vi /etc/snmp/snmpd.conf

Un-comment this line:
  • #  Listen for connections from the local system only
    #agentAddress  udp:127.0.0.1:161
    #  Listen for connections on all interfaces (both IPv4 *and* IPv6)
    agentAddress udp:161,udp6:[::1]:161
Change this line:
  • #rocommunity public  localhost
                                                     #  Default access to basic system info
     rocommunity nhutcom  
Where "nhutcom" is community string for SNMP target

Change this line:
  • #rocommunity secret  10.0.0.0/16
    rocommunity secret 172.18.72.0/24,172.16.72.0/24,172.18.21.0/24
With 172.18.72.0/24,172.16.72.0/24,172.18.21.0/24 is network we want to allow get SNMP traffic from   

2_ Configure file /etc/default/snmpd

Change this line from:

  • SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
To: 
  • SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid'
Just remove 127.0.0.1 at the end of the line.

After done all above step, let check the result, run:

#snmpwalk -v 2c -c <comminity string> localhost

and
#snmpwalk -v 2c -c <string> <IP external of the server>      //snmpwalk -v 2c -c nhutcom 192.168.1.1

And the result should be

  • SNMPv2-MIB::sysDescr.0 = STRING: Linux blablabla 2.6.18-308.el5 #1 SMP Tue Feb 21 20:05:41 EST 2012 i686
    SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
    DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (15216041) 1 day, 18:16:00.41
    SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
    SNMPv2-MIB::sysName.0 = STRING: blablabla
    SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)
    SNMPv2-MIB::sysORLastChange.0 = Timeticks: (3) 0:00:00.03
    SNMPv2-MIB::sysORID.1 = OID: SNMPv2-MIB::snmpMIB
    SNMPv2-MIB::sysORID.2 = OID: TCP-MIB::tcpMIB
    SNMPv2-MIB::sysORID.3 = OID: IP-MIB::ip
    SNMPv2-MIB::sysORID.4 = OID: UDP-MIB::udpMIB
    SNMPv2-MIB::sysORID.5 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
    SNMPv2-MIB::sysORID.6 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
    SNMPv2-MIB::sysORID.7 = OID: SNMP-MPD-MIB::snmpMPDCompliance
    SNMPv2-MIB::sysORID.8 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
    SNMPv2-MIB::sysORDescr.1 = STRING: The MIB module for SNMPv2 entities
    SNMPv2-MIB::sysORDescr.2 = STRING: The MIB module for managing TCP implementations
    SNMPv2-MIB::sysORDescr.3 = STRING: The MIB module for managing IP and ICMP implementations
    SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for managing UDP implementations
    SNMPv2-MIB::sysORDescr.5 = STRING: View-based Access Control Model for SNMP.
    SNMPv2-MIB::sysORDescr.6 = STRING: The SNMP Management Architecture MIB.
    SNMPv2-MIB::sysORDescr.7 = STRING: The MIB for Message Processing and Dispatching.
    SNMPv2-MIB::sysORDescr.8 = STRING: The management information definitions for the SNMP User-based Security Model.
    SNMPv2-MIB::sysORUpTime.1 = Timeticks: (2) 0:00:00.02
    SNMPv2-MIB::sysORUpTime.2 = Timeticks: (2) 0:00:00.02
    SNMPv2-MIB::sysORUpTime.3 = Timeticks: (2) 0:00:00.02
    SNMPv2-MIB::sysORUpTime.4 = Timeticks: (2) 0:00:00.02
    SNMPv2-MIB::sysORUpTime.5 = Timeticks: (2) 0:00:00.02
    SNMPv2-MIB::sysORUpTime.6 = Timeticks: (3) 0:00:00.03
    SNMPv2-MIB::sysORUpTime.7 = Timeticks: (3) 0:00:00.03
    SNMPv2-MIB::sysORUpTime.8 = Timeticks: (3) 0:00:00.03
    HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (15326821) 1 day, 18:34:28.21
    .... And more
And should not : "Timeout: No Response from localhost"

And don't forget to put SNMP deamon to automatically start when system start


One thing, when using snmptester of Paessler to check, the result maybe:
 Just ignore it. Let declare your server into your monitor system.


===================================
DO THE SAME TASK WITH CENTOS
===================================

Setup and configure SNMP in Centos and Ubuntu have some differences:


# yum install net-snmp-utils net-snmp
# up2date -v -i net-snmp-utils net-snmp
# vi /etc/snmp/snmpd.conf
Find the following Line:
com2sec notConfigUser  default       public

Replace with (make sure you replace 192.168.0.0/24 with your network/subnet) the following lines:
com2sec local     localhost           public
com2sec mynetwork 192.168.0.0/24      public
Find Lines:
group   notConfigGroup v1           notConfigUser
group   notConfigGroup v2c           notConfigUser

Replace with:
group MyRWGroup v1         local
group MyRWGroup v2c        local
group MyRWGroup usm        local
group MyROGroup v1         mynetwork
group MyROGroup v2c        mynetwork
group MyROGroup usm        mynetwork
Find line:
view    systemview     included      system

Replace with:
view all    included  .1                               80
Find line:
access  notConfigGroup ""      any       noauth    exact  systemview none none

Replace with:
access MyROGroup ""      any       noauth    exact  all    none   none
access MyRWGroup ""      any       noauth    exact  all    all    none
Find lines:
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root  (configure /etc/snmp/snmp.local.conf)

Replace with (make sure you supply appropriate values):
syslocation Linux (RH3_UP2), Home Linux Router.
syscontact YourNameHere <you@example.com>
































No comments:

Post a Comment