I managed to make the debug work defining the debug parameters within the mysql
file. This is the output I got:
root@server2:/tmp# cat mysql_snmp.txt
2020-09-14 10:33:10 at /etc/snmp/mysql:82
'Found configuration file /etc/snmp/mysql.cnf'
2020-09-14 10:33:10 at /etc/snmp/mysql:137
array (
0 => './mysql',
)
2020-09-14 10:33:10 parse_cmdline() at /etc/snmp/mysql:266
array (
)
2020-09-14 10:33:10 validate_options() at /etc/snmp/mysql:189
array (
)
2020-09-14 10:33:10 ss_get_mysql_stats() at /etc/snmp/mysql:300
'Cache file is /var/cache/librenms/agent-local-mysql'
2020-09-14 10:33:10 ss_get_mysql_stats() at /etc/snmp/mysql:317
'The cache file seems too small or stale'
2020-09-14 10:33:10 ss_get_mysql_stats() at /etc/snmp/mysql:350
array (
0 => 'Connecting to',
1 => 'localhost',
2 => 3306,
3 => 'root',
4 => 'root',
)
2020-09-14 10:33:10 ss_get_mysql_stats() at /etc/snmp/mysql:362
'MySQL connection failed: No such file or directory'
root@server2:/tmp#
as you see: “MySQL Connection failed”
please ensure you have really set a password for root user (maybe change it to the same, to be safe)
and it is set in mysql.cnf correctly
But the credentials provided in the .cnf
file are working:
root@server2:/etc/snmp# mysql -uroot -proot -hlocalhost -P3306
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 114735
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> quit
Bye
root@server2:/etc/snmp#
root@server2:/etc/snmp# cat mysql.cnf
<?php
$debug = true;
$mysql_user = 'root';
$mysql_pass = 'root';
$mysql_host = 'localhost';
$mysql_port = 3306;
root@server2:/etc/snmp#
have you tried to login with a wrong password?
mysql/mariadb lets you also in with a given password if no password is set
Just did:
root@server2:/etc/snmp# mysql -uroot -ptoor -hlocalhost -P3306
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
root@server2:/etc/snmp#
have you tried to connect with ip instead of localhost?
OK, that failed:
root@server2:/etc/snmp# mysql -uroot -proot -h10.0.0.51 -P3306
ERROR 1045 (28000): Access denied for user 'root'@'server2.domain' (using password: YES)
root@server2:/etc/snmp#
Not really. I managed to work around that issue with the mysql connection using the IP, but the mysql
script is still failing.
The logs are still showing me the file not found
error:
2020-09-16 08:12:20 at /etc/snmp/mysql:82
'Found configuration file /etc/snmp/mysql.cnf'
2020-09-16 08:12:20 at /etc/snmp/mysql:137
array (
0 => './mysql',
)
2020-09-16 08:12:20 parse_cmdline() at /etc/snmp/mysql:266
array (
)
2020-09-16 08:12:20 validate_options() at /etc/snmp/mysql:189
array (
)
2020-09-16 08:12:20 ss_get_mysql_stats() at /etc/snmp/mysql:300
'Cache file is /var/cache/librenms/agent-local-mysql'
2020-09-16 08:12:20 ss_get_mysql_stats() at /etc/snmp/mysql:317
'The cache file seems too small or stale'
2020-09-16 08:12:20 ss_get_mysql_stats() at /etc/snmp/mysql:350
array (
0 => 'Connecting to',
1 => 'localhost',
2 => 3306,
3 => 'root',
4 => 'root',
)
2020-09-16 08:12:20 ss_get_mysql_stats() at /etc/snmp/mysql:362
'MySQL connection failed: No such file or directory'
2020-09-16 08:12:51 at /etc/snmp/mysql:82
'Found configuration file /etc/snmp/mysql.cnf'
2020-09-16 08:12:51 at /etc/snmp/mysql:137
array (
0 => '/etc/snmp/mysql',
)
2020-09-16 08:12:51 parse_cmdline() at /etc/snmp/mysql:266
array (
)
2020-09-16 08:12:51 validate_options() at /etc/snmp/mysql:189
array (
)
2020-09-16 08:12:51 ss_get_mysql_stats() at /etc/snmp/mysql:300
'Cache file is /var/cache/librenms/agent-local-mysql'
2020-09-16 08:12:51 ss_get_mysql_stats() at /etc/snmp/mysql:317
'The cache file seems too small or stale'
2020-09-16 08:12:51 ss_get_mysql_stats() at /etc/snmp/mysql:350
array (
0 => 'Connecting to',
1 => 'localhost',
2 => 3306,
3 => 'root',
4 => 'root',
)
2020-09-16 08:12:51 ss_get_mysql_stats() at /etc/snmp/mysql:362
'MySQL connection failed: No such file or directory'
on which IPs/Ports is mysql listening?
netstat -anp |grep mysql
3306:
root@server2:~# netstat -anp |grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3248/mysqld
tcp 0 0 10.0.0.51:3306 10.0.0.50:36910 ESTABLISHED 3248/mysqld
tcp 0 0 10.0.0.51:3306 10.0.0.50:36900 ESTABLISHED 3248/mysqld
tcp 0 0 10.0.0.51:3306 10.0.0.50:36844 ESTABLISHED 3248/mysqld
tcp 0 0 10.0.0.51:3306 10.0.0.50:36762 ESTABLISHED 3248/mysqld
unix 2 [ ACC ] STREAM LISTENING 21199 3248/mysqld /database/mariadb/mysql/mysql.sock
unix 3 [ ] STREAM CONNECTED 9739014 3248/mysqld /database/mariadb/mysql/mysql.sock
root@server2:~#
ok … tried this?
mysql.cnf
<?php
$debug = true;
$mysql_user = 'root';
$mysql_pass = 'root';
$mysql_host = '127.0.0.1';
$mysql_port = 3306;
as written in Documentation:
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.
Bingo!
That is some weird output message. @SourceDoctor, thanks for taking your time to help me with this issue
root@server2:/etc/snmp# ./mysql
a0:66
a1:4
a2:24
a3:23
a4:3475
a5:2082756
a6:1
a7:6
a8:0
a9:0
aa:8191
ab:7138
ac:1048
ad:0
ae:964
af:84
ag:645359
ah:436558
ai:1109
aj:991683
ak:318430
al:0
am:0
an:0
ao:0
ap:0
aq:0
yeah.
As you see it was in docs documented
Nevertheless i’m happy it runs on your side now.
Output is so because of two reason, first one is to be compatible with check_mk agents.
Second one, it’s an old script. New LibreNMS Agents have to return json.
2 Likes