{"id":943,"date":"2015-01-16T11:27:01","date_gmt":"2015-01-16T11:27:01","guid":{"rendered":"http:\/\/10sa.com\/sql_stories\/?p=943"},"modified":"2015-01-16T11:27:01","modified_gmt":"2015-01-16T11:27:01","slug":"zabbix-mysql-percona-monitoring-plugins-many-servers-monitored-with-one-plugin","status":"publish","type":"post","link":"http:\/\/10sa.com\/sql_stories\/?p=943","title":{"rendered":"Zabbix MySQL Percona Monitoring Plugins &#8211; many servers monitored with one plugin"},"content":{"rendered":"<p>My aim was to avoid installation of any additional software on database servers (PHP). Simultaneously, a plugin for monitoring Mysql server, I needed to install, required PHP.<br \/>\nIn order to meet my needs I decided modify a bit the <a href=\"http:\/\/www.percona.com\/doc\/percona-monitoring-plugins\/1.1\/#\" title=\"Percona plugin\">Percona plugin<\/a> and get the data through http.<\/p>\n<p>You need some http server, then configure virtual server, e.g. zabbix-mysql.php-server.your-network.<br \/>\nNext, you put there this PHP script:<\/p>\n<pre lang=php>\r\n# VirtualHost: zabbix-mysql.php-server.your-network\r\n&lt;?PHP\r\n\/\/ Error_reporting(E_ALL); ini_set ( \"error_reporting\" , E_ALL); ini_set ( \"display_errors\"  , 1);\r\n$Option=key($_GET);\r\n$Host=$_GET['host'];\r\n$User=\"ZABBIX\";\r\n$Password=\"************\";\r\n\r\n\/\/ Args order: items host user pass\r\n$cmd=\"\/var\/lib\/zabbix\/percona\/scripts\/get_mysql_stats_wrapper.sh $Option $Host $User $Password\";\r\npassthru(\"$cmd\", $exit_code);\r\n\/\/ echo \"exit code: $exit_code\";\r\nexit();\r\n<\/pre>\n<p>Get the following content and save it as \/tmp\/percona.patch.<\/p>\n<pre lang=bash>\r\n--- \/tmp\/get_mysql_stats_wrapper.sh     2014-07-21 12:02:09.000000000 +0200\r\n+++ \/var\/lib\/zabbix\/percona\/scripts\/get_mysql_stats_wrapper.sh  2015-01-09 15:34:31.151424576 +0100\r\n@@ -9,9 +9,11 @@\r\n # Authors: Roman Vynar\r\n\r\n ITEM=$1\r\n-HOST=localhost\r\n+HOST=$2\r\n+USER=$3\r\n+PASS=$4\r\n DIR=`dirname $0`\r\n-CMD=\"\/usr\/bin\/php -q $DIR\/ss_get_mysql_stats.php --host $HOST --items gg\"\r\n+CMD=\"\/usr\/bin\/php -q $DIR\/ss_get_mysql_stats.php --host $HOST --items gg --user $USER --pass $PASS\"\r\n CACHEFILE=\"\/tmp\/$HOST-mysql_cacti_stats.txt\"\r\n\r\n if [ \"$ITEM\" = \"running-slave\" ]; then\r\n<\/pre>\n<p>Make patch with diff file and replace original wrapper:<\/p>\n<pre lang=bash>\r\npatch \/var\/lib\/zabbix\/percona\/scripts\/get_mysql_stats_wrapper.sh -i \/tmp\/percona.patch -o \/var\/lib\/zabbix\/percona\/scripts\/get_mysql_stats_wrapper-new.sh\r\nmv \/var\/lib\/zabbix\/percona\/scripts\/get_mysql_stats_wrapper.sh \/var\/lib\/zabbix\/percona\/scripts\/get_mysql_stats_wrapper-old.sh\r\nmv \/var\/lib\/zabbix\/percona\/scripts\/get_mysql_stats_wrapper-new.sh \/var\/lib\/zabbix\/percona\/scripts\/get_mysql_stats_wrapper.sh\r\n<\/pre>\n<p>On the database node you have to extract file userparameter_percona_mysql.conf and change <\/p>\n<pre lang=bash>\r\nsed -i 's\/\\(^.*,\\)\\(.*\\s\\)\\(.*\\)\/\\1 wget -qO - \"zabbix-mysql.php-server.your-network?\\3\\&host=db-mysql.your-network\"\/g' .\/userparameter_percona_mysql.conf\r\n<\/pre>\n<p>Restart zabbix service on the database node and add &#8220;Percona MySQL Server Template&#8221; to your node on Zabbix server.<br \/>\nEnd.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My aim was to avoid installation of any additional software on database servers (PHP). Simultaneously, a plugin for monitoring Mysql server, I needed to install, required PHP. In order to meet my needs I decided modify a bit the Percona plugin and get the data through http. You need some http server, then configure virtual [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/posts\/943"}],"collection":[{"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=943"}],"version-history":[{"count":19,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/posts\/943\/revisions"}],"predecessor-version":[{"id":963,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/posts\/943\/revisions\/963"}],"wp:attachment":[{"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=943"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}