架構師成長之路4.1-多維監控體系_硬件監控

點擊返回架構師成長之路html

架構師成長之路4.1-多維監控體系_硬件監控

監控其實佔用了正常運維至少60%的工做量,每每你們談及監控可能回答就是如何使用zabbix、nagix系統,但其不太注重總結監控本質。linux

監控入門:sql

  • 識別監控對象:
  • 監控對象的理解:CPU工做原理  
  • 監控對象的指標:CPU使用率、CPU負載 、CPU個數、 CPU上下文切換
  • 確認告警基準線:怎麼樣纔算故障?CPU負載多少纔算高?

預中級監控須要作:shell

  • 工具化和監控分離
  • 監控對象的分類:
    硬件監控(機房巡檢、IPMI、SNMP) 
    系統監控(對象:CPU、內存、IO[磁盤、網絡]、進程等)
    服務監控(對象:各種服務[Nginx|Tomcat|RabbitMQ|Openstack|Mysql|*])
    日誌監控(方法:Elastic Stack)
    網絡監控(方法:第三方、Smokeping)
    APM應用性能管理(工具:PINPoint)
    流量監控(工具:Piwik、xx統計、xx分析)
    其餘監控(APP監控、安全監控、業務監控、輿論監控、xx監控)
  • 掌握一個監控工具:好比zabbix

中級監控須要作數組

  • 標準化監控(標準化的腳本、模板等等)
  • 分佈式監控(主動、被動、分佈式)
  • 自動化監控(自動發現、主動註冊[Agent主動註冊、Server經過API主動添加])
  • 性能優化(數據採集、數據存儲、數據查詢)
  • 二次開發(定製報表、API調用、xxx)

進階監控須要作:安全

  • 動態告警
  • 智能告警:1.告警去重 2.去除依賴性
  • 故障自愈
  • 大規模監控

硬件監控

1  服務器硬件監控_IPMI

遠程控制卡:能夠說和服務器徹底獨立存在,遠程控制卡都是經過IPMI標準。性能優化

智能平臺管理接口 (IPMI) 是一種開放標準的硬件管理接口規格,定義了嵌入式管理子系統進行通訊的特定方法。用戶能夠利用 IPMI 監視服務器的物理特徵,如溫度、電壓、電扇工做狀態、電源供應以及機箱入侵等。Ipmi 最大的優點在 於它是獨立於 CPU BIOS 和 OS 的,因此用戶不管在開機仍是關機的狀態下,只要接通電源就能夠實現對服務器的監控。Ipmi 是一種規範的標準,其中最重要的物理部件就是BMC(Baseboard Management Controller),一種嵌入式管理微控制器,它至關於整個平臺管理的「大腦」,經過它 ipmi 能夠監控各個傳感器的數據並記錄各類事件的日誌。服務器

服務器廠家遠程控制卡名字:網絡

  •      DELL服務器:IDRAC
  •      HP服務器:ILO
  •      IBM服務器:IMM

若是在linux下使用IPMI對服務器進行硬件監控,須要什麼條件?架構

  • 硬件必須支持
  • 操做系統必須支持:linux系統確定支持
  • 管理工具:linux系統採用ipmitool (ipmitool 是一種可用在 linux 系統下的命令行方式的 ipmi 平臺管理工具,它支持 ipmi 1.5 規範(最新的規範爲 ipmi 2.0),經過它能夠實現獲取傳感器的信息、顯示系統日誌內容、網絡遠程開關機等功能。)
yum install -y OpenIPMI ipmitool   #安裝IPMI
systemctl start  ipmi   #啓動IPMI

使用IPMI兩種方式:

  • 本地調用
  • 遠程網路調試  須要IP地址,用戶名和密碼

 IPMI配置網絡兩種方式:

  • ipmi over lan  網絡數據包經過網卡
  • 獨立配置IP地址(推薦)

2  路由器和交換機硬件監控_SNMP

