07008 发表于 2016-10-25 10:41:32

基于zabbix 内置key的应用

一、内置key说明:
    Zabbix 内置了很多丰富的key,使得咱们再添加linux os模板的时候,已经帮我们把key给定义好,这样我们就能够直接链接模板就可以使用了。
我们这边的话列举一些内置key,然后进行一些简单的说明:当我们内置key可以采集到数据的时候我们最好是不用去写自定义key再去采集的:二、详情可以查看官方文档:
https://www.zabbix.com/documentation/3.0/manual/config/items/itemtypes/zabbix_agent#supported_item_keys

三、内置监控项key列表:agent.hostname
返回被监控端名称(字符串)使用方式列举:后面使用的方式是一样的:# ./zabbix_get -s192.168.10.100 -k agent.hostnameZabbix server
agent.ping
    检测被监控端是否存活(1:运行中 其他:未运行)-使用函数 nodata()检测客户端是否正在运行

agent.version
    zabbix agent版本字符串

kernel.maxfiles
    系统支持最大的open files整数

kernel.maxproc
    系统支持最大的进程数量整数

log
    监控日志文件
    file - 文件详细路径
    regexp - 正则
    encoding - 编码
    maxlines - zabbix agent向server或者proxy发送最大的行数。
这个参数覆盖配置文件zabbxi_agentd.conf中的’MaxLinesPerSecond’
mode - 可选值:all (默认), skip (跳过处理老数据).mode参数从2.0版本开始支持
output - 可选项,输出格式模板.
示例: log loglog

logrt
    Monitoring of log file withlog rotation support.
    file_pattern - 文件绝对路径

net.if.discovery
列出网卡.通常用于低级别的discovery.JSON对象
net.if.in
    网卡入口流量整数.
    if - 网卡名称
    mode - 可用值: bytes - 字节数 (默认)
    packets - 包数量
    errors - 错误数量
    dropped - 丢包数量
示例keys: net.if.in net.if.in

net.if.out
   网卡出口流量(参数参见net.if.in)

net.if.total
    网卡进/出流量的总和(参数参见net.if.in)

net.tcp.listen
   检测端口是否开启0 –(not listen) 1 –in LISTEN stateport
   示例:net.tcp.listen

net.tcp.port[<ip>,port]
是否可以连接到指定的TCP端口0 – cannotconnect 1 – can connect
   ip - IP地址(默认是 127.0.0.1)
   port - 端口
范例: net.tcp.port[,80] 检测web服务器端口是否运行中

net.tcp.service
    检测服务是否开启,并且端口可用0 – 服务挂了 1 – 服务运行中
      service - 如下:ssh, ntp,ldap, smtp, ftp, http, pop, nntp,imap, tcp, https, telnet
      ip - IP地址 (默认127.0.0.1)
         port - 端口 (默认情况为标准端口号)
示例key: net.tcp.service

net.tcp.service.perf
    检测服务器性能0 – 服务挂了; seconds – 链接到服务器端口消耗的时间
    service - 如下:ssh, ntp,ldap, smtp, ftp, http, pop, nntp,imap, tcp, https, telnet
    ip - IP地址 (默认127.0.0.1)
    port - 端口 (默认情况为标准端口号)
    示例key:net.tcp.service.perf

proc.mem[<name>,<user>,<mode>,<cmdline>]
    用户进程消耗的内存内存使用量 (字节单位).
    name - 进程名 (默认值“all processes”)
    user - 用户名 (默认值“all users”)
   mode - 可选值: avg, max,min, sum (默认)
   cmdline - 命令行过滤(正则表达时)
示例keys: proc.mem[,root] – root的进程消耗了多少内存
    proc.mem– zabbix用户运行的zabbix_server使用了多少内存
   proc.mem[,oracle,max,oracleZABBIX]

proc.num[<name>,<user>,<state>,<cmdline>]
   某用户某些状态的进程的数量进程数量
   name - 进程名称 (默认“all processes”)
   user - 用户名 (默认“all users”)
   state - 可用值: all (默认), run,sleep, zomb
   cmdline - 命令行过滤(正则表达时)
   示例keys:proc.num[,mysql] – MySQL用户运行的进程数量
      proc.num – www-data运行了多少个apache2进程
   proc.num[,oracle,sleep,oracleZABBIX]
