zoukankan      html  css  js  c++  java
  • zabbix入门到精通之Zabbix对linux主机的监控

    我们大概了解了怎么对台主机进行监控,主要步骤设计到添加主机,并且为主机添加监控项,这里主要为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,sectors pages
    Numeric (unsigned)
    Decimal
    B
    system.swap.in[,pages]
    system.swap.out[<device>,<type>]
    Type:count,sectors pages
    Numeric (unsigned)
    Decimal
    B
    system.swap.out[,pages]
    上图为所有与内存相关的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.1 Zabbix对linux网卡的监控
    Linux对网卡的监控的基本思路和监控其他linux项目没什么区别第一步添加linux主机,第二步为linux主机添加网卡相对应的item,任何在item的基础上绘制graph然后把graph集中添加到一张screen上方便集中展示。下面的图表为监控网卡流量用到的相关key。
    Key
    参数
    类型
    单位
    举例
    net.if.in[if,<mode>]
    Bytes,packets errors,dropped
    Numeric (unsigned)
    Decimal
    Bps
    net.if.in[eth0,errors]             net.if.in[eth0]
    net.if.out[if,<mode>]
    Bytes,packets errors,dropped
    Numeric (unsigned)
    Decimal
    Bps
    net.if.out[eth0,errors]             net.if.out[eth0]
    net.if.total[if,<mode>]
    Bytes,packets errors,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.1 Zabbix对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.1 Zabbix对磁盘的监控
    首先我们添加主机,并且为主机添加一个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按钮。如下图所示

                                                                                                                                                                          

    选择要导入的模版,然后双击copy按钮即可,同样方法可以把graph数据也导入模版里。
    3.6.3 模版的使用
    创建主机时选择模版按钮后点击add按钮选择关联的模版即可,最后选择save按钮进行保存。
    3.6.4模版的导入导出
    3.6.4.1模版的导出
    选择ConfigureàTemplates选择要导出的模版后,选择下方的Export selectd后双击go按钮,导出模版到想要保存的位置。
    3.6.4.2模版的导入
    选择ConfigureàTemplates-import后双击浏览按钮后选择要导入的模版,已经导入的模版类型后双击,Import即可。

     http://nanwangting.blog.51cto.com/608135/1118799

  • 相关阅读:
    批量重命令文件名称的几种方式
    SecureCRT常用快捷键
    ipv4地址从最后一位按步长递增
    win32
    GDI根据位图和透明度创建蒙版
    git bash的一些使用
    win32
    win32
    win32
    QT
  • 原文地址:https://www.cnblogs.com/chen110xi/p/5693807.html
Copyright © 2011-2022 走看看