MariaDB/MySQL health plugin for Nagios Core?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
reynierpm
Posts: 20
Joined: Mon Aug 31, 2015 9:55 pm

MariaDB/MySQL health plugin for Nagios Core?

Post 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
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: MariaDB/MySQL health plugin for Nagios Core?

Post by Box293 »

As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
reynierpm
Posts: 20
Joined: Mon Aug 31, 2015 9:55 pm

Re: MariaDB/MySQL health plugin for Nagios Core?

Post by reynierpm »

Box293 wrote:This one is pretty popular:
https://exchange.nagios.org/directory/M ... th/details
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?
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: MariaDB/MySQL health plugin for Nagios Core?

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
reynierpm
Posts: 20
Joined: Mon Aug 31, 2015 9:55 pm

Re: MariaDB/MySQL health plugin for Nagios Core?

Post 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:

Code: Select all

cpan DBD::mysql
But it fails (logs are huge for post here)

Can you help me?
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: MariaDB/MySQL health plugin for Nagios Core?

Post by Box293 »

Code: Select all

yum -y install perl-DBD-MySQL
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
reynierpm
Posts: 20
Joined: Mon Aug 31, 2015 9:55 pm

Re: MariaDB/MySQL health plugin for Nagios Core?

Post by reynierpm »

Box293 wrote:

Code: Select all

yum -y install perl-DBD-MySQL
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
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: MariaDB/MySQL health plugin for Nagios Core?

Post 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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
reynierpm
Posts: 20
Joined: Mon Aug 31, 2015 9:55 pm

Re: MariaDB/MySQL health plugin for Nagios Core?

Post 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
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: MariaDB/MySQL health plugin for Nagios Core?

Post by Box293 »

Great stuff, glad you're on the right track :)
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked