Code Monkey home page Code Monkey logo

sensu-plugins / sensu-plugins-mysql Goto Github PK

View Code? Open in Web Editor NEW
18.0 9.0 63.0 147 KB

This plugin provides native MySQL instrumentation for monitoring and metrics collection, including: service health, database connectivity, `InnoDB` locks, replication status, metrics collection, and sending metrics to a MySQL database.

Home Page: http://sensu-plugins.io

License: MIT License

Ruby 100.00%
sensu-plugins-mysql sensu-plugins mysql mysql-metrics metrics

sensu-plugins-mysql's Introduction

Sensu-Plugins-mysql

Build Status Gem Version Code Climate Test Coverage Dependency Status

Functionality

Files

  • bin/check-cloudwatch-mysql-sensu.rb
  • bin/check-mysql-alive.rb
  • bin/check-mysql-status.rb
  • bin/check-mysql-connections.rb
  • bin/check-mysql-disk.rb
  • bin/check-mysql-innodb-lock.rb
  • bin/check-mysql-threads.rb
  • bin/check-mysql-query-result-count.rb
  • bin/check-mysql-select-count.rb
  • bin/check-mysql-msr-replication-status.rb
  • bin/metrics-mysql-graphite.rb
  • bin/metrics-mysql-multiple-select-count.rb
  • bin/metrics-mysql-processes.rb
  • bin/metrics-mysql-raw.rb
  • bin/metrics-mysql.rb
  • bin/metrics-mysql-query-result-count.rb
  • bin/metrics-mysql-select-count.rb
  • bin/mysql-metrics.sql

Usage

metrics-mysql

{
    "mysql":{
        "hostname": "localhost",
        "username": "sensu_user",
        "password": "sensu_user_pass"
    }
}

metrics-mysql-graphite example:

/opt/sensu/embedded/bin$ /opt/sensu/embedded/bin/ruby metrics-mysql-graphite.rb --host=localhost --port=3306 --user=collectd --pass=tflypass --socket=/data/mysql.sock

check-mysql-connections example

/opt/sensu/embedded/bin$ /opt/sensu/embedded/bin/ruby check-mysql-connections.rb --host=localhost --port=3306 --user=collectd --pass=tflypass --socket=/data/mysql.sock

check-mysql-connections example with ini file to hide credentials

$ /opt/sensu/embedded/bin/check-mysql-connections.rb --host=<DBHOST> --ini=/etc/sensu/my.ini

check-mysql-alive example

$ /opt/sensu/embedded/bin/check-mysql-alive.rb --host=<DBHOST> --ini=/etc/sensu/my.ini --ini-section=customsection

check-mysql-disk example (note: you must supply max disk size)

$ /opt/sensu/embedded/bin/check-mysql-disk.rb --host=<DBHOST> --ini=/etc/sensu/my.ini --size <MAX_DB_SIZE>

check-mysql-innodb-lock example

$ /opt/sensu/embedded/bin/check-mysql-innodb-lock.rb --host=<DBHOST> --ini=/etc/sensu/my.ini

check-mysql-threads example

$ /opt/sensu/embedded/bin/check-mysql-threads.rb --host=<DBHOST> --ini=/etc/sensu/my.ini --warnlow 0

check-mysql-replication-status example

$ /opt/sensu/embedded/bin/check-mysql-replication-status.rb --host=<SLAVE> --ini=/etc/sensu/my.ini

check-mysql-msr-replication-status example

$ /opt/sensu/embedded/bin/check-mysql-replication-status.rb --host=<SLAVE> --ini=/etc/sensu/my.ini

check-mysql-query-result-count example

/opt/sensu/embedded/bin$ /opt/sensu/embedded/bin/ruby check-mysql-query-result-count.rb --host=localhost --port=3306 --user=collectd --pass=tflypass --socket=/data/mysql.sock --warning 1 --critical 10 --query 'SELECT DISTINCT(t.id) FROM table t where t.failed = true'

check-mysql-select-count example

/opt/sensu/embedded/bin$ /opt/sensu/embedded/bin/ruby check-mysql-select-count.rb --host=localhost --port=3306 --user=collectd --pass=tflypass --socket=/data/mysql.sock --warning 30000 --critical 50000 --query 'SELECT count(*) FROM table t'

metrics-mysql-query-result-count example

