2015/09/27

在 CentOS 7 安裝 snmpd 服務(CentOS 7 SNMP install)


----
在 CentOS 7 安裝 snmpd 服務(CentOS 7 SNMP install)
----
在 CentOS 7 安裝 snmpd 服務,讓主機的資訊可以透過網路取得。
環境是 CentOS 7 x86_64 版本防火牆已經關閉, SELINUX 設定為 permissive

[root@hnamenode2 snmp]# getenforce
Permissive

# 安裝 snmpd 元件
[root@hnamenode2 ~]# yum -y install net-snmp net-snmp-utils
# 修改設定檔,更換為底下資訊
[root@hnamenode2 snmp]# cat /etc/snmp/snmpd.conf
# snmp 存取資訊
com2sec local           localhost       public
com2sec localnet         192.168.0.0/16  public(public建議修改為其他的帳號)

group   MyRWGroup v1            local
group   MyROGroup v1            localnet

group   MyROSystem v1           local
group   MyROSystem v2c          local
group   MyROSystem usm          local

group   MyROGroup v1            localnet
group   MyROGroup v2c           localnet
group   MyROGroup usm           localnet

group   MyRWGroup v1            local
group   MyRWGroup v2c           local
group   MyRWGroup usm           local

view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.25.1.1
view    all    included   .1 80

access  MyROGroup ""      any       noauth    prefix  all none none
access  MyRWGroup ""      any       noauth    prefix  all all  all

# 位置及裝置資訊
sysName hadoop_hnamenode2(主機裝置名稱)
syslocation CM1022_RACK1(所在位置資訊)
syscontact mtchang@hadoop.jangmt.com (聯絡人資訊)
pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat


# 重新啟動服務
[root@hnamenode2 snmp]# systemctl restart snmpd.service

# 預設開機啟動
[root@hnamenode2 snmp]# systemctl enable snmpd.service
ln -s '/usr/lib/systemd/system/snmpd.service' '/etc/systemd/system/multi-user.target.wants/snmpd.service'

# 觀看啟動的狀態
[root@hnamenode2 snmp]# systemctl status snmpd.service
snmpd.service - Simple Network Management Protocol (SNMP) Daemon.
   Loaded: loaded (/usr/lib/systemd/system/snmpd.service; disabled)
   Active: active (running) since 日 2015-09-27 11:17:53 CST; 1min 55s ago
 Main PID: 23472 (snmpd)
   CGroup: /system.slice/snmpd.service
           └─23472 /usr/sbin/snmpd -LS0-6d -f

# 觀看 port 是否開啟
[root@hnamenode2 snmp]# netstat -auntp | grep snmp
tcp        0      0 127.0.0.1:199           0.0.0.0:*               LISTEN      23472/snmpd      
udp        0      0 0.0.0.0:161             0.0.0.0:*                           23472/snmpd   

# 驗證 snmpd 服務
[root@hnamenode2 snmp]# snmpwalk -c public -v 2c 192.168.1.250 
SNMPv2-MIB::sysDescr.0 = STRING: Linux hnamenode2 3.10.0-229.11.1.el7.x86_64 #1 SMP Thu Aug 6 01:06:18 UTC 20
15 x86_64
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (7188) 0:01:11.88
SNMPv2-MIB::sysContact.0 = STRING: cccm@cm.nsysu.edu.tw
SNMPv2-MIB::sysName.0 = STRING: hadoop_hnamenode2
SNMPv2-MIB::sysLocation.0 = STRING: CM1022_RACK1
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORID.1 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.2 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.6 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.7 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.8 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.9 = OID: SNMP-NOTIFICATION-MIB::snmpNotifyFullCompliance
SNMPv2-MIB::sysORID.10 = OID: NOTIFICATION-LOG-MIB::notificationLogMIB
SNMPv2-MIB::sysORDescr.1 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.2 = STRING: The management information definitions for t
... 略 ....

ref:
https://www.haproxy.com/doc/hapee/1.5/configuration/snmp_redhat_above55.html
http://www.liquidweb.com/kb/how-to-install-and-configure-snmp-on-centos/
張貼留言

like