zabbix_get查看agent端的key值提示没有权限:Permission denied

zabbix使用自动发现创建监控项

    agent端的配置:

    自动发现实例名,ip,端口

#!/bin/bash

printf "{\n"
printf '\t'"\"data\":["
first=1
for info in `cat /root/test.log`
do
        IFS=',' read -r -a itmes <<< $info
        if [ $first == 1 ];then
                printf '\n\t\t{'
                echo "\"{#PIDNAME}\":\"${itmes[0]}\",\"{#IP}\":\"${itmes[1]}\",\"{#PORT}\":\"${itmes[2]}\"}"
                first=0
        else
                printf '\n\t\t'
                echo ",{\"{#PIDNAME}\":\"${itmes[0]}\",\"{#IP}\":\"${itmes[1]}\",\"{#PORT}\":\"${itmes[2]}\"}"
        fi
done;

printf "\n\t]\n"
printf "}\n"

agent的配置文件

[root@accur1 zabbix_agentd.d]# vim flume.conf
UserParameter=disc_flume,bash /etc/zabbix/zabbix_agentd.d/disc_flume.sh

server端执行zabbix_get提示报错:没有权限

[root@zabbix ~]# zabbix_get -s 192.168.191.151 -p 10050 -k disc_flume
{
	"data":[cat: /root/test.log: Permission denied

	]
}

分析结果:agent端的selinux和firewalld已经关闭

需要更改agent的配置文件

修改为AllowRoot=1


server端再次执行脚本结果:

[root@zabbix ~]# zabbix_get -s 192.168.191.151 -p 10050 -k disc_flume
{
	"data":[
		{"{#PIDNAME}":"flume-test1","{#IP}":"192.168.1.1","{#PORT}":"9092"}

		,{"{#PIDNAME}":"flume-test2","{#IP}":"192.168.1.2","{#PORT}":"9093"}

	]
}


上一篇:input 非 password 类型 输入框显示圆点


下一篇:pyqt5,pycharm,Process finished with exit code -1073741819 (0xC0000005)