sensu-plugins / sensu-plugins-mysql

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.
http://sensu-plugins.io
MIT License
18 stars 63 forks source link

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

Open amnkh opened 6 years ago

amnkh commented 6 years ago

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

majormoses commented 6 years ago

Could you please include your full (redacted) check configuration from the screenshot I am not sure which metrics script to look in.

amnkh commented 6 years ago

image_2017-10-31_11-08-21

Dear majormoses, Thanks a lot for your response. This the full test, should I include any content or check codes?

majormoses commented 6 years ago

OK I think I see the confusion you are executing this as a check when this is actually in fact a handler. As this does not match the naming convention which I can't seem to find documented anywhere so I have opened several issues to address the renaming and the documentation of the proper naming convention.

You probably want to look at one of these for mysql metrics gathering:

majormoses commented 6 years ago

@amnkh did that help?