CentOS6u9 Zabbix2.2安装配置监控告警(四)Template OS Linux模板小结

简单说明:

本博文是对zabbix_get命令-k参数可用的检测关键字的简单总结归纳
这些关键字通过查看Template OS Linux模板获得
CentOS6u9 Zabbix2.2安装配置监控告警(四)Template OS Linux模板小结_第1张图片
CentOS6u9 Zabbix2.2安装配置监控告警(四)Template OS Linux模板小结_第2张图片

测试命令说明:

# Server端信息
SERVER_IP=192.168.1.10
SERVER_PORT=10051
# Agent端信息
AGENT_IP=192.168.1.11
AGENT_PORT=10050

zabbix_get
# -s 指定agent的IP
# -p 指定agent的PORT
# -I 指定zabbix服务端IP
# -k 指定检测关键字

系统时间相关的测试关键字:

# Template OS Linux: Host boot time
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.boottime
# Template OS Linux: Host local time
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.localtime
# 这两个测试返回UNIX时间戳,可以使用date命令转换
date +%F_%T -d @$(zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.localtime)

# Template OS Linux: System uptime
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.uptime
# 监控系统启动了多少秒,如果该数据不刷新,则激活触发器:
# Template OS Linux:{HOST.NAME} has just been restarted

内核配置相关的测试关键字:

# Template OS Linux: Maximum number of opened files
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k kernel.maxfiles
# 监控当前系统配置的最大可以打开的文件数,如果小于1024则激活触发器:
# Template OS Linux:Configured max number of opened files is too low on {HOST.NAME}

# Template OS Linux: Maximum number of processes
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k kernel.maxproc
# 监控当前系统配置的最大可以打开的进程数量,如果小于256则激活触发器:
# Template OS Linux:Configured max number of processes is too low on {HOST.NAME}

# Template OS Linux: Number of logged in users
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.users.num
# 监控当前登陆系统的用户数量

# Template OS Linux: Number of processes
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k proc.num[]
# 监控当前系统打开的进程数量,如果5分钟内平均进程数量大于300则激活触发器:
# Template OS Linux:Too many processes on {HOST.NAME}

CPU和负载相关的测试关键字:

# Template OS Linux: CPU steal time
# Template OS Linux: CPU system time
# Template OS Linux: CPU softirq time
# Template OS Linux: CPU user time
# Template OS Linux: CPU nice time
# Template OS Linux: CPU interrupt time
# Template OS Linux: CPU idle time
# Template OS Linux: CPU iowait time
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.cpu.util[,steal]
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.cpu.util[,system]
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.cpu.util[,softirq]
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.cpu.util[,user]
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.cpu.util[,nice]
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.cpu.util[,interrupt]
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.cpu.util[,idle]
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.cpu.util[,iowait]

iostat |grep avg-cpu -A 1
# 监控CPU的各个状态,和命令iostat的输出部分应该是相同的,
# 如idle空闲百分比,system系统进程占用百分比,user用户进程占用百分比,
# 监控项iowait即cpu的wait百分比,该值过高则说明进程大量等待IO,如果大于20%,则激活触发器:
# Template OS Linux:Disk I/O is overloaded on {HOST.NAME}

# Template OS Linux: Processor load (1 min average per core)
# Template OS Linux: Processor load (5 min average per core)
# Template OS Linux: Processor load (15 min average per core)
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.cpu.load[percpu,avg1]
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.cpu.load[percpu,avg5]
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.cpu.load[percpu,avg15]
# 监控系统1分钟/5分钟/15分钟内的系统负载,
# 当1分钟内的负载监控项显示,5分钟内的平均数据大于5时,激活触发器:
# Template OS Linux:Processor load is too high on {HOST.NAME}

# Template OS Linux: Context switches per second
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.cpu.switches
# 总的上下文交换次数,无关联触发器

# Template OS Linux: Interrupts per second
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.cpu.intr
# 监控产生的进程中断,应该是系统启动后的总数

内存相关的测试关键字:

# Template OS Linux: Total memory
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k vm.memory.size[total]
# 监控物理内存总大小

# Template OS Linux: Available memory
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k vm.memory.size[available]
free -b|grep -e '-/+ buffers/cache:'|awk '{print $3}'
# 返回free命令下的物理内存空闲,单位是Byte,如果空闲内存小于20M则激活触发器:
# Template OS Linux:Lack of available memory on server {HOST.NAME}

SWAP相关的测试关键字:

# Template OS Linux: Total swap space
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.swap.size[,total]
# 监控swap总大小

# Template OS Linux: Free swap space
# Template OS Linux: Free swap space in %
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.swap.size[,free]
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.swap.size[,pfree]
# 监控swap空间空闲容量和空闲百分比,当空闲百分比小于50%时,激活触发器:
# Template OS Linux:Lack of free swap space on {HOST.NAME}

文件系统相关的测试关键字:

# Mounted filesystem discovery: Total disk space on /
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k vfs.fs.size[/,total]
echo $(($(df |grep -e ' /$'|awk '{print $2}')*1024))
# 监控文件系统总空间,单位是byte

# Mounted filesystem discovery: Used disk space on /
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k vfs.fs.size[/,used]
echo $(($(df |grep -e ' /$'|awk '{print $3}')*1024))
# 监控文件系统已使用空间,单位是byte

# Mounted filesystem discovery: Free disk space on /
# Mounted filesystem discovery: Free disk space on / (percentage)
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k vfs.fs.size[/,free]
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k vfs.fs.size[/,pfree]
# 监控某个文件系统的空闲容量和空闲百分比,当空闲百分比小于20%时,激活触发器:
# Free disk space is less than 20% on volume /

配置变更相关的测试关键字:

# Template OS Linux: Host name
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.hostname
# 获取系统主机名,当主机名变化时激活触发器:
# Template OS Linux:Hostname was changed on {HOST.NAME}

# Template OS Linux: System information
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k system.uname
uname -a
# 监控系统uname信息,当变化时激活触发器:
# Template OS Linux:Host information was changed on {HOST.NAME}

# Template App Zabbix Agent: Host name of zabbix_agentd running
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k agent.hostname
# 获取agent配置的主机名,当该名变化时激活触发器:
# Template App Zabbix Agent:Host name of zabbix_agentd was changed on {HOST.NAME}

# Template OS Linux: Checksum of /etc/passwd
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k vfs.file.cksum[/etc/passwd]
cksum /etc/passwd|awk '{print $1}'
# 返回cksum命令生成的校验值,如果相邻的两次之间的校验值不一致,则激活触发器:
# Template OS Linux:/etc/passwd has been changed on {HOST.NAME}

网络相关的测试关键字:

# Template App Zabbix Agent: Agent ping
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k agent.ping
ping -c 1 ${AGENT_IP} &>/dev/null;[ $? -eq 0 ]&& echo 1
# ping通则返回1,连续5分钟不通则激活触发器:
# Template App Zabbix Agent:Zabbix agent on {HOST.NAME} is unreachable for 5 minutes

# Network interface discovery: Incoming network traffic on eth0
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k net.if.in[eth0]
# 监控网卡eth0的input流量

# Network interface discovery: Outgoing network traffic on eth0
zabbix_get -s ${AGENT_IP} -p ${AGENT_PORT} -I ${SERVER_IP} -k net.if.out[eth0]
# 监控网卡eth0的output流量

[TOC]

你可能感兴趣的:(Zabbix)