網絡發現(Network Discovery)
**網絡發現是zabbix最具有特色的功能之一,它能根據用戶實現定義好的規則自動添加監控主機和服務等
-->speed up Zabbix deployment
-->simplify administration
-->use Zabbix in rapidly changing environments without excessive administration
**Zabbix的網絡發現功能可基於如下信息進行:
-->IP ranges
-->Availability of external services (FTP,SSH,WEB,POP3,IMAP,TCP,etc)
-->Information received from Zabbix agent
-->Information received from SNMP agent
網絡發現:過程階段
**網絡發現通常包含兩個階段: discovery和actions
-->Discovery
*-->Zabbix periodically scans the IP range defined in network discovery reles
*--> Zabbix定期掃描網絡發現規則定義的IP地址範圍
*-->The frequency of the check is configurable for each rule individually
*每個單獨的規則都可配置檢查的頻率
*-->Each rule has a set of service chekcks defined to be performed for the IP range
*-->每個規則都有一套服務chekcks定義爲IP範圍內進行
*-->Every check of a service and a host (IP) performed by the network discovery module generates a discovery event.
*-->每一個服務的每一個檢查和由網絡發現模塊執行的主機(IP)生成一個發現事件。
Discovery中的事件:
Service Up
Service Down
Host Up
Host Down
Service Discovered
Service Lost
Host Discovered
Host Lost
Action,網絡發現中的事件可以觸發action,從而自動執行指定的操作,如:
Sending notifications
Adding/removing hosts
Enabling/disabling hosts
Adding hosts to group
Removing hosts from a group
Linking hosts to/unlinking from a template
Executing remote scripts
-->這些事件的配置還可以基於設備的類型、IP、狀態、上線/離線進行配置。
網絡發現:接口添加
網絡發現中添加主機時會自動創建interface
the services detected
-->例如:如果基於SNMP檢測成功,則會創建SNMP接口
如果某服務同時響應給了agent和SNMP,則兩種接口都會創建。
如果同一種發現機制(如agent)返回了非唯一數據,則第一個接口被識別爲默認,其他的爲額外接口。
不同的主機如果返回相同的數據,則第一個主機將被添加,餘下的主機會被當做第一個主機的額外接口。
自動註冊
Zabbix支持active agent的自動註冊(auto-resisitration)功能,通常用於此前故障的agent重新上線的場景,也可基於active agent的自動註冊機制添加被動檢測,這會通過active agent註冊時提供的"ListenIP"和"ListenPort"進行,Server端在收到自動註冊請求後以接收到的IP和Port爲接口屬性。
實現過程如下:
(1)創建模板
(2)創建模板item
(3)創建模板觸發器trigger
(4)創建模板視圖Graph
(5)創建發現規則
(6)創建發現actions事件實現添加主機
(7)定義一個用戶和組用於接受通知及消息
在服務器上創建tom用戶:
# useradd tom
(8)定義移除action,只要探測失敗,就移除主機:
(9)網絡發現:配置active agent自動註冊
*-->Configuration-->Actions-->Event source(Autoregistration)-->Create action
此外,還需要配置agent的工作屬性,並重啓agent
-->zabbix-agentd.conf
ServerActive=172.16.100.2
#指向zabbix server
配置如下:
(10)配置被監控端如下配置:
# cat /etc/zabbix/zabbix_agentd.conf | grep -E '(ServerActive|Server|usage)' Server=172.16.100.2 ServerActive=172.16.100.2 UserParameter=memory.usage[*],/bin/cat /proc/meminfo | awk '/^$1:/{print $$2}'
配置web頁面監控應用
Zabbix還可以進行web站點監控的可用性檢測
創建web監控需要先定義一個web方案(scenarios)
-->web方案包括一個或多個HTTP請求或"步驟(step)"
-->步驟(step)的執行過程安裝預先定義的順序進行執行
通過web監控可實時獲取如下消息
-->整個web方案中所有的步驟的平均下載速度
-->失敗的步驟號
-->失敗的報錯信息
在web方案的具體步驟中,可以按需要使用如下消息
-->該步驟的下載速度
-->迴應時間
-->迴應狀態碼
Zabbix可以檢測獲取到的HTML頁面中是否包含預設的字符串,也可以實現登錄和頁面點擊。
創建web監控方案
**創建web方案的前提需要創建一個適用的應用(application)
可以在"Hosts"或"Templates"上創建應用
如果在"Templates"上創建應用,則需要將此"Templates"鏈接至要監控的其web的主機上方能使用此"application"
下面創建web監控
首先,在172.16.100.7主機中定義application
Scenario items
方案創建完成後,zabbix將會自動在鏈接的Application中添加如下監控項
Name | Key | Type | Type of information | Status |
Download speed for scenario "Web Monitoring". | web.test.in[Web Monitoring,,bps] | Web monitoring | Numeric (float) | Enabled |
Download speed for step "test" of scenario "Web Monitoring". | web.test.in[Web Monitoring,test,bps] | Web monitoring | Numeric (float) | Enabled |
Download speed for step "Home" of scenario "Web Monitoring". | web.test.in[Web Monitoring,Home,bps] | Web monitoring | Numeric (float) | Enabled |
Failed step of scenario "Web Monitoring". | web.test.fail[Web Monitoring] | Web monitoring | Numeric (unsigned) | Enabled |
Last error message of scenario "Web Monitoring". | web.test.error[Web Monitoring] | Web monitoring | Character | Enabled |
在創建觸發器和告警時可以利用這些監控項,例如:
-->{host:web.test.fail[www.samlee.com].last(0)}#0
-->{host:web:test.in[www.samlee.com,,bps].last(0)}<10000
最後查看數據示意圖如下:
可以看到頁面的響應速度和下載速度
創建web監控的trigger,表達式爲主頁最後一次的響應碼不等於200就觸發事件:
以上爲Zabbixzabbix發現_自動註冊及web頁面狀態監控所有內容。