2.1  SNMP簡介  

  SNMP是英文"Simple Network Management Protocol"的縮寫,中文意思是"簡單網絡管理協議"。SNMP是一種簡單網絡管理協議,它屬於TCP/IP五層協議中的應用層協議,用於網絡管理的協議。SNMP主要用於網絡設備的管理。因爲SNMP協議簡單可靠 ,受到了衆多廠商的歡迎,成爲了目前最爲普遍的網管協議。

  SNMP協議主要由兩大部分構成:SNMP管理站和SNMP代理。SNMP管理站是一箇中心節點,負責收集維護各個SNMP元素的信息,並對這些信息進行處理,最後反饋給網絡管理員;而SNMP代理是運行在各個被管理的網絡節點之上,負責統計該節點的各項信息,而且負責與SNMP管理站交互,接收並執行管理站的命令,上傳各類本地的網絡信息。

  SNMP管理站和SNMP代理之間是鬆散耦合。他們之間的通訊是經過UDP協議完成的。通常狀況下,SNMP管理站經過UDP協議向SNMP代理髮送各類命令,當SNMP代理收到命令後,返回SNMP管理站須要的參數。可是當SNMP代理檢測到網絡元素異常的時候,也能夠主動向SNMP管理站發送消息,通告當前異常情況。

  SNMP的基本思想:爲不一樣種類的設備、不一樣廠家生產的設備、不一樣型號的設備,定義爲一個統一的接口和協議,使得管理員能夠是使用統一的外觀面對這些須要管理的網絡設備進行管理。經過網絡,管理員能夠管理位於不一樣物理空間的設備,從而大大提升網絡管理的效率,簡化網絡管理員的工做。

  SNMP的工做方式:管理員須要向設備獲取數據,因此SNMP提供了【讀】操做;
                                       管理員須要向設備執行設置操做,因此SNMP提供了【寫】操做;
                                       設備須要在重要情況改變的時候,向管理員通報事件的發生,因此SNMP提供了【Trap】操做。

2.2 SNMP 和 UDP

  SNMP採用UDP協議在管理端和agent之間傳輸信息。 SNMP採用UDP 161端口接收和發送請求,162端口接收trap,執行SNMP的設備缺省都必須採用這些端口。

2.3 Snmp版本

  SNMP目前共有v1,v2,v3這三個版本: 

  • SNMP v1是SNMP協議的最第一版本,不過依然是衆多廠家實現SNMP基本方式。 
  • SNMP v2一般被指是基於community的SNMP V2。Community實質上就是密碼。
  • SNMP v3 是最新版本的SNMP。它對網絡管理最大的貢獻在於其安全性。增長了對認證和密文傳輸的支持。

2.4 Snmp的實現結構

SNMP管理的網絡主要由三部分組成:
  • 被管理的設備:
  • SNMP代理 :    【被】監管的設備上運行一個SNMP代理(Agent)),代理實現設備與管理站的SNMP通訊。
  • 網絡管理系統(NMS):   負責網管命令的發出、數據存儲、及數據分析。又稱爲【管理站】
它們之間的關係
  • 網絡中被管理的每個設備都存在一個管理信息庫(MIB)用於收集並儲存管理信息。
        經過SNMP協議,NMS能獲取這些信息。被管理設備,又稱爲網絡單元或網絡節點,能夠是支持SNMP協議的路由器、交換機、服務器或者主機等等。
  • SNMP代理是被管理設備上的一個網絡管理軟件模塊,擁有本地設備的相關管理信息,並用於將它們轉換成與SNMP兼容的格式,傳遞給NMS。
  • NMS運行應用程序來實現監控被管理設備的功能。另外,NMS還爲網絡管理提供大量的處理程序及必須的儲存資源。

                                                                                                     

(1)管理信息庫MIB  

        MIB文件中的變量使用的名字取自ISO和ITU管理的對象標識符(object identifier)名字空間。它是一種分級樹的結構。

        OID(Object Identifier):
        每一個管理對象都有本身的OID(Object Identifier),管理對象經過樹狀結構進行組織,OID由樹上的一系列整數組成,整數之間用點( . )分隔開,樹的葉子節點纔是真正可以被管理的對象。
        以下圖所示,第一級有三個節點:ccitt、iso、iso-ccitt。低級的對象ID分別由相關組織分配。一個特定對象的標識符可經過由根到該對象的路徑得到。通常網絡設備取iso節點下的對象內容。
        如名字空間ip結點下一個名字爲ipInReceives的MIB變量被指派數字值3,於是該變量的名字爲: iso.org.dod.internet.mgmt.mib.ip.ipInReceives  ,,對應的對象標識符OID爲:  1.3.6.1.2.1.4.3

 

        當網絡管理協議在報文中使用MIB變量時,每一個變量名後還要加一個後綴,以做爲該變量的一個實例。如ipInReceives的實例數字表示爲:1.3.6.1.2.1.4.3.0. 須要注意的是,MIB中的管理對象的OID有些須要動態確            定:如IP路由表,爲了指明地址172.18.20.220的下一站路由(next hop),咱們能夠引用這樣的實例:

         iso.org.dod.internet.mgmt.mib.ip. ipRouteTable.ipRouteEntry.ipRouteNextHop.172.18.20.220, 相應的數字表示爲:1.3.6.1.2.1.4.21.1.7.172.18.20.220

