在RedHat Linux系統中安裝和配置snmp服務

來源:互聯網
上載者:User

標籤:redhat linux伺服器安裝snm   redhat linux配置snmp服務   linux伺服器snmp擷取cpu   記憶體   硬碟資訊   

檢查系統是否安裝snmp服務# rpm -qa|grep snmp
net-snmp-5.3.2.2-17.el5
net-snmp-perl-5.3.2.2-17.el5
net-snmp-devel-5.3.2.2-17.el5
net-snmp-libs-5.3.2.2-17.el5
net-snmp-utils-5.3.2.2-17.el5
net-snmp-libs-5.3.2.2-17.el5
net-snmp-devel-5.3.2.2-17.el5

SNMP服務安裝後會有以上安裝包


安裝SNMP服務1.配置好本地yum服務,使用yum安裝   yum install -y net-snmp*
2.配置SNMP服務開機啟動  #chkconfig snmpd on
  #chkconfig --list | grep snmpd  查看開機啟動設定是否成功
  snmpd           0:關閉  1:關閉  2:啟用  3:啟用  4:啟用  5:啟用  6:關閉

驗證SNMP服務1.使用snmpwalk擷取主機名稱 # snmpwalk -v 2c -c public localhost sysName.0
 SNMPv2-MIB::sysName.0 = STRING: wh69
 snmpwalk用法
 snmpwalk -v 1|2c|3(代表SNMP版本) -c <community string> IP地址 OID(對象標示符)
2.使用snmptranslate命令,檢查snmp工具是否可以使用 # snmptranslate -To | head
 .1.3
 .1.3.6
 .1.3.6.1
 .1.3.6.1.1
 .1.3.6.1.2
 .1.3.6.1.2.1
 .1.3.6.1.2.1.1
 .1.3.6.1.2.1.1.1
 .1.3.6.1.2.1.1.2
 .1.3.6.1.2.1.1.3
查出了部分oid,則表示snmp工具可以正常使用

配置SNMP服務1.配置SNMP連接字串 community string  #vi /etc/snmp/snmpd.conf
  修改下面欄位
#       sec.name  source          communitycom2sec notConfigUser  default    public
修改 public為自己定義的community string
2.修改查看裝置節點許可權 在設定檔/etc/snmp/snmpd.conf中找到如下位置
##### 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.1view    systemview    included   .1.3.6.1.2.1.25.1.1
view:定義了可以查看哪些節點裝置的資訊。
snmp預設配置只能查看.1.3.6.1.2.1.1和.1.3.6.1.2.1.25.1.1節點下的裝置資訊,
而主機CPU和記憶體等裝置都不在這些節點下,所以無法擷取這些資料。
因此,可以修改這個配置,如下:
##### 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   .1view    systemview    included   .1.3.6.1.2.1.1view    systemview    included   .1.3.6.1.2.1.25.1.1
在此處添加了一行:
view    systemview    included   .1
表示可以查看.1節點下的所有裝置資訊。 
3.修改Process checks的配置在設定檔/etc/snmp/snmpd.conf中找到如下位置
################################################################################ Process checks.##  The following are examples of how to use the agent to check for#  processes running on the host.  The syntax looks something like:##  proc NAME [MAX=0] [MIN=0]##  NAME:  the name of the process to check for.  It must match#         exactly (ie, http will not find httpd processes).#  MAX:   the maximum number allowed to be running.  Defaults to 0.#  MIN:   the minimum number to be running.  Defaults to 0.##  Examples (commented out by default):##  Make sure mountd is running#proc mountd#  Make sure there are no more than 4 ntalkds running, but 0 is ok too.#proc ntalkd 4#  Make sure at least one sendmail, but less than or equal to 10 are running.#proc sendmail 10 1
去除
#proc mountd
#proc ntalkd 4
#proc sendmail 10 1

這三行前面的#號,取消注釋
4.修改Executables/scripts配置在設定檔/etc/snmp/snmpd.conf中找到如下位置
################################################################################ Executables/scripts###  You can also have programs run by the agent that return a single#  line of output and an exit code.  Here are two examples.##  exec NAME PROGRAM [ARGS ...]##  NAME:     A generic name.#  PROGRAM:  The program to run.  Include the path!#  ARGS:     optional arguments to be passed to the program# a simple hello world#exec echotest /bin/echo hello world# Run a shell script containing:

#exec echotest /bin/echo hello world
前面的#去掉,取消注釋
5.修改disk checks配置

在設定檔/etc/snmp/snmpd.conf中找到如下位置

################################################################################ disk checks## The agent can check the amount of available disk space, and make# sure it is above a set limit.  # disk PATH [MIN=100000]## PATH:  mount path to the disk in question.# MIN:   Disks with space below this value will have the Mib's errorFlag set.#        Default value = 100000.# Check the / partition and make sure it contains at least 10 megs.#disk / 10000

#disk / 10000
前的#號去掉,取消注釋

6.修改load average checks配置在設定檔/etc/snmp/snmpd.conf中找到如下位置
################################################################################ load average checks## load [1MAX=12.0] [5MAX=12.0] [15MAX=12.0]## 1MAX:   If the 1 minute load average is above this limit at query#         time, the errorFlag will be set.# 5MAX:   Similar, but for 5 min average.# 15MAX:  Similar, but for 15 min average.# Check for loads:#load 12 14 14

#load 12 14 14
前的#去掉,取消注釋
7.儲存修改,重啟snmp服務#service snmpd restart
8.驗證修改配置後的snmp服務# snmpwalk -v 2c -c xindixindi localhost 1.3.6.1.4.1.2021.11.11.0
UCD-SNMP-MIB::ssCpuIdle.0 = INTEGER: 99
如上,通過本機localhost擷取到CPU的空閑率為99%

完成配置現在可以在solarwinds和Cacti等監控系統中,通過SNMP服務監控該linux伺服器了。





相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.