MySQL
MySQL
Install prereqs
The MySQL script requires PHP-CLI and the PHP MySQL extension, so please verify those are installed.
The version depends on your PHP version
apt-get install php-cli php-mysql
yum install php-cli php-mysql
Create the cache directory
Create the cache directory, '/var/cache/librenms/' and make sure that it is owned by the user running the SNMP daemon.
mkdir -p /var/cache/librenms/
MySQL User
Refer to the Percona Documentation for details on how to create a MySQL user with privileges to read the required monitoring data from MySQL / MariaDB.
MySQL script
Unlike most other scripts, the MySQL script requires a configuration file mysql.cnf in the same directory as the extend or agent script with following content:
<?php
$mysql_user = 'root';
$mysql_pass = 'toor';
$mysql_host = 'localhost';
$mysql_port = 3306;
Note that depending on your MySQL installation (chrooted install for example), use 127.0.0.1 instead of localhost. localhost makes a MySQL connection via the mysql socket, while 127.0.0.1 make a standard IP connection to mysql.
Note also if you get a mysql error Uncaught TypeError: mysqli_num_rows(): Argument #1, this is because you are using a newer mysql version which doesnt support UNBLOCKING for slave statuses, so you need to also include the line $chk_options['slave'] = false; into mysql.cnf to skip checking slave statuses
If this device has no agent, install the agent
and copy the mysql script to /usr/lib/check_mk_agent/local/
Verify it is working by running /usr/lib/check_mk_agent/local/mysql
-
Copy the mysql script to the desired host.
wget https://github.com/librenms/librenms-agent/raw/master/snmp/mysql -O /etc/snmp/mysql -
Make the file executable
chmod +x /etc/snmp/mysql -
Edit
/etc/snmp/mysqlto set your MySQL connection constants or declare them in/etc/snmp/mysql.cnf(new file) -
Edit your
snmpd.conffile and add:extend mysql /etc/snmp/mysql -
Restart snmpd.
LibreNMS discovers the application automatically, as described at the top of the page. If the discovery fails, do the steps under the SNMP Extend heading at the top of the page.