(2)管理信息結構(SMI)

          SMI定義了SNMP框架所用信息的組織、組成和標識,它還爲描述MIB對象和描述協議怎樣交換信息奠基了基礎。SMI定義的數據類型:

   ◆  簡單類型(simple)

  • Integer:整型是-2,147,483,648~2,147,483,647的有符號整數
  • octet string: 字符串是0~65535個字節的有序序列
  • OBJECT IDENTIFIER: 來自按照ASN.1規則分配的對象標識符集

  ◆  簡單結構類型(simple-constructed)

  • SEQUENCE 用於列表。這一數據類型與大多數程序設計語言中的「structure」相似。一個SEQUENCE包括0個或更多元素,每個元素又是另外一個ASN.1數據類型
  • SEQUENCE OF type 用於表格。這一數據類型與大多數程序設計語言中的「array」相似。一個表格包括0個或更多元素,每個元素又是另外一個ASN.1數據類型。

  ◆  應用類型(application-wide)

  • IpAddress: 以網絡序表示的IP地址。由於它是一個32位的值,因此定義爲4個字節;
  • counter:計數器是一個非負的整數,它遞增至最大值,然後回零。在SNMPv1中定義的計數器是32位的,即最大值爲4,294,967,295;
  • Gauge :也是一個非負整數,它能夠遞增或遞減,但達到最大值時保持在最大值,最大值爲232-1;
  • time ticks:是一個時間單位,表示以0.01秒爲單位計算的時間;

(3)SNMP報文

       SNMP中定義了五種消息類型:Get-Request、Get-Response、Get-Next-Request、Set-Request和Trap 。

  • get-request操做:從代理進程處提取一個或多個參數值。Get-Request是由管理站發送到代理側的161端口的;
  • get-next-request操做:從代理進程處提取一個或多個參數的下一個參數值。Get-Next-Request是由管理站發送到代理側的161端口的;
  • set-request操做:設置代理進程的一個或多個參數值。Set-Request是由管理站發送到代理側的161端口的;
  • response操做:返回的一個或多個參數值。這個操做是由代理進程發出的。它是前面3中操做的響應操做。
  • trap操做:代理進程主動發出的報文,通知管理進程有某些事情發生。Trap 是由代理進程發給管理進程的,其中Trap消息被髮送到管理進程的162端口,全部數據都是走UDP封裝。

2.5 SNMP報文格式

(1)公共SNMP首部 共三個字段: 

  •  版本  該字段的值是經過SNMP版本號減1獲得的,因此:

        XX=0 對應SNMPv1

        XX=1 對應SNMPv2c

        XX=2 對應SNMPv2

        XX=3 對應SNMPv3

  • 共同體(community)共同體就是一個字符串,做爲管理進程和代理進程之間的明文口令,經常使用的是6個字符「public」。
  • PDU類型: 以下圖:

(2)get/set首部

  • 請求標識符(request ID)  : 這是由管理進程設置的一個整數值。代理進程在發送get-response報文時也要返回此請求標識符。管理進程可同時向許多代理髮出get報文,這些報文都使用UDP傳送,先發送的有可能後到達。設置了請求標識符可以使管理進程可以識別返回的響應報文對於哪個請求報文
  •  差錯狀態(error status):由代理進程回答時填入0~5中的一個數字,以下:

  •  差錯索引(error index): 當出現noSuchName、badValue或readOnly的差錯時,由代理進程在回答時設置的一個整數,它指明有差錯的變量在變量列表中的偏移。

(3)trap首部

  • 企業(enterprise):填入trap報文的網絡設備的對象標識符。此對象標識符確定是在圖3的對象命名樹上的enterprise結點{1.3.6.1.4.1}下面的一棵子樹上。
  • trap類型 :此字段正式的名稱是generic-trap,共分爲7種:

              當使用上述類型二、三、5時,在報文後面變量部分的第一個變量應標識響應的接口。

  • 特定代碼(specific-code) : 指明代理自定義的時間(若trap類型爲6),不然爲0。
  • 時間戳(timestamp) : 指明自代理進程初始化到trap報告的事件發生所經歷的時間,單位爲10ms。例如時間戳爲1908代表在代理初始化後1908ms發生了該時間。

