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


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)'


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.

  • You probably have requiretty set in /etc/sudoers – Joshua Griffiths Oct 13 '15 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 – Joshua Griffiths Oct 13 '15 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. – fatninja Oct 13 '15 at 11:36

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:

  • I have tried this method resulted in the same error shown above. I am curious on why mysql.ping won't work. – fatninja Oct 13 '15 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. – ostendali Oct 13 '15 at 13:14
  • I couldn't make it work. Finally I ended up doing service mysqld status | grep -c running – fatninja Nov 4 '15 at 3:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.