MySQL
MySQL
Install prereqs
The MySQL script requires PHP-CLI and the PHP MySQL extension, so please verify those are installed.
May vary based on 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 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), you may have to specify 127.0.0.1 instead of localhost. Localhost make 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
Install the agent on this device if it isn't already
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/mysql
to set your MySQL connection constants or declare them in/etc/snmp/mysql.cnf
(new file) -
Edit your snmpd.conf file and add:
extend mysql /etc/snmp/mysql
-
Restart snmpd.
The application should be auto-discovered as described at the top of the page. If it is not, please follow the steps set out under SNMP Extend
heading top of page.