virgo-agent-toolkit / rackspace-monitoring-agent

Rackspace Cloud Monitoring Agent
http://virgoagent.com/rackspace-monitoring-agent/
Apache License 2.0
118 stars 39 forks source link

agent.mysql doesn't use details[username] #843

Open joeashcraft opened 9 years ago

joeashcraft commented 9 years ago

I'm unable to get the agent.mysql check to authenticate to the server. It seems it's using the default credentials (user 'root' with no password).

Symptoms:

agent.mysql check doesn't return any metrics, though the log shows it's trying to run.

Steps to Recreate:

  1. create check on agent.mysql with the following details: {"host":"127.0.0.1","port":3306,"username":"raxmon","password":"qwerty1234"}
  2. create the 'raxmon' user in mysql mysql -e "grant process on *.* to raxmon@localhost identified by 'qwerty1234'; flush privileges;"
  3. see no metrics in Rackspace Intelligence or with /usr/bin/rackspace-monitoring-agent -d -o -e check_runner -x agent.mysql

output of check_runner:

state unavailable
status mysql_real_connect(host=127.0.0.1, port=3306, username=(null)) failed: (1045) Access denied for user 'root'@'127.0.0.1' (using password: NO)

log entry:

Thu Aug 20 17:12:32 2015 INF: (plugin=agent.mysql, id=chg61Xvxxx, iid=idVhzQoxxx) -> agent.mysql (details=host="127.0.0.1",password="qwerty1234",port=3306,username="raxmon",id="chg61Xvxxx",period=60) scheduled for 60s

manual testing:

$ mysql -u raxmon -h 127.0.0.1 -pqwerty1234 -sse "show status like 'Connections%';"
Connections 903936
rjemanuele commented 9 years ago

Hi Joe,

It does take a little while for data to show up in Intelligence. If you still do not have data, you can enable debug logging in the agent. You do that by adding a line to the config file /etc/rackspace-monitoring-agent.cfg that says: monitoring_debug true After that line is added, restart the agent and you'll see more information logged. Find your check and you can post here the details returned by mysql (assuming there are).

Thank you,

Rob

PS The check runner does not have the username and password required to run the check as you would like, the best bet if using raxmon would be to send a test check with the details specified.

joeashcraft commented 9 years ago

Thanks for the tip about the debug log. It turns out the MySQL user just didn't have proper privileges!

Fri Aug 21 10:51:24 2015 DBG: 2001::::::::443 (hostname=agent-endpoint-ord.monitoring.api.rackspacecloud.com connID=1) -> SENDING: (endpoint:500) => {"target":"endpoint","source":"axxxxxxx-fxxx-4xxx-cxxx-bxxxxx1xxxxx","id":"500","params":{"timestamp":1440193884000,"check_type":"agent.mysql","status":"mysql_query \"show slave status\" failed: (1227) Access denied; you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation","state":"unavailable","min_check_period":75000,"metrics":[],"check_id":"chg61Xvxxx"},"v":"1","method":"check_metrics.post"}

For reference, here's the first few lines of debug log when this check works:

Fri Aug 21 10:53:39 2015 DBG: (plugin=agent.mysql, id=chg61Xvxxx, iid=idOPLeixxx) -> /usr/bin/rackspace-monitoring-agent: starting process
Fri Aug 21 10:53:39 2015 DBG: (plugin=agent.mysql, id=chg61Xvxxx, iid=idOPLeixxx) -> Setting check status string (status=success)
Fri Aug 21 10:53:39 2015 DBG: (plugin=agent.mysql, id=chg61Xvxxx, iid=idOPLeixxx) -> Metric added (dimension=innodb, name=os_log_pending_fsyncs, type=uint64, value=0, unit=queries)

Apparently, the minimum required privileges are process, replication client.

+-------------------------------------------------------------------------------------------------------------------------------------+
| Grants for raxmon@127.0.0.1                                                                                                         |
+-------------------------------------------------------------------------------------------------------------------------------------+
| GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'raxmon'@'127.0.0.1' IDENTIFIED BY PASSWORD '*ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789XXX' |
+-------------------------------------------------------------------------------------------------------------------------------------+
joeashcraft commented 9 years ago

as for a feature request... it might be nice to have the MySQL error as something higher than DBG level output.

rjemanuele commented 9 years ago

Thanks Joe. We'll definitely look into changing that error message to be logged at a higher level. We'll leave this open as a record to change that.