zabbix 监控日志和报权限问题
1、客户端配置
[root@mysql zabbix_agentd.conf.d]# pwd /usr/local/zabbix-server/etc/zabbix_agentd.conf.d [root@mysql zabbix_agentd.conf.d]# cat custom_parameters.conf UserParameter=masterha_manager,[ `/bin/ps aux | /bin/grep -v grep | /bin/grep -o masterha_manager` == masterha_manager ] &> /dev/null ;echo $? UserParameter=crond,[ `/bin/ps aux | /bin/grep -v grep | /bin/grep -o crond` == crond ] &> /dev/null ;echo $? UserParameter=postfix,[ `/bin/ps aux | /bin/grep -v grep | /bin/grep -o postfix` == postfix ] &> /dev/null ;echo $? UserParameter=error,/usr/local/zabbix-server/error_log.sh
2、检查日志关键字脚本
#!/bin/bash msg=`tail -n 100 /var/log/secure | grep -iE "error" ` if [ ! -n "$msg" ];then echo "OK" exit 0 else echo "error" exit 0 fi
3、zabbix 监控项和触发器配置
监控项配置:
触发器配置:
4、告警展示
zabbix_get查看agent端的key值提示没有权限:Permission denied
zabbix 平台监控项获取监控值为
sh /root/test.sh: Permission denied
分析结果:agent端的selinux和firewalld已经关闭,zabbix agent 没有执行脚本的权限
需要更改agent的配置文件
vim /etc/zabbix/zabbix_agent.conf
修改为
AllowRoot=1
本文来自希曼博客-www.ximan.tech,作者:希曼博客,转载请注明原文链接:https://www.cnblogs.com/lihuaichen/p/15240198.html