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.

Konrad Gajewski
  • 1,518
  • 3
  • 15
  • 29
fatninja
  • 11
  • 1
  • 3
  • 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

1 Answers1

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
ostendali
  • 403
  • 2
  • 4
  • 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 04 '15 at 03:45