zabbix agent有主动被两种模式:主动模式是其向zabbix server发送数据,被动模式是由zabbix server到zabbix agent上取数据。同样在web界面上,有agent和agent(active)两种类型。其中agent类型就是指的被动模式,本篇也主机涉及的是被动模式下,系统预设的key值类型。

一、agent与kernel选项

1agent.hostname 返回被监控端名称(字符串)
2agent.ping     检测被监控端是否存活(1:运行中 其他:未运行)-使用函数 nodata()检测客户端是否正在运行
3agent.version  zabbix agent版本字符串
4kernel.maxfiles 系统支持最大的open files整数
5kernel.maxproc  系统支持最大的进程数量整数

二、log与logrt

log的用法如下:

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

log用于监控单个文件,如需要监控多个文件,可以使用logrt,如下:

1logrt[file_pattern,<regexp>,<encoding>,<maxlines>,<mode>,<output>]
2Monitoring of log file with log rotation support.
3file_pattern - 文件绝对路径

具体使用示例如下:

1log[/var/log/syslog]
2log[/var/log/syslog,error]
3log[/home/zabbix/logs/logfile,,,100]

三、net相关

net相并的key比较多,可以监控DNS、服务、端口、网卡流量等。

1、net.dns相关

net.dns可以检测DNS服务器,也可以用于检测DNS记录。

 1net.dns[<ip>,zone,<type>,<timeout>,<count>]
 2检测DNS服务是否开启0 – DNS挂了  1 - DNS运行中
 3ip - DNS服务器的ip地址(留空表示使用本地DNS, ignored onWindows)
 4zone - 需要测试的域名
 5type - 记录类型 (默认为 SOA),type可选值:  ANY, A, NS, CNAME, MB, MG, MR, PTR, MD, MF, MX, SOA, NULL, WKS (除了windows), HINFO, MINFO, TXT, SRV SRV
 6timeout (ignored on Windows) – 超时时间(默认1秒)
 7count (ignored on Windows) – 重试次数 (默认值2)
 8----------------------------------------------------------------
 9net.dns.record[<ip>,zone,<type>,<timeout>,<count>]
10执行一个DNS查询获取DNS查询数据.
11ip - DNS服务器的ip地址(留空表示使用本地DNS, ignored on Windows)
12zone - 需要测试的域名
13type - 记录类型 (默认SOA,可选值同net.dns)
14timeout (ignored on Windows) – 超时时间(默认1秒)
15count (ignored on Windows) – 重试次数 (默认值2)

示例如下:

1net.dns[8.8.8.8,zabbix.com,MX,2,1]
2net.dns.record[8.8.8.8,361way.com,MX,2,1]

2、net网卡流量相关

 1net.if.collisions[if]
 2Out-of-window collision.Number of collisions. Integer.if - 网卡
 3net.if.discovery
 4列出网卡.通常用于低级别的discovery.JSON对象
 5net.if.in[if,<mode>]
 6网卡入口流量整数.
 7if - 网卡名称
 8mode - 可用值: bytes - 字节数 (默认)
 9packets - 包数量
10errors - 错误数量
11dropped - 丢包数量
12示例keys: net.if.in[eth0,errors] net.if.in[eth0]
13net.if.out[if,<mode>]
14网卡出口流量(参数参见net.if.in)
15net.if.total[if,<mode>]
16网卡进/出流量的总和(参数参见net.if.in)

3、net端口与服务

 1net.tcp.listen[port]
 2检测端口是否开启0 – (not listen) 1 –  in LISTEN stateport
 3示例: net.tcp.listen[80]
 4net.tcp.port[<ip>,port]
 5是否可以连接到指定的TCP端口0 – cannot connect 1 – can connect
 6   ip - IP地址(默认是 127.0.0.1)
 7   port - 端口
 8范例: net.tcp.port[,80] 检测web服务器端口是否运行中
 9net.tcp.service[service,<ip>,<port>]