(4)變量綁定(variable-bindings)    指明一個或多個變量的名和對應的值。在get或get-next報文中,變量的值應忽略。 

2.6 代理和管理站的模型

    Snmp分2種角色:SNMP管理站和SNMP代理(agent)。

  • 管理站指的是運行了能夠執行網絡管理任務軟件的服務器,一般被稱做爲網絡管理工做站(NMS),NMS負責採樣網絡中agent的信息,並接受agent的trap。
  • 代理是實際網絡設備中用來實現SNMP功能的部分。

     代理在UDP的161端口接收NMS的讀寫請求消息,管理站在UDP的162端口接收代理的事件通告消息。
     因此,一旦獲取設備的訪問權限(community,默認爲public),就能夠訪問設備信息、改寫和配置設備參數。因爲採用UDP協議,不須要在代理和管理站之間保持鏈接。

2.7 SNMP的操做命令

     SNMP協議之因此易於使用,這是由於它對外提供了三種用於控制MIB對象的基本操做命令。它們是:Get、Set 和 Trap

  • Get:管理站讀取代理者處對象的值。它是SNMP協議中使用率最高的一個命令,由於該命令是從網絡設備中得到管理信息的基本方式。
  • Set:管理站設置代理者處對象的值。它是一個特權命令,由於能夠經過它來改動設備的配置或控制設備的運轉狀態。它能夠設置設備的名稱,關掉一個端口或清除一個地址解析表中的項等。
  • Trap: 代理者主動向管理站通報重要事件。它的功能就是在網絡管理系統沒有明確要求的前提下,由管理代理通知網絡管理系統有一些特別的狀況或問題 發生了。若是發生意外狀況,客戶會向服務器的162端口發送一個消息,告知服務器指定的變量值發生了變化。一般由服務器請求而得到的數據由服務器的161 端口接收。Trap 消息能夠用來通知管理站線路的故障、鏈接的終端和恢復、認證失敗等消息。管理站可相應的做出處理。

2.8 SNMP的消息構成

      SNMP協議定義了數據包的格式,及網絡管理員和管理代理之間的信息交換,它還控制着管理代理的MIB數據對象。所以,可用於處理管理代理定義的各類任務。

      一條SNMP消息由"版本號"、"SNMP共同體名"和"協議數據單元(PDU)"構成,數據包的長度不是固定的。

  • 版本識別符(version identifier):用於說明如今使用的是哪一個版本的SNMP協議,確保SNMP代理使用相同的協議,每一個SNMP代理都直接拋棄與本身協議版本不一樣的數據報。
  • 團體名(Community Name)團體(community)是基本的安全機制,用於實現SNMP網絡管理員訪問SNMP管理代理時的身份驗證。相似於密碼,默認值爲 public。團體名(Community name)是管理代理的口令,管理員被容許訪問數據對象的前提就是網絡管理員知道網絡代理的口令。若是把配置管理代理成能夠執行Trap命令,當網絡管理 員用一個錯誤的分區名查詢管理代理時,系統就發送一個autenticationFailure trap報文。
  • 協議數據單元(PDU)PDU (協議數據單元)是SNMP消息中的數據區, 即Snmp通訊時報文數據的載體。PDU指明瞭SNMP的消息類型及其相關參數。

2.9 NET-SNMP 

     2.9.1 NET-SNMP簡介   

      在 Linux 系統中,咱們能夠選擇 net-snmp 來處理絕大多數和 SNMP 相關的工做。

      NET-SNMP 是一種開放源代碼的 SNMP 協議實現。它支持 SNMP v1, SNMP v2c 與 SNMP v3,並可使用 IPV4 及 IPV6 。也包含 SNMP Trap 的全部相關實現。
      NET-SNMP 包含了 snmp 實用程序集和完整的 snmp 開發庫。

  • 路由器和交換機須要配置SNMP
snmp-server community carlos88 RO 100
  • 服務器須要安裝SNMP 
 yum install net-snmp net-snmp-utils  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

snmp -v2c -c carlos88 172.18.20.220 1.3.6.1.2.1.1.3.0 # 獲取系統的運行時間
snmp -v2c -c carlos88 172.18.20.220 1.3.6.1.4.1.2021.10.1.3.1 # 獲取系統第一分鐘的負載
 

  

    2.9.2 snmpd.conf文件

一般 SNMP 服務的配置文件位於 /etc/snmp/snmpd.conf,先來看一下這個文件:

