You will need to open port tcp/3306 from the Opsview Monitor server to the MySQL server host. See your operating system/firewall documentation for information on how to do this if your host is running a local firewall.
On the MySQL server to be monitored:
- Install the Opsview Agent - see [Opsview Agents] (doc:opsview-agents)
- Enable remote connections in MySQL (see http://dev.mysql.com/doc/refman/5.7/en/server-options.html) but ensure you have set a MySQL root password for security reasons ('mysql_secure_installation' may be available on your system to secure MySQL)
- Create a dedicated user within MySQL for use by monitoring (see http://dev.mysql.com/doc/refman/5.5/en/adding-users.html for more information). Suitable SQL to create an 'opsview' user might be (NOTE: set the <opsview server IP address> and <password> accordingly):
mysql> CREATE USER 'opsview'@'<opsview server IP address>' IDENTIFIED BY '<password>';
mysql> FLUSH PRIVILEGES;
In the Opsview Monitor UI:
- Create a new host within "Menu => Settings => Host Settings" for your MySQL database server.
- Add the Host Template "OS - Opsview Agent"
- Add the Host Template "Database - MySQL Server"
- On the 'Variables' tab add in 'MYSQLCREDENTIALS' with a value set to 'credentials'. In the lower pane override the username and password for the account you created in MySQL
- Submit Changes
- Perform a configuration reload by using "Menu => Settings => Reload"
If you see the below output:
$ /usr/local/nagios/libexec/check_mysql_performance -H localhost -u opsview -p PASSWORD --metricname=Connections -w 20 -c 30 MONITORED BY: master RETURN CODE: 255 ERROR: DBI connect('host=localhost','opsview',...) failed: Access denied for user 'opsview'@'localhost' (using password: YES) at /usr/local/nagios/libexec/check_mysql_performance line 463.
This means that the username we are using is not set up in the database we are trying to monitor (see the "Installation..." section above).