10检测服务是否开启,并且端口可用0 – 服务挂了 1 – 服务运行中
11    service - 如下:ssh, ntp, ldap, smtp, ftp, http, pop, nntp,imap, tcp, https, telnet
12    ip - IP地址 (默认127.0.0.1)
13    port - 端口 (默认情况为标准端口号)
14示例key: net.tcp.service[ftp,,45]
15net.tcp.service.perf[service,<ip>,<port>]
16检测服务器性能0 – 服务挂了; seconds – 链接到服务器端口消耗的时间
17service - 如下:ssh, ntp, ldap, smtp, ftp, http, pop, nntp,imap, tcp, https, telnet
18ip - IP地址 (默认127.0.0.1)
19port - 端口 (默认情况为标准端口号)
20示例key: net.tcp.service.perf[ssh]
21         net.udp.listen[port]

四、proc相关

 1proc.mem[<name>,<user>,<mode>,<cmdline>]
 2用户进程消耗的内存内存使用量 (字节单位).
 3name - 进程名 (默认值 “all processes”)
 4user - 用户名 (默认值“all users”)
 5mode - 可选值: avg, max, min, sum (默认)
 6cmdline - 命令行过滤(正则表达时)
 7示例keys: proc.mem[,root] – root的进程消耗了多少内存
 8    proc.mem[zabbix_server,zabbix] – zabbix用户运行的zabbix_server使用了多少内存
 9    proc.mem[,oracle,max,oracleZABBIX]
10proc.num[<name>,<user>,<state>,<cmdline>]
11某用户某些状态的进程的数量进程数量
12name - 进程名称 (默认“all processes”)
13user - 用户名 (默认 “all users”)
14state - 可用值: all (默认), run,sleep, zomb
15cmdline - 命令行过滤(正则表达时)
16示例keys: proc.num[,mysql] – MySQL用户运行的进程数量
17proc.num[apache2,www-data] – www-data运行了多少个apache2进程
18proc.num[,oracle,sleep,oracleZABBIX]
19备注:Windows系统只支持name和user两个参数

五、sensor传感器相关

1sensor[device,sensor,<mode>]
2读取硬件传感器
3device - 设备名称
4sensor - 传感器名称
5mode - 可选值:avg, max, min
6示例key: sensor[w83781d-i2c-0-2d,temp1]
7Prior to Zabbix 1.8.4, the sensor[temp1] format was used. On Linux 2.6+, 读取/sys/class/hwmon. On OpenBSD, 读取hw.sensors MIB.示例
8keys: sensor[cpu0,temp0] – CPU0的温度
9sensor[cpu[0-2]$,temp,avg] – cpu平均温度Zabbix 1.8.4开始支持OpenBSD

六、system相关

 1system.boottime
 2系统启动的时间戳整数.unix时间戳
 3system.cpu.intr
 4设备中断整数
 5system.cpu.load[<cpu>,<mode>]
 6CPU负载浮点数
 7cpu - 可用值: all (默认), percpu (所有在线cpu的负载)
 8mode - 可用值:avg1 (1分钟 默认值), avg5(5分钟平均), avg15 (15分钟平均值)
 9范例key: system.cpu.load[,avg5]