###############################################################################
#
# snmpd.conf:
#   An example configuration file for configuring the ucd-snmp snmpd agent.
#
###############################################################################
#
# This file is intended to only be as a starting point.  Many more
# configuration directives exist than are mentioned in this file.  For
# full details, see the snmpd.conf(5) manual page.
#
# All lines beginning with a '#' are comments and are intended for you
# to read.  All other lines are configuration commands for the agent.

###############################################################################
# Access Control
###############################################################################

# As shipped, the snmpd demon will only respond to queries on the
# system mib group until this file is replaced or modified for
# security purposes.  Examples are shown below about how to increase the
# level of access.

# By far, the most common question I get about the agent is "why won't
# it work?", when really it should be "how do I configure the agent to
# allow me to access it?"
#
# By default, the agent responds to the "public" community for read
# only access, if run out of the box without any configuration file in
# place.  The following examples show you other ways of configuring
# the agent so that you can change the community names, and give
# yourself write access to the mib tree as well.
#
# For more information, read the FAQ as well as the snmpd.conf(5)
# manual page.

####
# 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

# -----------------------------------------------------------------------------

# Here is a commented out example configuration that allows less
# restrictive access.

# YOU SHOULD CHANGE THE "COMMUNITY" TOKEN BELOW TO A NEW KEYWORD ONLY
# KNOWN AT YOUR SITE.  YOU *MUST* CHANGE THE NETWORK TOKEN BELOW TO
# SOMETHING REFLECTING YOUR LOCAL NETWORK ADDRESS SPACE.

##       sec.name  source          community
#com2sec local     localhost       COMMUNITY
#com2sec mynetwork NETWORK/24      COMMUNITY

##     group.name sec.model  sec.name
#group MyRWGroup  any        local
#group MyROGroup  any        mynetwork
#
#group MyRWGroup  any        otherv3user
#...

##           incl/excl subtree                          mask
#view all    included  .1                               80

## -or just the mib2 tree-

#view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc


##                context sec.model sec.level prefix read   write  notif
#access MyROGroup ""      any       noauth    0      all    none   none
#access MyRWGroup ""      any       noauth    0      all    all    all


###############################################################################
# Sample configuration to make net-snmpd RFC 1213.
# Unfortunately v1 and v2c don't allow any user based authentification, so
# opening up the default config is not an option from a security point.
#
# WARNING: If you uncomment the following lines you allow write access to your
# snmpd daemon from any source! To avoid this use different names for your
# community or split out the write access to a different community and
# restrict it to your local network.
# Also remember to comment the syslocation and syscontact parameters later as
# otherwise they are still read only (see FAQ for net-snmp).
#

# 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:
# Open up the whole tree for ro, make the RFC 1213 required ones rw.
#       name            incl/excl       subtree mask(optional)
#view    roview          included        .1
#view    rwview          included        system.sysContact
#view    rwview          included        system.sysName
#view    rwview          included        system.sysLocation
#view    rwview          included        interfaces.ifTable.ifEntry.ifAdminStatus
#view    rwview          included        at.atTable.atEntry.atPhysAddress
#view    rwview          included        at.atTable.atEntry.atNetAddress
#view    rwview          included        ip.ipForwarding
#view    rwview          included        ip.ipDefaultTTL
#view    rwview          included        ip.ipRouteTable.ipRouteEntry.ipRouteDest
#view    rwview          included        ip.ipRouteTable.ipRouteEntry.ipRouteIfIndex
#view    rwview          included        ip.ipRouteTable.ipRouteEntry.ipRouteMetric1
#view    rwview          included        ip.ipRouteTable.ipRouteEntry.ipRouteMetric2
#view    rwview          included        ip.ipRouteTable.ipRouteEntry.ipRouteMetric3
#view    rwview          included        ip.ipRouteTable.ipRouteEntry.ipRouteMetric4
#view    rwview          included        ip.ipRouteTable.ipRouteEntry.ipRouteType
#view    rwview          included        ip.ipRouteTable.ipRouteEntry.ipRouteAge
#view    rwview          included        ip.ipRouteTable.ipRouteEntry.ipRouteMask
#view    rwview          included        ip.ipRouteTable.ipRouteEntry.ipRouteMetric5
#view    rwview          included        ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaIfIndex
#view    rwview          included        ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaPhysAddress
#view    rwview          included        ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaNetAddress
#view    rwview          included        ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType
#view    rwview          included        tcp.tcpConnTable.tcpConnEntry.tcpConnState
#view    rwview          included        egp.egpNeighTable.egpNeighEntry.egpNeighEventTrigger
#view    rwview          included        snmp.snmpEnableAuthenTraps

