IT运维流程库历史主题 · 只读
← 返回目录

Zabbix Agent类型支持所有的item key - (3)?

Key

描述
返回值
参数
说明

vfs.file.cksum[file]

计算文件校验和,使用UNIX cksum算法.
整数
file - 文件完整路径
示例:
⇒ vfs.file.cksum[/etc/passwd] 返回值示例: 1938292000 旧命名: cksum

vfs.file.contents[file,<encoding>]

获取文件内容
文本
file - 文件完整路径
encoding - 编码
返回一个空字符串,如果该文件为空或只包含LF/CR字符

示例: ⇒ vfs.file.contents[/etc/passwd] 文件大小不能超过64 Kbytes.

vfs.file.exists[file]

检查文件是否存在
0 - 不存在
1 - 存在一般文件或链接(软链接或硬链接)至一般文件
file - 文件完整路径
示例:
⇒ vfs.file.exists[/tmp/application.pid] 返回值取决于S_ISREG POSIX宏返回的内容

vfs.file.md5sum[file]

文件MD5校验和
字符串(文件的MD5哈希值)
file - 文件完整路径
示例:
⇒ vfs.file.md5sum[/usr/local/etc/zabbix_agentd.conf] 返回值示例: b5052decb577e0fffd622d6ddc017e82

vfs.file.regexp[file,regexp,<encoding>,<start line>,<end line>,<output>]

搜索文件中的字符串
包含匹配字符串的行或按特定的输出选项输出
file - 文件完整路径
regexp - 正则表达式
encoding - 编码
start line -搜索起始行号 (默认为首行).
end line - 搜索结束行号 (默认最后一行).
output - 可选的输出格式模板. \0 被转义输出为匹配的文本而 \N (其中 N=1…9)被转义输出为第N个匹配组 (当N超过匹配到的数量时为空字符串).
只返回第一个匹配到的行.
如果未匹配到则返回空字符串. 在agent上使用输出参数提取正文. start line, end line 和 output 参数在zabbix 2.2被支持. 示例: ⇒ vfs.file.regexp[/etc/passwd,zabbix] ⇒ vfs.file.regexp[/path/to/some/file,"([0-9]+)$",,3,5,\1] ⇒ vfs.file.regexp[/etc/passwd,^zabbix:.:([0-9]+),,,,\1] → getting the ID of user zabbix

vfs.file.regmatch[file,regexp,<encoding>,<start line>,<end line>]

搜索文件是否包含字符串
0 - 未找到
1 - 找到
file - 文件完整路径
regexp - 正则表达式
encoding - 编码
start line -搜索起始行号 (默认为首行).
end line - 搜索结束行号 (默认最后一行).
start line, end line 和 output 参数在zabbix 2.2被支持.
示例: ⇒ vfs.file.regmatch[/var/log/app.log,error]

vfs.file.size[file]

文件大小(字节bytes).
整数
file - 文件完整路径
zabbix用户对该文件需有可读权限
示例: ⇒ vfs.file.size[/var/log/syslog]

vfs.file.time[file,<mode>]

文件的时间戳.
整数 (Unix 时间戳)
file - 文件完整路径
mode - 可用值:
modify (默认) - 内容变动时间, access -访问时间, change - 修改时间
示例:
⇒ vfs.file.time[/etc/passwd,modify]

vfs.fs.discovery

列出已挂载文件系统,通常用于底层发现.
JSON对象
-
-

vfs.fs.inode[fs,<mode>]

Inode使用率
整数 - 数量
浮点 -百分比
fs - 文件系统
mode - 可用值:
total (默认), free, used, pfree (可用百分比), pused (使用百分比)
示例:
⇒ vfs.fs.inode[/,pfree] 旧命名:
vfs.fs.inode.free, vfs.fs.inode.pfree, vfs.fs.inode.total

vfs.fs.size[fs,<mode>]

磁盘空间大小或占总量的半分比
整数 - 字节
浮点 -百分比
fs - 文件系统
mode - 可用值:
total (默认), free, used, pfree (可用百分比), pused (使用百分比)
在已挂载卷的情况下,返回本地文件系统的磁盘空间

示例: ⇒ vfs.fs.size[/tmp,free] 使用free模式时不考虑一个文件系统的预留空间.
旧命名:
vfs.fs.free, vfs.fs.total, vfs.fs.used, vfs.fs.pfree, vfs.fs.pused

vm.memory.size[<mode>]

内存大小或占总量的百分比
整数 - 字节
浮点 -百分比e
mode - 可用值:
total (默认), active, anon, buffers, cached, exec, file, free, inactive, pinned,shared, wired, used, pused (使用百分比), available, pavailable (可用百分比)
接受三个类别的参数:
1) total - 内存总量;
2) 平台特定的内存类型:
active, anon, buffers, cached, exec, file, free, inactive, pinned,shared, wired;
3) 用户级别衡量的使用量和可用量:
used, pused, available,pavailable.
旧命名:
vm.memory.buffers, vm.memory.cached, vm.memory.free, vm.memory.shared,vm.memory.total

web.page.get[host,<path>,<port>]

获取网页内容
网页源码文本
host - 主机名/域名
path - 存放路径(默认为”/”)
port - 端口号 (默认为80)
返回空字符串表示失败.
示例: ⇒ web.page.get[ ,index.php,80]

web.page.perf[host,<path>,<port>]

完全页面加载时长(秒).
浮点
host - 主机名/域名
path - 存放路径(默认为”/”)
port - 端口号 (默认为80)
返回0表示失败.
示例: ⇒ web.page.perf[ ,index.php,80]

web.page.regexp[host,<path>,<port>,<regexp>,<length>,<output>]

网页中搜索字符串.
匹配的字符串或按特定的输出选项输出
host - 主机名/域名
path - 存放路径(默认为”/”)
port - 端口号 (默认为80)
regexp - 正则表达式
length - 返回最大字符串长度
output - 可选的输出格式模板. \0 被转义输出为匹配的文本而 \N (其中 N=1…9)被转义输出为第N个匹配组 (当N超过匹配到的数量时为空字符串).
返回空字符串表示未匹配到内容.
在agent上使用输出参数提取正文. 示例: ⇒ web.page.regexp[ ,index.php,80,OK,2]
原创:开源联盟