1 zabbix agent安装可以写如下脚本
#!/bin/sh # Description: try to install zabbix_agent with source package. v1 20151019 by liuliancao # Usage: two installation styles: # 1.Zabbix-Server checks you ,both you and the Zabbix_Server must have a public ip(but our server do not have ^_^) or you have direct way to the Zabbix-Server by Router or Switch.Please set the ZABBIX_INSTALLATION‘s value to 0 # 2.You communicate with Zabbix_Server actively when you are not in the same subnet,especially when you do not have a public ip( i mean the Zabbix-Server cannot find you.). Please set the ZABBIX_INSTALLATION‘s value to 1 ZABBIX_PACKAGE=‘zabbix-2.4.6.tar.gz‘ ZABBIX_SERVER=‘your_server_ip‘ ZABBIX_SERVER_SUBIP=‘your_server_in_ip‘ ZABBIX_INSTALLATION=1 #you need set this,0(ServerChecks),1(ActiveChecks). #unpack tar xf ~/$ZABBIX_PACKAGE # for gcc and gcc-c++ yum -y install gcc gcc-c++ 1>/dev/null #install echo "installing.................." cd ${ZABBIX_PACKAGE%.tar.gz} ./configure --prefix=/usr/local/zabbix --enable-agent --sysconfdir=/etc/zabbix &>/dev/null make &>/dev/null && make install &>/dev/null echo "export PATH=$PATH:/usr/local/zabbix/bin:/usr/local/zabbix/sbin" >> /etc/profile && source /etc/profile cp misc/init.d/tru64/zabbix_agentd /etc/init.d/ chmod 755 /etc/init.d/zabbix_agentd sed -i ‘1a # chkconfig: 2345 90 10‘ /etc/init.d/zabbix_agentd sed -i ‘2a # Description: Zabbix_agentd service.‘ /etc/init.d/zabbix_agentd sed -i ‘s%DAEMON=/usr/local/sbin/zabbix_agentd%DAEMON=/usr/local/zabbix/sbin/zabbix_agentd%‘ /etc/init.d/zabbix_agentd chkconfig --add zabbix_agentd && chkconfig zabbix_agentd on #add zabbix group groupadd -g 201 zabbix && useradd -g zabbix -u 201 zabbix #modify zabbix_agentd.conf if [ $ZABBIX_INSTALLATION -eq 1 ];then sed -i ‘s%Server=127.0.0.1%#Server=127.0.0.1%‘ /etc/zabbix/zabbix_agentd.conf sed -i "s%ServerActive=127.0.0.1%ServerActive=$ZABBIX_SERVER:10053%" /etc/zabbix/zabbix_agentd.conf sed -i ‘s%# StartAgents=3%StartAgents=0%‘ /etc/zabbix/zabbix_agentd.conf # else #if you can ping zabbix_server with subnet ip,use this sed -i "s%Server=127.0.0.1%Server=$ZABBIX_SERVER_SUBIP%" /etc/zabbix/zabbix_agentd.conf sed -i "s%ServerActive=127.0.0.1%# ServerActive=127.0.0.1%" /etc/zabbix/zabbix_agentd.conf fi #all need to be done sed -i ‘s%# UnsafeUserParameters=0%UnsafeUserParameters=1%‘ /etc/zabbix/zabbix_agentd.conf sed -i ‘s%# Include=$%Include=/etc/zabbix/zabbix_agentd.conf.d%‘ /etc/zabbix/zabbix_agentd.conf sed -i ‘s%Hostname=Zabbix server%# Hostname=Zabbix server%‘ /etc/zabbix/zabbix_agentd.conf # #try to run zabbix_agentd echo "now starting zabbix_agentd service..." service zabbix_agentd start && echo "start successfully." || echo "start failed.please check the log file /tmp/zabbix_agentd.log" && exit 3
2 zabbix 报警系统的调试
2.0 总体的思路:首先你的动作action可以是空条件的,这样你enabled就会触发,可避免触发器或这action设置不当引起错误
2.1 如果不用脚本,那么直接调试,设置好媒介media,用户user,和权限,就直接取Administration-audit-actionlog查看,是否有什么报错
2.2 如果用了脚本(推荐使用sendEmail,之前有介绍),本地先执行看是否有错误,可能有退回或者提示等,这时候就需要去邮件设置snmp等服务的开启,或者添加白名单等等,这里也可以防止密码填错等问题。
2.3 测试完脚本然后按2.1去web添加,查看日志的处理情况
3 zabbix xml文件
首先zabbix可以把模版和screen等导出为xml文件,zabbix的xml文件有很多相似之处,这里咱们就可以偷懒,实现多item或这多screen source的添加,具体可以写脚本,我通常很懒,以后再更新写脚本吧,不过通常一个sed就够用了。
比如我想添加screen,我已经有了一个我的所有主机的网络信息了,那么我想同样监控这些主机的cpu和内存咋办,肯定不是一个一个添加,我们可以把网络的xml导出,然后执行
sed ‘s#<name>.*</name>#<name>CPU utilization</name>#g‘ Downloads/zbx_export_screens.xml > cpu_monitor.xml
然后再修改第一个screen的name名称即可。
4 可能极少的人还不知道monitoring-latestdata可以查看具体的数据,在configuration-hosts那里可以看那些添加的item是否合格,是否有问题
时间: 2024-11-07 12:48:40