# 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  roview rwview none



###############################################################################
# System contact information
#

# It is also possible to set the sysContact and sysLocation system
# variables through the snmpd.conf file:

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

# Example output of snmpwalk:
#   % snmpwalk -v 1 localhost -c public system
#   system.sysDescr.0 = "SunOS name sun4c"
#   system.sysObjectID.0 = OID: enterprises.ucdavis.ucdSnmpAgent.sunos4
#   system.sysUpTime.0 = Timeticks: (595637548) 68 days, 22:32:55
#   system.sysContact.0 = "Me <me@somewhere.org>"
#   system.sysName.0 = "name"
#   system.sysLocation.0 = "Right here, right now."
#   system.sysServices.0 = 72


###############################################################################
# Logging
#

# We do not want annoying "Connection from UDP: " messages in syslog.
# If the following option is commented out, snmpd will print each incoming
# connection, which can be useful for debugging.

dontLogTCPWrappersConnects yes

# -----------------------------------------------------------------------------


###############################################################################
# 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

#  A snmpwalk of the process mib tree would look something like this:
#
# % snmpwalk -v 1 localhost -c public .1.3.6.1.4.1.2021.2
# enterprises.ucdavis.procTable.prEntry.prIndex.1 = 1
# enterprises.ucdavis.procTable.prEntry.prIndex.2 = 2
# enterprises.ucdavis.procTable.prEntry.prIndex.3 = 3
# enterprises.ucdavis.procTable.prEntry.prNames.1 = "mountd"
# enterprises.ucdavis.procTable.prEntry.prNames.2 = "ntalkd"
# enterprises.ucdavis.procTable.prEntry.prNames.3 = "sendmail"
# enterprises.ucdavis.procTable.prEntry.prMin.1 = 0
# enterprises.ucdavis.procTable.prEntry.prMin.2 = 0
# enterprises.ucdavis.procTable.prEntry.prMin.3 = 1
# enterprises.ucdavis.procTable.prEntry.prMax.1 = 0
# enterprises.ucdavis.procTable.prEntry.prMax.2 = 4
# enterprises.ucdavis.procTable.prEntry.prMax.3 = 10
# enterprises.ucdavis.procTable.prEntry.prCount.1 = 0
# enterprises.ucdavis.procTable.prEntry.prCount.2 = 0
# enterprises.ucdavis.procTable.prEntry.prCount.3 = 1
# enterprises.ucdavis.procTable.prEntry.prErrorFlag.1 = 1
# enterprises.ucdavis.procTable.prEntry.prErrorFlag.2 = 0
# enterprises.ucdavis.procTable.prEntry.prErrorFlag.3 = 0
# enterprises.ucdavis.procTable.prEntry.prErrMessage.1 = "No mountd process running."
# enterprises.ucdavis.procTable.prEntry.prErrMessage.2 = ""
# enterprises.ucdavis.procTable.prEntry.prErrMessage.3 = ""
# enterprises.ucdavis.procTable.prEntry.prErrFix.1 = 0
# enterprises.ucdavis.procTable.prEntry.prErrFix.2 = 0
# enterprises.ucdavis.procTable.prEntry.prErrFix.3 = 0
#
#  Note that the errorFlag for mountd is set to 1 because one is not
#  running (in this case an rpc.mountd is, but thats not good enough),
#  and the ErrMessage tells you what's wrong.  The configuration
#  imposed in the snmpd.conf file is also shown.
#
#  Special Case:  When the min and max numbers are both 0, it assumes
#  you want a max of infinity and a min of 1.
#


# -----------------------------------------------------------------------------


###############################################################################
# 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. The name must be unique for each exec statement.
#  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:
#
# #!/bin/sh
# echo hello world
# echo hi there
# exit 35
#
# Note:  this has been specifically commented out to prevent
# accidental security holes due to someone else on your system writing
# a /tmp/shtest before you do.  Uncomment to use it.
#
#exec shelltest /bin/sh /tmp/shtest