/opt/sensu/embedded/bin$ /opt/sensu/embedded/bin/ruby metrics-mysql-query-result-count.rb --host=localhost --port=3306 --user=collectd --pass=tflypass --socket=/data/mysql.sock --query 'SELECT DISTINCT(t.id) FROM table t where t.failed = true'

metrics-mysql-select-count example

/opt/sensu/embedded/bin$ /opt/sensu/embedded/bin/ruby metrics-mysql-select-count.rb --host=localhost --port=3306 --user=collectd --pass=tflypass --socket=/data/mysql.sock --query 'SELECT COUNT(*) FROM table t'

metrics-mysql-multiple-select-count example

/opt/sensu/embedded/bin$ /opt/sensu/embedded/bin/metrics-mysql-multiple-select-count.rb --host=localhost --port=3306 --user=collectd --pass=tflypass --socket=/data/mysql.sock --query '{"t1_count":"SELECT COUNT(*) FROM table t1", "t2_count":"SELECT COUNT(*) FROM table t2"}'

Security

In keeping with the principle of least privilege you should create a new user with the minimum required permissions. See the table below for minimum permissions for each check.

Check Permissions
check-mysql-alive.rb SELECT
check-mysql-connections.rb SELECT
check-mysql-disk.rb SELECT
check-mysql-innodb-lock.rb PROCESS
check-mysql-query-result-count.rb depends on query
check-mysql-select-count.rb SELECT
check-mysql-replication-status.rb SUPER OR REPLICATION_CLIENT (the latter is preferable)
check-mysql-msr-replication-status.rb SELECT
check-mysql-status.rb SELECT
check-mysql-threads.rb SELECT
metrics-mysql-graphite.rb SELECT
metrics-mysql-processes.rb SELECT
metrics-mysql-query-result-count.rb depends on query
metrics-mysql-select-count.rb   depends on query                                        
metrics-mysql-multiple-select-count   depends on query                                        
metrics-mysql-raw.rb SELECT
metrics-mysql.rb INSERT into sensumetrics.sensu_historic_metrics

I would recommend using different users when you need to have more than RO access (REPLICATION_CLIENT or using the metrics handler) to limit the potential ramifications of that user being compromised.

Installation

Installation and Setup

Notes

The ruby executables are install in path similar to /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugins-mysql-0.0.4/bin

Troubleshooting

When used in chef, if the dependencies are missing, an error may abort the chef-client run:

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

This may be fixed by installing the mysql client library before the plugin:

# http://serverfault.com/questions/415392/install-mysql-gem-for-use-in-chef-client
package "libmysqlclient-dev" do
  action :install
end

sensu_gem 'sensu-plugins-mysql' do version '0.0.4' end

sensu-plugins-mysql's People

Contributors

2autunni avatar aerostitch avatar alchandia avatar amdprophet avatar analytically avatar bill538 avatar corro avatar cwjohnston avatar dcharleston avatar dependabot-preview[bot] avatar dependabot-support avatar eheydrick avatar fuzzy-logic-zach avatar hanynowsky avatar hobthross avatar jroyal avatar jtomaszon avatar majormoses avatar mattyjones avatar multani avatar nagyt234 avatar ndelic0 avatar negachov avatar oba11 avatar runtimee avatar scones avatar sensu-plugin avatar sstarcher avatar tas50 avatar tinle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sensu-plugins-mysql's Issues

Can't use check-mysql-status with remote db

Two problems:

a) generated command assumes you're using a socket even when you specific a remote host

b) the password I supply in my.ini gets double quotes added to it in the command which makes it invalid

check-mysql-threads.rb not installed with gem

[/opt/sensu/embedded/bin]# ls -la | grep check-mysql
-rwxr-xr-x. 1 root root    533 Jun 14 21:22 check-mysql-alive.rb
-rwxr-xr-x. 1 root root    539 Jun 14 21:22 check-mysql-connections.rb
-rwxr-xr-x. 1 root root    532 Jun 14 21:22 check-mysql-disk.rb
-rwxr-xr-x. 1 root root    539 Jun 14 21:22 check-mysql-innodb-lock.rb
-rwxr-xr-x. 1 root root    546 Jun 14 21:22 check-mysql-replication-status.rb

[/opt/sensu/embedded/bin]# ./gem list | grep sensu-plugins-mysql
sensu-plugins-mysql (0.0.4)