备注:Windows系统只支持name和user两个参数

system.boottime
    系统启动的时间戳整数.unix时间戳

system.cpu.intr
   设备中断整数

system.cpu.load[<cpu>,<mode>]
    CPU负载浮点数
    cpu - 可用值: all (默认), percpu (所有在线cpu的负载)
    mode - 可用值:avg1 (1分钟默认值), avg5(5分钟平均), avg15 (15分钟平均值)
范例key: system.cpu.load[,avg5]

system.cpu.num[<type>]
    CPU数量处理器个数type - 可用值: online (默认值), max范例: system.cpu.num

system.cpu.switches
    上下文交换交换次数老命名方式:system

system.cpu.util[<cpu>,<type>,<mode>]
    CPU利用率百分比
    cpu - cpu数量 (默认是所有cpu)
    type - 可用值: idle,nice, user (默认), system (windows系统默认值), iowait, interrupt,   softirq,steal
    mode - 可用值: avg1 (一分钟平均,默认值), avg5(5分钟平均, avg15 (15分钟平均值)
范例key: system.cpu.util

system.hostname[<type>]
   返回主机名字符串
   type (仅用于windows系统) – 可用值: netbios(默认)or host

system.hw.cpu[<cpu>,<info>]
    返回CPU信息字符/数字
    cpu - cpu数量或者all (默认)
    info - full (默认), curfreq,maxfreq, model 或者vendor
    例如: system.hw.cpuAuthenticAMD 从/proc/cpuinfo、/sys/devices/system/cpu//cpufreq/cpuinfo_max_freq获取信息. 如果指定了CPU数量和    curfreq或者maxfreq, 将会返回数值(Hz).

system.hw.devices[<type>]
列出PCI或者USB文本值type - pci (默认) or usb范例:system.hw.devices 00:00.0 Host bridge: Advanced Micro Devices RS780Host Bridge [..] 返回lspci或者lsusb(不带参数)
system.hw.macaddr[<interface>,<format>]
列出MAC地址字符串interface - all (默认) 或者正则表达式format - full (默认) 、short范例:system.hw.macaddr["eth0$",full] 00:11:22:33:44:55 列出指定接口mac地址 如果format指定为short,MAC地址相同的将会被忽略掉
system.localtime[<type>]
系统时间.数字或者字符串
system.run
   在制定的主机上运行命令文本
command - 命令mode - wait (默认值, 执行超时时间), nowait (不等待)最大可用返回512KB数据,包含空白数据。 命令输出数据必须是文本例如:system.run[“ls -l /”] – 列出/的文件和目录.Note: 启用这个方法, agent配置文件必须配置 EnableRemoteCommands=1选项
system.sw.arch
返回软件信息字符串范例:system.sw.arch
system.sw.os[<info>]
返回系统信息字符串info - full (default), short,name范例:system.sw.os Ubuntu 2.6.35-28.50-generic 2.6.35.11信息来自如下文件:/proc/version /proc/version_signature /etc/issue.net
system.sw.packages[<package>,<manager>,<format>]
已安装软件列表文本值package - all (默认)或者正则表达式manager - all (默认) or apackage managerformat - full (默认) ,short范例:system.sw.packages
system.swap.in[<device>,<type>]
交换分区IN(磁盘交换到内存)数字device - 交换分区设备 (默认all)type - 可选值: count(swapins数量), sectors(sectors swapped in), pages (pagesswapped in).示例key:system.swap.in[,pages]数据采集自: Linux2.4: /proc/swaps, /proc/partitions, /proc/stat            Linux 2.6: /proc/swaps, /proc/diskstats,/proc/vmstat
system.swap.out[<device>,<type>]
Swap out (f内存到磁盘) .数字device - swap设备 (默认all)type - count (number ofswapouts), sectors(sectors swapped out), pages (pages swapped out). 示例key:system.swap.out[,pages]数据采集自: Linux2.4: /proc/swaps, /proc/partitions, /proc/stat            Linux 2.6: /proc/swaps,/proc/diskstats, /proc/vmstat
system.swap.size[<device>,<type>]
交换分区大小字节或者百分比device - 交换分区 (默认值 all)type - free (free swap space, default), pfree (free swap space,in percent), pused (used swap space, in percent), total (total swap space),used (used swap space)示例 system.swap.size[,pfree] – 空闲swap百分比
system.uname
返回主机相信信息.字符串
system.uptime
系统运行时长(秒)多少秒使用s/uptime来获取
system.users.num
登陆用户数量多少用户agent使用who命令获取
vfs.dev.read[<device>,<type>,<mode>]
磁盘读取状态整数,浮点数(如果type为如下)device - 磁盘设备 (默认值“all”) type - 可选值:sectors,operations, bytes, sps, ops, bps(必须指定, 不同操作系统下不同).sps, ops, bps stand for:sectors, operations, bytes per second, respectivelymode - 可选值: avg1,avg5, avg15.备注: 只有type为sps, ops, bps的时候,第三个参数才被支持。不同操作系统的TYPE参数: FreeBSD – bps Linux – sps OpenBSD – operations Solaris – bytes示例key:vfs.dev.read[,operations]
vfs.dev.write[<device>,<type>,<mode>]
磁盘写入状态整数,device - 磁盘设备 (默认 all)type - sectors, operations,bytes, sps, ops, bpsmode - one of avg1(default),avg5 , avg15.example:vfs.dev.write[,operations] Old naming: io
vfs.file.cksum
计算文件校验 UNIXcksum.file - 文件完整路径
vfs.file.contents
获取文本内容若为空,只返回LF/CR characters.file - 文件完整路径例如:vfs.file.contents 文件不可以超过64KB.
vfs.file.exists
检测文件是否存在1 –存在 0 – 不存在    file - 文件完整路径

vfs.file.md5sum
文件MD5校验码文件MD5哈希值file - 完整路径
vfs.file.regexp
文件中搜索字符串包含字符串的行,或者为空file - 文件完整路径regexp - GNU正则表达式encoding - 编码start line - 从哪一行开始,默认第一行end line - 从哪一行结束,默认最后一行如:vfs.file.regexp    vfs.file.regexp+)$”,,3,5,\1]   vfs.file.regexp+),,,,\1]
vfs.file.regmatch
文件中搜索字符串0 –未找到 1 – 找到file - 文件完整路径regexp - GNU 正则表达式encoding - 编码start line - 哪行开始,默认第一行end line - 哪行结束,默认最后一行例如: vfs.file.regmatch
vfs.file.size
文件大小字节fzabbix必须有可读此文件的权限
vfs.file.time
文件时间信息Unix 时间戳.mode -modify (默认, 修改时间), access – 最后访问时间, change – 最后改变时间例如:vfs.file.time 备注:文件大小有限制
vfs.fs.discovery
列出挂载的文件系统 用于lld.JSON对象
vfs.fs.inode
inodes数量数字fs - 文件系统mode - total (默认), free,used, pfree (空闲百分比), pused (使用百分比)例如:vfs.fs.inode[/,pfree]
vfs.fs.size
磁盘空间,返回本地文件系统的使用量字节fs - 文件系统mode -total (默认), free, used, pfree (空闲百分比), pused (使用百分比).例如:vfs.fs.size
vm.memory.size[<mode>]
内存大小字节或百分比mode - total (默认), active,anon, buffers, cached, exec, file, free, inactive, pinned, shared, wired, used,pused, available监控项vm.memory.size[] 允许三种类型的参数:第一类:包含total - 总内存第二类: 系统指定内存类型:active, anon, buffers, cached,exec, file, free, inactive,pinned, shared, wired. 第三类:用户级别,一共使用了多少内存,还有多少内存可用: used, pused, available,pavailable.
web.page.get
获取网页内容网页源代码host - 主机名/域名path - 文件地址,默认/port - 端口,默认80返回空字符串表示失败. 例如: web.page.get[
web.page.perf
获取完全加载网页消耗的时长秒,返回0表示失败host - 主机名/域名path - html地址,默认是/port - 端口,默认80    #./zabbix_get -s 192.168.10.100 -k web.page.perf[www.baidu.com]   

web.page.regexp
在网页中搜索字符串失败则返回空字符 (不匹配).host - 主机名path - html文件路径 (默认值 /)port - 端口 (默认80)regexp - GNU正则表达式length - 返回的最大的字符串数量output - 输出格式模板可选项.


页: [1]
查看完整版本: 基于zabbix 内置key的应用