# Then,
# % snmpwalk -v 1 localhost -c public .1.3.6.1.4.1.2021.8
# enterprises.ucdavis.extTable.extEntry.extIndex.1 = 1
# enterprises.ucdavis.extTable.extEntry.extIndex.2 = 2
# enterprises.ucdavis.extTable.extEntry.extNames.1 = "echotest"
# enterprises.ucdavis.extTable.extEntry.extNames.2 = "shelltest"
# enterprises.ucdavis.extTable.extEntry.extCommand.1 = "/bin/echo hello world"
# enterprises.ucdavis.extTable.extEntry.extCommand.2 = "/bin/sh /tmp/shtest"
# enterprises.ucdavis.extTable.extEntry.extResult.1 = 0
# enterprises.ucdavis.extTable.extEntry.extResult.2 = 35
# enterprises.ucdavis.extTable.extEntry.extOutput.1 = "hello world."
# enterprises.ucdavis.extTable.extEntry.extOutput.2 = "hello world."
# enterprises.ucdavis.extTable.extEntry.extErrFix.1 = 0
# enterprises.ucdavis.extTable.extEntry.extErrFix.2 = 0

# Note that the second line of the /tmp/shtest shell script is cut
# off.  Also note that the exit status of 35 was returned.

# -----------------------------------------------------------------------------


###############################################################################
# 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

# % snmpwalk -v 1 localhost -c public .1.3.6.1.4.1.2021.9
# enterprises.ucdavis.diskTable.dskEntry.diskIndex.1 = 0
# enterprises.ucdavis.diskTable.dskEntry.diskPath.1 = "/" Hex: 2F
# enterprises.ucdavis.diskTable.dskEntry.diskDevice.1 = "/dev/dsk/c201d6s0"
# enterprises.ucdavis.diskTable.dskEntry.diskMinimum.1 = 10000
# enterprises.ucdavis.diskTable.dskEntry.diskTotal.1 = 837130
# enterprises.ucdavis.diskTable.dskEntry.diskAvail.1 = 316325
# enterprises.ucdavis.diskTable.dskEntry.diskUsed.1 = 437092
# enterprises.ucdavis.diskTable.dskEntry.diskPercent.1 = 58
# enterprises.ucdavis.diskTable.dskEntry.diskErrorFlag.1 = 0
# enterprises.ucdavis.diskTable.dskEntry.diskErrorMsg.1 = ""

# -----------------------------------------------------------------------------


###############################################################################
# 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

# % snmpwalk -v 1 localhost -c public .1.3.6.1.4.1.2021.10
# enterprises.ucdavis.loadTable.laEntry.loadaveIndex.1 = 1
# enterprises.ucdavis.loadTable.laEntry.loadaveIndex.2 = 2
# enterprises.ucdavis.loadTable.laEntry.loadaveIndex.3 = 3
# enterprises.ucdavis.loadTable.laEntry.loadaveNames.1 = "Load-1"
# enterprises.ucdavis.loadTable.laEntry.loadaveNames.2 = "Load-5"
# enterprises.ucdavis.loadTable.laEntry.loadaveNames.3 = "Load-15"
# enterprises.ucdavis.loadTable.laEntry.loadaveLoad.1 = "0.49" Hex: 30 2E 34 39
# enterprises.ucdavis.loadTable.laEntry.loadaveLoad.2 = "0.31" Hex: 30 2E 33 31
# enterprises.ucdavis.loadTable.laEntry.loadaveLoad.3 = "0.26" Hex: 30 2E 32 36
# enterprises.ucdavis.loadTable.laEntry.loadaveConfig.1 = "12.00"
# enterprises.ucdavis.loadTable.laEntry.loadaveConfig.2 = "14.00"
# enterprises.ucdavis.loadTable.laEntry.loadaveConfig.3 = "14.00"
# enterprises.ucdavis.loadTable.laEntry.loadaveErrorFlag.1 = 0
# enterprises.ucdavis.loadTable.laEntry.loadaveErrorFlag.2 = 0
# enterprises.ucdavis.loadTable.laEntry.loadaveErrorFlag.3 = 0
# enterprises.ucdavis.loadTable.laEntry.loadaveErrMessage.1 = ""
# enterprises.ucdavis.loadTable.laEntry.loadaveErrMessage.2 = ""
# enterprises.ucdavis.loadTable.laEntry.loadaveErrMessage.3 = ""

# -----------------------------------------------------------------------------


###############################################################################
# Extensible sections.
#

# This alleviates the multiple line output problem found in the
# previous executable mib by placing each mib in its own mib table:

# Run a shell script containing:
#
# #!/bin/sh
# echo hello world
# echo hi there
# exit 35
#
# Note:  this has been specifically commented out to prevent
# accidental security holes due to someone else on your system writing
# a /tmp/shtest before you do.  Uncomment to use it.
#
# exec .1.3.6.1.4.1.2021.50 shelltest /bin/sh /tmp/shtest

