문제

I have this shell script ordem2.sh. It works fine when executed in the command line:

var="$( mysql -Ns -uzabbix -e 'select ordem from mon.vendas')"
echo $var

I add UserParameter in /etc/zabbix_agentd.conf

UserParameter=ordem2,/home/ordem2.sh

But when I try to get information from zabbix 2.0 using zabbix_get -s 127.0.0.1 -p 10050 -k "ordem2", it shows no return value. What is wrong with this script?

도움이 되었습니까?

해결책

the issue was fixed.

step 1

edit sudoers using visudo and for user zabbix add /usr/bin/mysql

example: zabbix ALL=(ALL) NOPASSWD: /usr/bin/mysql,/usr/bin/nmap -O *

step 2

Add sudo before mysql in the shell script:

var="$( sudo /usr/bin/mysql -Ns -uzabbix -e 'select ordem from mon.vendas')"

Now the user zabbix agent can execute mysql.

Alexandre Alves

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top