10system.cpu.num[<type>]
11CPU数量处理器个数type - 可用值: online (默认值), max范例: system.cpu.num
12system.cpu.switches
13上下文交换交换次数老命名方式: system[switches]
14system.cpu.util[<cpu>,<type>,<mode>]
15CPU利用率百分比
16cpu - cpu数量 (默认是所有cpu)
17type - 可用值: idle, nice, user (默认), system (windows系统默认值), iowait, interrupt, softirq,steal
18mode - 可用值: avg1 (一分钟平均,默认值), avg5(5分钟平均, avg15 (15分钟平均值)
19范例key: system.cpu.util[0,user,avg5]
20system.hostname[<type>]
21返回主机名字符串
22type (仅用于windows系统) – 可用值: netbios(默认) or host
23system.hw.chassis[<info>]
24返回机架信息字符串
25info - full (默认), model, serial, type 或vendor
26例如: system.hw.chassis
27Hewlett-Packard HP Pro 3010 Small Form Factor PC CZXXXXXXXX Desktop]
28备注:要root权限,因为这些信息是从内存中读取的。
29system.hw.cpu[<cpu>,<info>]
30返回CPU信息字符/数字
31cpu - cpu数量或者all (默认)
32info - full (默认), curfreq, maxfreq, model 或者vendor
33例如: system.hw.cpu[0,vendor] AuthenticAMD 从/proc/cpuinfo、/sys/devices/system/cpu/[cpunum]/cpufreq/cpuinfo_max_freq获取信息. 如果指定了CPU数量和 curfreq或者maxfreq, 将会返回数值(Hz).
34system.hw.devices[<type>]
35列出PCI或者USB文本值
36type - pci (默认) or usb
37范例: system.hw.devices[pci] 00:00.0 Host bridge: Advanced Micro Devices [AMD] RS780 Host Bridge [..] 返回lspci或者lsusb (不带参数)
38system.hw.macaddr[<interface>,<format>]
39列出MAC地址字符串
40interface - all (默认) 或者正则表达式
41format - full (默认) 、short
42范例: system.hw.macaddr["eth0$",full] [eth0] 00:11:22:33:44:55 列出指定接口mac地址 如果format指定为short,MAC地址相同的将会被忽略掉
43system.localtime[<type>]
44系统时间.数字或者字符串
45system.run[command,<mode>]
46在制定的主机上运行命令文本
47command - 命令
48mode - wait (默认值, 执行超时时间), nowait (不等待)最大可用返回512KB数据,包含空白数据。 命令输出数据必须是文本
49例如: system.run[ls -l /] – 列出/的文件和目录.
50Note: 启用这个方法, agent配置文件必须配置 EnableRemoteCommands=1选项
51system.stat[resource,<type>]
52虚拟内存状态数字ent
53system.sw.arch
54返回软件信息字符串
55范例: system.sw.arch i686
56system.sw.os[<info>]
57返回系统信息字符串
58info - full (default), short ,name
59范例: system.sw.os[short] Ubuntu 2.6.35-28.50-generic 2.6.35.11
60信息来自如下文件:
61/proc/version [short]
62/proc/version_signature [name]
63/etc/issue.net
64system.sw.packages[<package>,<manager>,<format>]
65已安装软件列表文本值
66package - all (默认)或者正则表达式
67manager - all (默认) or a package manager
68format - full (默认) ,short
69范例: system.sw.packages[mini,dpkg,short]
70system.swap.in[<device>,<type>]
71交换分区IN(磁盘交换到内存)数字
72device - 交换分区设备 (默认all)
73type - 可选值: count (swapins数量), sectors(sectors swapped in), pages (pages swapped in).
74示例key: system.swap.in[,pages]
75数据采集自: Linux 2.4: /proc/swaps, /proc/partitions, /proc/stat
76            Linux 2.6: /proc/swaps, /proc/diskstats, /proc/vmstat
77system.swap.out[<device>,<type>]
78Swap out (f内存到磁盘) .数字
79device - swap设备 (默认all)
80type - count (number of swapouts), sectors(sectors swapped out), pages (pages swapped out). 示
81例key: system.swap.out[,pages]
82数据采集自: Linux 2.4: /proc/swaps, /proc/partitions, /proc/stat
83            Linux 2.6: /proc/swaps, /proc/diskstats, /proc/vmstat
84system.swap.size[<device>,<type>]
85交换分区大小字节或者百分比
86device - 交换分区 (默认值 all)
87type - 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)
88示例 system.swap.size[,pfree] – 空闲swap百分比
89system.uname
90返回主机相信信息.字符串
91system.uptime
92系统运行时长()多少秒使用s/uptime来获取
93system.users.num
94登陆用户数量多少用户agent使用who命令获取

七、vfs相关

 1vfs.dev.read[<device>,<type>,<mode>]
 2磁盘读取状态整数,浮点数(如果type为如下)
 3device - 磁盘设备 (默认值 “all”)
 4type - 可选值:sectors, operations, bytes, sps, ops, bps(必须指定, 不同操作系统下不同).  sps, ops, bps stand for: sectors, operations, bytes per second, respectively
 5mode - 可选值: avg1, avg5, avg15.
 6备注: 只有type为sps, ops, bps的时候,第三个参数才被支持。
 7不同操作系统的TYPE参数: FreeBSD – bps Linux – sps OpenBSD – operations Solaris – bytes
 8示例key: vfs.dev.read[,operations]
 9vfs.dev.write[<device>,<type>,<mode>]
