سؤال

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