一、在新机器上安装zabbix客户端
[[email protected]_client ~]#tar xf zabbix-3.0.3.tar.gz
[[email protected]_client ~]#cd zabbix-3.0.3
[[email protected]_client zabbix-3.0.3]#./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/ --enable-agent && make && make install
[[email protected]_client zabbix-3.0.3]#cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
[[email protected]_client zabbix-3.0.3]#cd /etc/zabbix/
[[email protected]_client zabbix]#cp zabbix_agentd.conf zabbix_agentd.conf.bak
[[email protected]_client zabbix]#vim zabbix_agentd.conf
30 LogFile=/var/log/zabbix/zabbix_agentd.log
91 Server=127.0.0.1,192.168.200.101
132 ServerActive=192.168.200.101:10051
143 Hostname=zabbix_client
278 UnsafeUserParameters=1
[[email protected]_client zabbix]#ln -s /usr/local/zabbix/sbin/zabbix_agentd /usr/local/sbin/
[[email protected]_client zabbix]#/etc/init.d/zabbix_agentd start
[[email protected]_client zabbix]#netstat -anpt |grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 47878/zabbix_agentd
二、在web界面进行配置
1、添加主机
三、自定义监控模板(监控uptime输出的信息)
1、编写监控脚本
[[email protected]_client zabbix_agentd.conf.d]# pwd
/etc/zabbix/zabbix_agentd.conf.d
[[email protected]_client zabbix_agentd.conf.d]# vim check_cpu.sh
#!/bin/bash
function one_load {
uptime | awk '{print $8}'| awk -F"," '{print $1}'
}
function five_load {
uptime | awk '{print $9}'| awk -F"," '{print $1}'
}
function fifteen_load {
uptime | awk '{print $10}'| awk -F"," '{print $1}'
}
function count_date {
uptime | awk '{print $3}' | awk -F"," '{print $1}' | awk -F":" '{print $1*60+$2}'
}
function count_user {
uptime | awk '{print $4}'
}
$1
2、配置文件添加配置(添加到最后一行即可)
[[email protected]_client zabbix_agentd.conf.d]# vim ../zabbix_agentd.conf
UserParameter=cpu.status[*],/etc/zabbix/zabbix_agentd.conf.d/check_cpu.sh $1
[[email protected]_client zabbix]# /etc/init.d/zabbix_agentd restart
3、在server端进行测试
[[email protected]_server ~]# zabbix_get -s 192.168.200.102 -k "cpu.status[one_load]"
0.18
[[email protected]_server ~]# zabbix_get -s 192.168.200.102 -k "cpu.status[five_load]"
0.10
[[email protected]_server ~]# zabbix_get -s 192.168.200.102 -k "cpu.status[count_user]"
1
4、web端配置模板
点击"模板"--->"配置"--->"创建模板"
此处就拿一个键值进行展示,其余的键值都大同小异,不再截图,看一下配置完监控项的效果
因为还没有看到触发器知识,所以直接选择了添加图形
主机链接模板
回到监控页面看一下效果
原文地址:http://blog.51cto.com/12730062/2070107