18_zabbix监控cpu、内存、磁盘、流量

zabbix_get服务端

  1. zabbix提供一个zabbix_get工具,可以跟zabbix agent通讯获取监控信息
  2. 使用方式:zabbix_get -s "IP" -k "key"
    例如:zabbix_get -s 192.168.3.199 -k system.uname
  3. zabbix agent 查看所有监控项目(key):zabbix_agentd -p

监控cpu(key值)

负载

system.cpu.load[all,avg1] #Float型
system.cpu.load[all,avg5] #Float型
system.cpu.load[all,avg15] #Float型

使用和空闲

system.cpu.util[,iowait,] #Float型
system.cpu.util[,system,] #Float型
system.cpu.util[,user,] #Float型
system.cpu.util[,idle,] #Float型

监控内存(key值)

剩余(buffers\cached实际上也是剩余的)

vm.memory.size[available]

监控磁盘

名称:Disk pfree on $1
名称:inode pfree on $1
vfs.fs.size[/,pfree] #Float型
vfs.fs.inode[/,pfree] #Float型

监控流量

net.if.in[eth0] #整型(每秒速率),默认返回字节数,需要8
net.if.out[eth0] #整型(每秒速率),默认返回字节数,需要
8
shell计算流量

onetime=$(ifconfig | grep eth0 -A 6 | grep 'RX packets' | awk '{print $5}')
sleep 30
twotime=$(ifconfig | grep eth0 -A 6 | grep 'RX packets' | awk '{print $5}')
echo "incoming traffic is $((($twotime-$onetime)/30*8))bps"

onetime=$(ifconfig | grep eth0 -A 6 | grep 'TX packets' | awk '{print $5}')
sleep 30
twotime=$(ifconfig | grep eth0 -A 6 | grep 'TX packets' | awk '{print $5}')
echo "outing traffic is $((($twotime-$onetime)/30*8))bps"