CentOS 5.x 之簡易 snmp 設定

CentIS 5.1

(1) 先確定有無安裝必要程式

rpm -qa | grep net-snmp

net-snmp-utils-5.3.1-19.el5_1.4 沒安裝會找不到 snmpwalk
net-snmp-libs-5.3.1-19.el5_1.4
net-snmp-5.3.1-19.el5_1.4


如果沒有安裝的話,用 yum 或是其他方法自行搞定!
搞定後記得把 snmpd 啟動,且設定為開機執行

chkconfig snmpd on
service snmpd start

(2) 設定 /etc/snmp/snmpd.conf

mrtg 會跑步起來,大部分的問題出在 snmp.conf 設定錯誤,一開始
可以執行 snmpwalk 測試看看

ex:

snmpwalk -c public -v 1 localhost system

-c public 指定 community ,public 是預設值,如果你更改了
snmp.conf community 設定,務必換成你自己的設定值。
snmpwalk 指令使用方法可以問男人 man snmpcmd

 -v 1 指定 protocol 版本,依你的 snmpd.conf 設定。

正確的話你應該可以看到許多類似如下的訊息:

SNMPv2-MIB::sysDescr.0 = STRING: Linux bscldap.cht.com.tw 2.6.18-8.1.15.el5 #1 SMP Mon Oct 22 08:32:04 EDT 2007 i686
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (261) 0:00:02.61
SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
SNMPv2-MIB::sysName.0 = STRING: bscldap.cht.com.tw
SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00
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: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (0) 0:00:00.00


修改 snmpd.conf 如下:

com2sec notConfigUser  default       public

group   notConfigGroup v1           notConfigUser
group   notConfigGroup v2c           notConfigUser

view    all           included   .1 80
view    systemview    included   .1.3.6.1.2.1.2
view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.25.1.1
view    systemview    included   .1.3.6.1.2.1.2.2.1
view    systemview    included   .1.3.6.1.4.1.2021.4.5.0
view    systemview    included   .1.3.6.1.4.1.2021.4.6.0
view    systemview    included   .1.3.6.1.4.1.2021.4.11.0
view    systemview    included   .1.3.6.1.4.1.2021.10.1.3.1
view    systemview    included   .1.3.6.1.4.1.2021.10.1.3.2
view    systemview    included   .1.3.6.1.4.1.2021.10.1.3.3
view    systemview    included   .1.3.6.1.4.1.2021.4.3.0
view    systemview    included   .1.3.6.1.4.1.2021.4.4.0
view    systemview    included   .1.3.6.1.4.1.2021.4.5.0
view    systemview    included   .1.3.6.1.4.1.2021.4.6.0
view    systemview    included   .1.3.6.1.4.1.2021.4.11.0
view    systemview    included   .1.3.6.1.4.1.2021.4.13.0
view    systemview    included   .1.3.6.1.4.1.2021.4.14.0
view    systemview    included   .1.3.6.1.4.1.2021.4.15.0
view    systemview    included   .1.3.6.1.4.1.2021.9.1.2.1
view    systemview    included   .1.3.6.1.4.1.2021.9.1.3.1
view    systemview    included   .1.3.6.1.4.1.2021.9.1.6.1
view    systemview    included   .1.3.6.1.4.1.2021.9.1.7.1
view    systemview    included   .1.3.6.1.4.1.2021.9.1.8.1
view    systemview    included   .1.3.6.1.4.1.2021.9.1.9.1
view    systemview    included   .1.3.6.1.4.1.2021.9.1.10.1
view    systemview    included   .1.3.6.1.4.1.2021.11.9.0
view    systemview    included   .1.3.6.1.4.1.2021.11.50.0
view    systemview    included   .1.3.6.1.4.1.2021.11.10.0
view    systemview    included   .1.3.6.1.4.1.2021.11.52.0
view    systemview    included   .1.3.6.1.4.1.2021.11.11.0
view    systemview    included   .1.3.6.1.4.1.2021.11.53.0
view    systemview    included   .1.3.6.1.4.1.2021.11.51.0

syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)


#其他設定方法 (example of RH9)

# # sec.name source community
>com2sec local localhost your_community
>com2sec mynetwork 192.168.1.0/24 you_community
>
>
> your_community 改成你喜歡的識別字,自己記得住就好!
>
> 192.168.1.0/24 請根據你自己的情況加以修改,不要傻傻的照抄喔!
>
>
> # group.name sec.model sec.name
> group MyRWGroup any local
> group MyROGroup any mynetwork
>
>
> any 可以改成 v1 或 v2c 或 v3,不改也行!
>
>
> # incl/excl subtree mask
> view all included .1 80
>
> ## context sec.model sec.level prefix read write notify
> access MyROGroup "" any noauth 0 all none none
> access MyRWGroup "" any noauth 0 all all all
>
> syslocation Redhat 9.0〈隨便填不是粉重要〉
> syscontact <root@localhost>〈填上你的 email ,不是粉重要〉

access notConfigGroup "" any noauth 0 all none none

parrotchang 發表在 痞客邦 PIXNET 留言(0) 人氣()