linux 下snmp安裝與使用

來源:互聯網
上載者:User

標籤:linux

安裝snmp

確認snmp代理已安裝

rpm -q net-snmp

如果未安裝,安裝snmp

yum install net-snmp


設定開機自動運行snmp

/sbin/chkconfig snmpd on配置snmp


修改設定檔

將原來的設定檔備份,編輯/etc/snmp/snmpd.conf,簡單配置如下


# First, map the community name "public" into a "security name"


#       sec.name  source          community

com2sec notConfigUser  default       public


####

# Second, map the security name into a group name:


#       groupName      securityModel securityName

group   notConfigGroup v1           notConfigUser

group   notConfigGroup v2c           notConfigUser


####

# Third, create a view for us to let the group have rights to:


# Make at least  snmpwalk -v 1 localhost -c public system fast again.

#       name           incl/excl     subtree         mask(optional)

view    systemview    included   .1.3.6.1.2.1.1

view    systemview    included   .1.3.6.1.2.1.25.1.1


####

# Finally, grant the group read-only access to the systemview view.


#       group          context sec.model sec.level prefix read   write  notif

access  notConfigGroup ""      any       noauth    exact  systemview none none

啟動snmp

/etc/init.d/snmpd start

如果已啟動則重啟snmp服務

/etc/init.d/snmpd restart


測試snmp

查看連接埠是否開啟

netstat -ln | grep 161


安裝snmp測試載入器

yum install net-snmp-utils


本機測試snmp資料(修改monit為配置的團體名)

snmpwalk -v 2c -c public localhost system


snmpwalk -v3 -u username -l auth -a MD5 -A password localhost


建立SNMP(v3)使用者


net-snmp-config --create-snmpv3-user -ro -a MD5 lyceemsnmp lyceem.com


遠程測試snmp資料(修改ip為伺服器ip,snmpwalk命令需要安裝net-snmp)

snmpwalk -v 2c -c public ip system


故常處理

錯誤排除如果本地測試snmp有資料,遠程測試snmp無資料則由於伺服器防火牆禁止了外部存取伺服器udp 161連接埠,則:

修改 /etc/sysconfig/iptables (或者:/etc/sysconfig/iptables-config ) ,增加如下規則:

-A RH-Firewall-1-INPUT -p udp -m state Cstate NEW -m udp Cdport 161 -j ACCEPT

重啟iptables

/etc/init.d/iptables restart 


本文出自 “Lonely(技術群:1991706)” 部落格,請務必保留此出處http://304076020.blog.51cto.com/7503470/1545302

linux 下snmp安裝與使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.