10磁盘写入状态整数,
11device - 磁盘设备 (默认 all)
12type - sectors, operations, bytes, sps, ops, bps
13mode - one of avg1 (default),avg5 , avg15.
14example: vfs.dev.write[,operations] Old naming: io
15vfs.file.cksum[file]
16计算文件校验 UNIX cksum.
17file - 文件完整路径
18vfs.file.contents[file,<encoding>]
19获取文本内容若为空,只返回 LF/CR characters.
20file - 文件完整路径
21例如: vfs.file.contents[/etc/passwd] 文件不可以超过64KB.
22vfs.file.exists[file]
23检测文件是否存在1 – 存在 0 – 不存在
24    file - 文件完整路径
25vfs.file.md5sum[file]
26文件MD5校验码文件MD5哈希值
27file - 完整路径
28vfs.file.regexp[file,regexp,<encoding>,<start line>,<end line>,<output>]
29文件中搜索字符串包含字符串的行,或者为空
30file - 文件完整路径
31regexp - GNU正则表达式
32encoding - 编码
33start line - 从哪一行开始,默认第一行
34end line - 从哪一行结束,默认最后一行
35如: vfs.file.regexp[/etc/passwd,zabbix]
36    vfs.file.regexp[/path/to/some/file,”([0-9]+)$”,,3,5,\1]
37    vfs.file.regexp[/etc/passwd,^zabbix:.:([0-9]+),,,,\1]
38vfs.file.regmatch[file,regexp,<encoding>,<start line>,<end line>]
39文件中搜索字符串0 – 未找到 1 – 找到
40file - 文件完整路径
41regexp - GNU 正则表达式
42encoding - 编码
43start line - 哪行开始,默认第一行
44end line - 哪行结束,默认最后一行
45例如: vfs.file.regmatch[/var/log/app.log,error]
46vfs.file.size[file]
47文件大小字节fzabbix必须有可读此文件的权限
48vfs.file.time[file,<mode>]
49文件时间信息Unix 时间戳.
50mode -  modify (默认, 修改时间), access – 最后访问时间, change – 最后改变时间
51例如: vfs.file.time[/etc/passwd,modify] 备注:文件大小有限制
52vfs.fs.discovery
53列出挂载的文件系统 用于lld.JSON对象
54vfs.fs.inode[fs,<mode>]
55inodes数量数字
56fs - 文件系统
57mode - total (默认), free, used, pfree (空闲百分比), pused (使用百分比)
58例如: vfs.fs.inode[/,pfree]
59vfs.fs.size[fs,<mode>]
60磁盘空间,返回本地文件系统的使用量字节
61fs - 文件系统
62mode -  total (默认), free, used, pfree (空闲百分比), pused (使用百分比).
63例如: vfs.fs.size[/tmp,free]

八、 web相关

 1web.page.get[host,<path>,<port>]
 2获取网页内容网页源代码
 3host - 主机名/域名
 4path - 文件地址,默认/
 5port - 端口,默认80返回空字符串表示失败.
 6web.page.perf[host,<path>,<port>]
 7获取完全加载网页消耗的时长秒,返回0表示失败
 8host - 主机名/域名
 9path - html地址,默认是/
10port - 端口,默认80
11web.page.regexp[host,<path>,<port>,<regexp>,<length>,<output>]
12在网页中搜索字符串  失败则返回空字符 (不匹配).
13host - 主机名
14path - html文件路径 (默认值 /)
15port - 端口 (默认80)
16regexp - GNU正则表达式
17length - 返回的最大的字符串数量
18output - 输出格式模板可选项.

九、vm内存相关

1vm.memory.size[<mode>]
2内存大小字节或百分比
3mode - total (默认), active, anon, buffers, cached, exec, file, free, inactive, pinned, shared, wired, used, pused, available
4监控项vm.memory.size[] 允许三种类型的参数:
5第一类:包含total - 总内存
6第二类: 系统指定内存类型:active, anon, buffers, cached, exec, file, free, inactive,pinned, shared, wired. 第三类:用户级别,一共使用了多少内存,还有多少内存可用: used, pused, available,pavailable.

注:以上涉及键值没必要刻意的去记,在zabbix agent上通过执行zabbix_agentd -p就可以打印出其所支持的所有key值