我們大概瞭解了怎麼對臺主機進行監控,主要步驟設計到添加主機,並且爲主機添加監控項,這裏主要爲item,然後在item的基礎上對item進行繪圖並且通過screen的方式把不同的監控圖像彙總到一張screen上。通過對quick章節我們認識到item監控項在zabbix中是非常重要的,而item的監控是通過key來定義的,key又分爲系統預定義好的key和自定義的key組成,這一節,我們通過對zabbix預定義的內存key來了解一下key到底是怎麼組成和怎麼使用的。
Key | 參數 | 類型 | 單位 | 舉例 |
vm.memory.size[<mode>] | total (default), active,anon, buffers, cached, exec, file, free, inactive pinned, shared, wired, used, pused, available, pavailable | Numeric (unsigned) Decimal | B | vm.memory.size[total] vm.memory.size[total] vm.memory.size[total] vm.memory.size[total] |
system.swap.in[<device>,<type>] | Type:count,sectorspages | Numeric (unsigned) Decimal | B | system.swap.in[,pages] |
system.swap.out[<device>,<type>] | Type:count,sectorspages | Numeric (unsigned) Decimal | B | system.swap.out[,pages] |
選擇要導入的模版,然後雙擊copy按鈕即可,同樣方法可以把graph數據也導入模版裏。
3.6.3 模版的使用
創建主機時選擇模版按鈕後點擊add按鈕選擇關聯的模版即可,最後選擇save按鈕進行保存。
3.6.4.1模版的導出
選擇ConfigureàTemplates選擇要導出的模版後,選擇下方的Export selectd後雙擊go按鈕,導出模版到想要保存的位置。
3.6.4.2模版的導入
選擇ConfigureàTemplates-import後雙擊瀏覽按鈕後選擇要導入的模版,已經導入的模版類型後雙擊,Import即可。
本文出自 “虛心求教” 博客,請務必保留此出處http://nanwangting.blog.51cto.com/608135/1118799
上圖爲所有與內存相關的key已經與之相對應的參數,單位,例子等相關信息,下面我將通過一個例子來展示怎麼添加一個合適的內存key並且填寫與之對應的單位,返回值等信息在zabbix添加item項時。
例1:監控主機的總內存,剩餘內存。
通過圖表和截圖我們可以很方便的看出來相關的對應關係。截圖中的key:vm.memory.size[total] 中的對應圖表中的key vm.memory.size[<mode>]而中括號中的mode這對應圖表中的參數,這裏爲total,當然了大家也可以根據需要填寫,比如監控內存以及使用的大小,這可以寫成vm.memory.size[used] 。截圖中的單位對應圖表中的單位B,等等對應關係很容易看出來,這裏就不多說了。然後大家按照quick章節中的實例爲item繪圖然後加入到screen裏就可以了。
1.1Zabbix對linux網卡的監控
Linux對網卡的監控的基本思路和監控其他linux項目沒什麼區別第一步添加linux主機,第二步爲linux主機添加網卡相對應的item,任何在item的基礎上繪製graph然後把graph集中添加到一張screen上方便集中展示。下面的圖表爲監控網卡流量用到的相關key。
Key | 參數 | 類型 | 單位 | 舉例 |
net.if.in[if,<mode>] | Bytes,packetserrors,dropped | Numeric (unsigned) Decimal | Bps | net.if.in[eth0,errors] net.if.in[eth0] |
net.if.out[if,<mode>] | Bytes,packetserrors,dropped | Numeric (unsigned) Decimal | Bps | net.if.out[eth0,errors] net.if.out[eth0] |
net.if.total[if,<mode>] | Bytes,packetserrors,dropped | Numeric (unsigned) Decimal | Bps | net.if.total[eth0,errors] net.if.total[eth0] |
這裏需要主要添加item的時候數據存儲類型store value要選擇爲Delta(speed per second)
例1:對linux主機eth0網卡進口流量的監控item
例2:對linux主機eth0網卡出口流量的監控item
爲linux主機eth0網卡的進出網卡繪圖。
1.1Zabbix對cpu的監控
相關key
Key | 參數 | 類型 | 單位 | 舉例 |
system.cpu.load[<cpu>,<mode>] | Cpu:all ,percpu Avg1,avg5,avg15 | Numeric (float) | 無 | system.cpu.load[,avg5] |
system.cpu.num[<type>] | Online,max | Numeric (unsigned) Decimal | 無 | system.cpu.num |
system.cpu.switches | 無 | Numeric (float) | 無 | system.cpu.switches |
system.cpu.util[<cpu>,<type>,<mode>] | Cpu:all,number Type:idle, nice, user,iowait,interrupt, softirq, steal Mode:avg1,av5,avg15 | Numeric (float) | % | system.cpu.util[0,user,avg5] |
例1:linux主機cpu的負載item
linux主機cpu利用率繪圖
1.1Zabbix對磁盤的監控
首先我們添加主機,並且爲主機添加一個item,然後在item上填寫相關內容,其中key安裝下面的格式來填寫。
Key | 參數 | 類型 | 單位 | 舉例 |
vfs.fs.size[fs,<mode>] | fs:文件系統 mode:total(默認) free,used,pfree,pused | Numeric (unsigned) Decimal | B % | vfs.fs.size[/tmp,free] |
vfs.file.size[file] | 文件路徑 | Numeric (unsigned) Decimal | B | vfs.file.size[/var/log/syslog] |
下圖爲監控/分區空間剩餘大小的item截圖。
爲item繪圖
效果圖
1.1把監控的圖像放入到一張screen中
創建screen:configureàscreenàcreate screen,這裏創建了一張名爲test,2行2列的screen。
創建後入下圖所示:
選擇change後添加想要加入的graph,下圖爲添加內存圖形(3.1中創建)到screen中,選中後雙擊保存按鈕就行保存
依次雙擊change按鈕添加上節 創建的4張graph圖到名test的 screen中。
1.1模板的創建
3.6.1創建模版
選擇ConfigureàTemplatesàCreate template
輸入創建模板的名字和所在的組,然後保存即可。這時大家會發現多了一個名爲test_linux但是裏面的數據位空的
3.6.2向模版裏導入數據
選擇往模版裏導入的主機的item,然後選擇copy select to後雙擊go按鈕。如下圖所示