# % snmpwalk -v 1 localhost -c public .1.3.6.1.4.1.2021.50
# enterprises.ucdavis.50.1.1 = 1
# enterprises.ucdavis.50.2.1 = "shelltest"
# enterprises.ucdavis.50.3.1 = "/bin/sh /tmp/shtest"
# enterprises.ucdavis.50.100.1 = 35
# enterprises.ucdavis.50.101.1 = "hello world."
# enterprises.ucdavis.50.101.2 = "hi there."
# enterprises.ucdavis.50.102.1 = 0

# Now the Output has grown to two lines, and we can see the 'hi
# there.' output as the second line from our shell script.
#
# Note that you must alter the mib.txt file to be correct if you want
# the .50.* outputs above to change to reasonable text descriptions.

# Other ideas:
#
# exec .1.3.6.1.4.1.2021.51 ps /bin/ps
# exec .1.3.6.1.4.1.2021.52 top /usr/local/bin/top
# exec .1.3.6.1.4.1.2021.53 mailq /usr/bin/mailq

# -----------------------------------------------------------------------------


###############################################################################
# Pass through control.
#

# Usage:
#   pass MIBOID EXEC-COMMAND
#
# This will pass total control of the mib underneath the MIBOID
# portion of the mib to the EXEC-COMMAND.
#
# Note:  You'll have to change the path of the passtest script to your
# source directory or install it in the given location.
#
# Example:  (see the script for details)
#           (commented out here since it requires that you place the
#           script in the right location. (its not installed by default))

# pass .1.3.6.1.4.1.2021.255 /bin/sh /usr/local/local/passtest

# % snmpwalk -v 1 localhost -c public .1.3.6.1.4.1.2021.255
# enterprises.ucdavis.255.1 = "life the universe and everything"
# enterprises.ucdavis.255.2.1 = 42
# enterprises.ucdavis.255.2.2 = OID: 42.42.42
# enterprises.ucdavis.255.3 = Timeticks: (363136200) 42 days, 0:42:42
# enterprises.ucdavis.255.4 = IpAddress: 127.0.0.1
# enterprises.ucdavis.255.5 = 42
# enterprises.ucdavis.255.6 = Gauge: 42
#
# % snmpget -v 1 localhost public .1.3.6.1.4.1.2021.255.5
# enterprises.ucdavis.255.5 = 42
#
# % snmpset -v 1 localhost public .1.3.6.1.4.1.2021.255.1 s "New string"
# enterprises.ucdavis.255.1 = "New string"
#

# For specific usage information, see the man/snmpd.conf.5 manual page
# as well as the local/passtest script used in the above example.

###############################################################################
# Further Information
#
#  See the snmpd.conf manual page, and the output of "snmpd -H".

 配置 SNMP 簡單步驟以下:  

  •  1 )首選是定義一個共同體名 (community) ,這裏是 public ,及能夠訪問這個 public 的用戶名( sec name ),這裏是 notConfigUser 。 Public 至關於用戶 notConfigUser 的密碼   
    #                   sec.name             source             community
     com2sec      notConfigUser      default            public 
     com2sec      carlos                   default            carlos88(將carlos用戶的共同體設置爲carlos88)
  • 2 )定義一個組名( groupName )這裏是 notConfigGroup ,及組的安全級別,把 notConfigGroup 這個用戶加到這個組中。   

           #                 groupName        securityModel      securityName 
             group        notConfigGroup          v1               notConfigUser   
             group        notConfigGroup          v2c             notConfigUser 
             group           admin                       v2c             carlos(將carlos用戶添加到admin用戶組)

  •  3 )定義一個可操做的範圍 (view) 名:
    定義一個view視圖,設置視圖的可看範圍:
             項目名分類 |視圖名稱|  包含/排除   | 範圍

                #                  name                incl/excl         subtree         mask(optional)       
              view           systemview          included         .1.3.6.1.2.1.1         
              view                  all                  included        .1   80 (這裏是 all ,範圍是  .1 
  •  4 )定義 notConfigUser 這個組在 all 這個 view 範圍內可作的操做,這時定義了 notConfigUser 組的成員可對.1 這個範圍作只讀操做。    

          定義組能夠看到的視圖權限:
                # 項目分類名 | 組名|描述|sec.model  |  sec.level  |  prefix    |  可讀讀視圖  |  可寫的視圖  |  notif

                    access     mygroup        ""      any     noauth       exact     all      none      none

 

備註:

cacti 就是經過snmp獲取相關數據信息,採用RRDTool繪圖顯示。

...........

相關文章
相關標籤/搜索