[/opt/sensu/embedded/bin]# ls /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-mysql-0.0.4/bin/
check-cloudwatch-mysql-sensu.rb    check-mysql-connections.rb         check-mysql-innodb-lock.rb         metrics-mysql-graphite.rb          mysql-metrics.sql
check-mysql-alive.rb               check-mysql-disk.rb                check-mysql-replication-status.rb  metrics-mysql.rb

Is there a new release coming?

`metrics-mysql.rb` should be renamed to indicate it is a handler

Discovered in #63:

In order to help users quickly identify and start using various components we have a naming convention for files:

  • check-*: indicates that it is a non metric check
  • metric-*: indicates that it is a metric check
  • handler-*: indicates that it is a handler
  • mutator-*: indicates that it is a mutator

I am not sure this is actually documented anywhere but it really needs to be (I will create another issue for that).

The file is named metrics-mysql.rb only after looking at the code did I realize it was not a metrics gatheror for mysql it was a handler to send metric data to mysql. To avoid confusion in a major release we should rename it to better reflect its nature, I am open to ideas but this is my initial thought:

  • handler-mysql-metrics.rb
  • handler-mysql.rb

@sensu-plugins/commit-bit any thoughts?

Code and help text inconsistent for minimum thresholds in check-mysql-threads.rb

The inline help says

Number of running threads under which we'll issue a warning/alert

but the code says

critical "MySQL currently running threads: #{run_thr}" if run_thr <= config[:mincrit].to_i warning "MySQL currently running threads: #{run_thr}" if run_thr <= config[:minwarn].to_i

Either the help should say "at which" or the code should say "<"

metrics_mysql error reading event: A JSON text must at least contain two octets!

Dear All,
Thanks a lot for committing to this fantastic project.
We have Sensu server and install every sensu client with this method:

echo '[sensu]
name=sensu
baseurl=http://sensu.global.ssl.fastly.net/yum/$basearch/
gpgcheck=0
enabled=1' > /etc/yum.repos.d/sensu.repo
yum install -y sensu

then download ssl keys
then

systemctl enable sensu-client
systemctl start sensu-client

then

yum -y install ioping
yum -y install python-pip gcc
/opt/sensu/embedded/bin/gem install sensu-plugins-load-checks
 /opt/sensu/embedded/bin/gem install sensu-plugins-io-checks
 /opt/sensu/embedded/bin/gem install sensu-plugins-disk-checks
 /opt/sensu/embedded/bin/gem install sensu-plugins-memory-checks
 /opt/sensu/embedded/bin/gem install sensu-plugins-hardware
 /opt/sensu/embedded/bin/gem install sensu-plugins-uptime-checks
/opt/sensu/embedded/bin/gem install sensu-plugins-vmstats
# for redis
 /opt/sensu/embedded/bin/gem install  sensu-plugins-redis
# for mysql
 /opt/sensu/embedded/bin/gem install sensu-plugins-mysql
# for port checks
 /opt/sensu/embedded/bin/gem install sensu-plugins-network-checks
# for mongodb you also need pymongo through pip
# pip install pymongo
 /opt/sensu/embedded/bin/gem install sensu-plugins-mongodb
# network checks
/opt/sensu/embedded/bin/gem install sensu-plugins-network-checks
# process checks
/opt/sensu/embedded/bin/gem install sensu-plugins-process-checks
chown -hR sensu:sensu /opt/sensu/
systemctl restart sensu-client

and after that we give access to mysql user

