1

I am trying to check whether MySql is up by using a UserParameter in zabbix.

UserParameter looks like this.

UserParameter=mysql.ping,sudo mysqladmin ping | grep -c alive | wc -l

When I execute mysqladmin ping | grep -c alive in the server, it is giving me the correct response.

#mysqladmin ping | grep alive | wc -l

1

But when I try to run the command as a zabbix user, It is giving the following error:

# sudo -u zabbix sudo mysqladmin ping | grep alive | wc -l mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using >password: NO)'

0

Just running the following works:

# sudo -u zabbix mysqladmin

..listing out various commands in mysqladmin

I have added zabbix to the sudoers list, requiring no password.

The issue is just for MySql, all other UserParameters (e.g. mail,load etc.) are working fine.

3
  • You probably have requiretty set in /etc/sudoers Commented Oct 13, 2015 at 10:39
  • Actually, it looks like you don't need sudo when running the command as zabbix user. Try sudo -u zabbix mysqladmin ping | grep alive | wc -l Commented Oct 13, 2015 at 10:42
  • I have commented out requiretty in /etc/sudoers, so this should not cause any problem. When I tried sudo -u zabbix mysqladmin ping | grep alive | wc -l, I got the same error as mentioned above. Commented Oct 13, 2015 at 11:36

1 Answer 1

1

You don't need to go through all this hassle. You can configure your my.cnf and zabbix agent using UserParameter=mysql.status.

Here is the solution to your problem:

 https://www.zabbix.com/forum/showthread.php?t=40870 
3
  • I have tried this method resulted in the same error shown above. I am curious on why mysql.ping won't work. Commented Oct 13, 2015 at 12:50
  • then it must be some permission issue, check your selinux configuration, look into the logs and see if you find anything related. Commented Oct 13, 2015 at 13:14
  • I couldn't make it work. Finally I ended up doing service mysqld status | grep -c running Commented Nov 4, 2015 at 3:45

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.