Page 1 of 2
MariaDB/MySQL health plugin for Nagios Core?
Posted: Wed Sep 02, 2015 8:01 pm
by reynierpm
Perhaps this has been asked several times in the past but I can't find the right answer so if any could point me on the right direction for find a good and recommended MySQL/MariaDB health I will be very graceful. As an additional request and perhaps could be fine (if already doesn't exists) a index page or some place where sort this kind of information for newbies like me.
Thanks in advace
Re: MariaDB/MySQL health plugin for Nagios Core?
Posted: Wed Sep 02, 2015 8:06 pm
by Box293
Re: MariaDB/MySQL health plugin for Nagios Core?
Posted: Wed Sep 02, 2015 8:49 pm
by reynierpm
I have compiled the plugin by running the following commands:
Code: Select all
./configure --with-nagios-group=nagcmd
make
make install
Then I've changed the owner (because I compiled as root):
Code: Select all
chown nagios:nagios check_mysql_health
And finally I've tried to run a simple command as shown in docs:
Code: Select all
check_mysql_health --hostname localhost --username nagios --password 'xxxxxxxx' --mode connection-time
bash: check_mysql_health: command not found
Why it's failing?
Re: MariaDB/MySQL health plugin for Nagios Core?
Posted: Wed Sep 02, 2015 10:16 pm
by Box293
Make sure you pre-pend the command with
./ (if you are in /usr/local/nagios/libexec) or
/usr/local/nagios/libexec/
Code: Select all
./check_mysql_health --hostname localhost --username nagios --password 'xxxxxxxx' --mode connection-time
/usr/local/nagios/libexec/check_mysql_health --hostname localhost --username nagios --password 'xxxxxxxx' --mode connection-time
Re: MariaDB/MySQL health plugin for Nagios Core?
Posted: Wed Sep 02, 2015 11:14 pm
by reynierpm
I got this almost done but something else is failing.
Code: Select all
./check_mysql_health --hostname localhost --username nagios --password 'xxxxx' --mode connection-time
CRITICAL - cannot connect to information_schema. install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: . /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at (eval 18) line 3.
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge.
at ./check_mysql_health line 1955
I've tried also to install the module by running:
But it fails (logs are huge for post here)
Can you help me?
Re: MariaDB/MySQL health plugin for Nagios Core?
Posted: Thu Sep 03, 2015 12:10 am
by Box293
Re: MariaDB/MySQL health plugin for Nagios Core?
Posted: Thu Sep 03, 2015 6:57 pm
by reynierpm
I've compiled the plugin and get it working by running some tests as for example the command below:
Code: Select all
check_mysql_health --hostname localhost --username nagios --password xxxxxxxxx --mode connection-time
Now I want to define the service and the command but got some doubts around setup & usage and hope some one can help me here. Below is the service definition (as I am doing don't know if it's right):
Code: Select all
define service{
use local-service ; Name of service template to use
host_name localhost
service_description MariaDB
check_command check_mysql_health
notifications_enabled 1
}
The following is the command definition:
Code: Select all
# 'check_mysql_health' command definition
define command{
command_name check_mysql_health
command_line $USER1$/check_mysql_health --hostname $HOSTNAME$ --username $USERNAME$ --password $PASSWORD$
}
This is where my doubt comes since in plugin docs I can read this:
The environment variables are:
NAGIOS__SERVICEMYSQL_HOST (_mysql_host in the service definition)
NAGIOS__SERVICEMYSQL_USER (_mysql_user in the service definition)
NAGIOS__SERVICEMYSQL_PASS (_mysql_pass in the service definition)
NAGIOS__SERVICEMYSQL_PORT (_mysql_port in the service definition)
NAGIOS__SERVICEMYSQL_SOCK (_mysql_sock in the service definition)
But what is the right way to use this on the service|command definition? Can any give me some example of this and tell me also where I should write those values? Meaning current hostname, username and mysql user password
Re: MariaDB/MySQL health plugin for Nagios Core?
Posted: Thu Sep 03, 2015 8:48 pm
by Box293
Define your command like this:
Code: Select all
# 'check_mysql_health' command definition
define command{
command_name check_mysql_health
command_line $USER1$/check_mysql_health --hostname $HOSTNAME$ --username $ARG1$ --password $ARG2$ $ARG3$
}
Define your service like this:
Code: Select all
define service{
use local-service ; Name of service template to use
host_name localhost
service_description MariaDB
check_command check_mysql_health!the_username!the_password!--mode connection-time
notifications_enabled 1
}
The
! in the check_command in the service separate $ARG1$, $ARG2$, $ARG3$
Does this make sense?
Re: MariaDB/MySQL health plugin for Nagios Core?
Posted: Thu Sep 03, 2015 8:56 pm
by reynierpm
Yes, many thanks I've figured out minutes ago and got this working but thanks for your time, this will act as help for others
Re: MariaDB/MySQL health plugin for Nagios Core?
Posted: Thu Sep 03, 2015 11:32 pm
by Box293
Great stuff, glad you're on the right track