create database sensumetrics;
use sensumetrics;
create table sensu_historic_metrics(
    `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `client_id` VARCHAR(150) NOT NULL,
    `check_name` VARCHAR(100) NOT NULL,
    `issue_time` INT(8) UNSIGNED NOT NULL,
    `output` TEXT,    
    `status` INT(2) UNSIGNED,
    INDEX `client_id_idx` (`client_id`),
    INDEX `check_name_idx` (`check_name`),
    INDEX `issue_time_idx` (`issue_time`)
);
GRANT SELECT,INSERT on sensumetrics.sensu_historic_metrics TO sensu_user@'localhost' IDENTIFIED BY 'sensu_user_pass';
FLUSH PRIVILEGES;

After these everything works correctly but I see one point:

  | metrics_mysql | error reading event: A JSON text must at least contain two octets!

But its not like an error, It's wired that I have no MySQL error except this one, Can you help me to fix this?
If there are any other information that I should provide, please let me know.
I get this text on all other clients (about 30 virtual machines) all on the last one that I installed 2 days ago
Thanks a lot.
sensu

libmysqlclient.so.20()(64bit) is needed

Getting the dependencies error while installing DBD-mysql-4.046-1.el6.x86_64 from the rpm
libmysqlclient.so.20()(64bit) is needed by DBD-mysql-4.046-1.el6.x86_64
libmysqlclient.so.20(libmysqlclient_20.0)(64bit) is needed by DBD-mysql-4.046-1.el6.x86_64

conflict between options on check-mysql-disk.rb

on this script there is:

 option :size,
         short: '-s',
         long: '--size=VALUE',
         description: 'Database size',
         proc: proc(&:to_f),
         required: true

and

option :socket,
       description: 'Socket to use',
       short: '-S SOCKET',
       long: '--socket SOCKET',
       default: nil

So we can't use socket for connecting to the DB

Doesn't work with MySQL 8 due to different default charset

MySQL 8 changed the default charset to utf8mb4. It seems this broke the mysql sensu scripts, as they all error out when connecting now.

CheckMySQLHealth CRITICAL: MySQL check failed: unknown charset number: 255

As far as I can tell, there's no configuration option for the scripts to tell what charset they should use when connecting.

check-mysql-disk.rb size should be a required option

I setup a very simple docker test using this:

docker run --name sensu-test -e MYSQL_ROOT_PASSWORD="SOME_ROOT_PASS" mysql:5.7
# inside docker container
mysql> GRANT SELECT ON *.* TO 'sensu'@'172.17.0.1' IDENTIFIED BY 'sensu';
mysql> FLUSH PRIVILEGES;

when running the following command it criticals incorrectly and probably should emit an unknown:

$ ./bin/check-mysql-disk.rb -h 172.17.0.2 -u sensu -p sensu
CheckMysqlDisk CRITICAL: Database size exceeds critical threshold: DB size: 0.01, disk use: Infinity%

I have not inspected the sql very but I would guess that it is right and we need some special logic to deal with disk in use as infinity

check-mysql-disk.rb error : CheckMysqlDisk CRITICAL: comparison of Float with String failed

I'm not familiar with ruby.

When I run check-mysql-disk.rb, I found this error.
"CheckMysqlDisk CRITICAL: comparison of Float with String failed"

$ check-mysql-disk.rb -h 127.0.0.1 -i /etc/sensu/conf.d/mysql.cnf --size 1000
CheckMysqlDisk CRITICAL: comparison of Float with String failed

If I add "to_f" to disk_size, critical_usage, warning_usage, it works well.
Is this the right way? If then, I will make a pull request.

$ diff check-mysql-disk.rb test-check-mysql-disk.rb
88,90c88,90
<     disk_size = config[:size]
<     critical_usage = config[:crit]
<     warning_usage = config[:warn]
---
>     disk_size = config[:size].to_f
>     critical_usage = config[:crit].to_f
>     warning_usage = config[:warn].to_f

version `libmysqlclient_20.2' not found

Getting this message when running the slave status check...

/opt/sensu/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require': /usr/lib64/mysql/libmysqlclient.so.20: version libmysqlclient_20.2' not found (required by /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/mysql-2.9.1/lib/mysql/mysql_api.so) - /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/mysql-2.9.1/lib/mysql/mysql_api.so (LoadError)
from /opt/sensu/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/mysql-2.9.1/lib/mysql.rb:6:in rescue in <top (required)>'
from /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/mysql-2.9.1/lib/mysql.rb:2:in <top (required)>' from /opt/sensu/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require'
from /opt/sensu/embedded/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-mysql-0.0.4/bin/check-mysql-replication-status.rb:27:in <top (required)>'
from /opt/sensu/embedded/bin/check-mysql-replication-status.rb:22:in load' from /opt/sensu/embedded/bin/check-mysql-replication-status.rb:22:in

'
Usage: /opt/sensu/embedded/bin/check-mysql-replication-status.rb (options)

It seems to be working on all servers except the ones that I removed the older version of mysql connector for python and installed a newer version that worked with the 1.6.4 mysql utilities.

I found the libmysqlclient.so.20.2.0 (i think) in an older version of mysql that i extracted and put in the /usr/lib64/mysql directory... Didn't help, but looking at the file i see it's calling for the _20.2 in the so.20 file not the one I put in there.

So, I'm not really sure how to go about resolving this. I have tried reinstalling the plugin the mysql2 gem. I cannot reinstall mysql without jumping through a lot of hoops.

any idea?

Update requirement mysql2

Currently required mysql2 version 0.3.18 does not properly close mysql connections (see brianmario/mysql2#606). This leads to the effect, that metrics-mysql-graphite.rb always reports an aborted client every check. This issue should be fixed in newer version of mysql2.

gem not found

I've installed the sensu-plugin cert as documented in the README, but I am seeing following error message when I try to install it.

$ gem install sensu-plugins-mysql
ERROR:  Could not find a valid gem 'sensu-plugins-mysql' (>= 0) in any repository

Sensu not handling event sourced from metrics-mysql-graphite.rb

I know this is a long shot but wanted to check here.

I'm running /opt/sensu/embedded/bin/metrics-mysql-graphite.rb and getting the correct output. But I've noticed that using my graphite handler (type => 'tcp') the sensu server is receiving, processing, and storing the check fine but not getting to the "handling event" section. All other checks using this graphite handler are sending fine.

Any ideas why this might be? Is the output too long? Is 94 datapoints too many?

Any suggestions would be greatly appreciated.

Add socket param to INI file

we populate the /etc/sensu/my.cnf with MySQL user and pass. But usually we need to point the path of used MySQL socket which is not always /var/lib/mysql/mysql.sock

  • Thus, enabling socket param in /etc/sensu/my.cnf is the best option (Since using --socket option from sensu server is impossible when differents clients have different mysql paths):
    Just this would do:
def run
    if config[:ini]
      ini = IniFile.load(config[:ini])
      section = ini['client']
      db_user = section['user']
      db_pass = section['password']
      db_socket = section['socket']
    else
      db_user = config[:user]
      db_pass = config[:password]
      db_socket = config[:socket]
    end

    begin
      db = Mysql.real_connect(config[:hostname], db_user, db_pass, config[:database], config[:port].to_i, db_socket)

Not all options read from ini file

Need to add the ability to pull :host and :socket from ini file (my.cnf). While there are cli options for this, the config file already contains this information and should have the option to be leveraged as to better follow the DRY principle.

No such file or directory - connect(2) for /tmp/mysql.sock

Running /opt/sensu/embedded/bin/check-mysql-connections.rb on Ubuntu Xenial results in:

Check failed to run: No such file or directory - connect(2) for /tmp/mysql.sock, 
["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/ruby-mysql-2.9.14/lib/mysql/protocol.rb:150:in
 `initialize'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/ruby-mysql-2.9.14/lib/mysql
/protocol.rb:150:in `new'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/ruby-mysql-2.9.14/lib/mysql
/protocol.rb:150:in `block in initialize'", "/opt/sensu/embedded/lib/ruby/2.3.0/timeout.rb:74:in `timeout'", 
"/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/ruby-mysql-2.9.14/lib/mysql/protocol.rb:147:in 
`initialize'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/ruby-mysql-2.9.14/lib/mysql.rb:115:in 
`new'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/ruby-mysql-2.9.14/lib/mysql.rb:115:in 
`connect'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/ruby-mysql-2.9.14/lib/mysql.rb:50:in 
`new'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-mysql-1.0.0/bin/check-mysql-
connections.rb:79:in `run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.4.2/lib/sensu-plugin/cli.rb:58:in `block in <class:CLI>'"]

while the database is running:

  • port 3306 is listening
  • mysql opens a console and issuing show databases shows the databases

check-mysql-status.rb as un-used database option

The file check-mysql-status.rb contains a command line option for -d database.
However, the database option does not appear to be used in the following code.
If this is by design, that it should not be there I can open a pull request and remove it.
If not and we would like to check the status of a named database, then I can also look at this.

Mysql gem is outdated, won't compile against mysql8

These need to be converted away from the "mysql" gem. It's long-dead. It won't even compile against mysql8-dev.

I'd go for it, but my ruby skills are.. questionable. at best. for now.

Small sample of mysql gem failing to compile:

gem install mysql
Fetching: mysql-2.9.1.gem (100%)
Building native extensions. This could take a while...
ERROR:  Error installing mysql:
	ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.5.0/gems/mysql-2.9.1/ext/mysql_api
/usr/bin/ruby2.5 -r ./siteconf20190413-580-1qljyc4.rb extconf.rb
checking for mysql_ssl_set()... yes
checking for rb_str_set_len()... yes
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
creating Makefile

current directory: /var/lib/gems/2.5.0/gems/mysql-2.9.1/ext/mysql_api
make "DESTDIR=" clean

current directory: /var/lib/gems/2.5.0/gems/mysql-2.9.1/ext/mysql_api
make "DESTDIR="
compiling mysql.c
mysql.c:79:2: error: unknown type name ‘my_bool’
  my_bool *is_null;
  ^~~~~~~
mysql.c: In function ‘options’:
mysql.c:361:5: error: unknown type name ‘my_bool’; did you mean ‘_Bool’?
     my_bool b;
     ^~~~~~~
     _Bool

in `require': cannot load such file -- mysql (LoadError)

Hey Im Getting This Error for some checks.
I read in some websites that the solution is to install mysql2 gem but still didnt helped me.

/opt/sensu/embedded/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in require': cannot load such file -- mysql (LoadError)
from /opt/sensu/embedded/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in require' from /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-mysql-3.1.1/bin/check-mysql-replication-status.rb:33:in '
from /opt/sensu/embedded/bin/check-mysql-replication-status.rb:23:in load' from /opt/sensu/embedded/bin/check-mysql-replication-status.rb:23:in '`

Need to change - "Require 'mysql'" to "Require 'mysql2'" in ruby scripts

check-mysql-connections.rb getting connection error message

Check failed to run: Connection refused - connect(2) for "10.236.220.135" port 3306, ["/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/ruby-mysql-2.9.14/lib/mysql/protocol.rb:153:in initialize'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/ruby-mysql-2.9.14/lib/mysql/protocol.rb:153:in new'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/ruby-mysql-2.9.14/lib/mysql/protocol.rb:153:in block in initialize'", "/opt/sensu/embedded/lib/ruby/2.4.0/timeout.rb:76:in timeout'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/ruby-mysql-2.9.14/lib/mysql/protocol.rb:147:in initialize'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/ruby-mysql-2.9.14/lib/mysql.rb:115:in new'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/ruby-mysql-2.9.14/lib/mysql.rb:115:in connect'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/ruby-mysql-2.9.14/lib/mysql.rb:50:in new'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-mysql-3.1.0/bin/check-mysql-connections.rb:84:in run'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:58:in block in class:CLI'"]

Check failed to run: undefined method `[]' for nil:NilClass

Presentation

Launching an agent to check for mysql health, I get an error I don't know how to solve.

The context

I use Docker images with ruby shared runtime.
According to sensuctl asset list, the check I've created is:

---
type: CheckConfig
api_version: core/v2
metadata:
  created_by: global
  name: mysql_is_alive
  namespace: prod
spec:
  check_hooks: null
  command: check-mysql-alive.rb --ini /checks/my.cnf --ini-section=prod
  env_vars: null
  handlers: []
  high_flap_threshold: 0
  interval: 30
  low_flap_threshold: 0
  output_metric_format: ""
  output_metric_handlers: null
  proxy_entity_name: ""
  publish: true
  round_robin: false
  runtime_assets:
  - sensu-ruby
  - sensu-mysql
  secrets: null
  stdin: false
  subdue: null
  subscriptions:
  - mysql
  timeout: 20
  ttl: 0

The /checks/my.cnf directory is on the host, and shared through a volume into a Docker service.

The error

Here is the output I get from the agent executing the check:

Check failed to run: undefined method `[]' for nil:NilClass, ["/var/lib/sensu/2a68686cce9a58fffd7e384ede7538621a77d5930bba05c3296eb2a3b5f87d7caf20d0405099b2f9c81a5d86da7384b888e387dd84661b52ef23dc56e35431d8/lib/ruby/2.4.0/bundler/gems/sensu-plugins-mysql-a20e9500620b/bin/check-mysql-alive.rb:86:in `run'", "/var/lib/sensu/2a68686cce9a58fffd7e384ede7538621a77d5930bba05c3296eb2a3b5f87d7caf20d0405099b2f9c81a5d86da7384b888e387dd84661b52ef23dc56e35431d8/lib/ruby/2.4.0/gems/sensu-plugin-4.0.0/lib/sensu-plugin/cli.rb:59:in `block in <class:CLI>'"]

Poor documentation

I been going through the plugins and bit confused.

..wish there exists some docs/README

For the following option on check-mysql-disk.rb.. what does the size implies ??
I guess total expected allocated database size, is it ??

option :size,
         short: '-s',
         long: '--size=VALUE',
         description: 'Database size'

Looking for some examples on the plugins.rb files..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.