Zabbix MySQL Percona Monitoring Plugins – many servers monitored with one plugin
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 server, e.g. zabbix-mysql.php-server.your-network.
Next, you put there this PHP script:
# VirtualHost: zabbix-mysql.php-server.your-network
<?PHP
// Error_reporting(E_ALL); ini_set ( "error_reporting" , E_ALL); ini_set ( "display_errors" , 1);
$Option=key($_GET);
$Host=$_GET['host'];
$User="ZABBIX";
$Password="************";
// Args order: items host user pass
$cmd="/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh $Option $Host $User $Password";
passthru("$cmd", $exit_code);
// echo "exit code: $exit_code";
exit();
Get the following content and save it as /tmp/percona.patch.
--- /tmp/get_mysql_stats_wrapper.sh 2014-07-21 12:02:09.000000000 +0200
+++ /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh 2015-01-09 15:34:31.151424576 +0100
@@ -9,9 +9,11 @@
# Authors: Roman Vynar
ITEM=$1
-HOST=localhost
+HOST=$2
+USER=$3
+PASS=$4
DIR=`dirname $0`
-CMD="/usr/bin/php -q $DIR/ss_get_mysql_stats.php --host $HOST --items gg"
+CMD="/usr/bin/php -q $DIR/ss_get_mysql_stats.php --host $HOST --items gg --user $USER --pass $PASS"
CACHEFILE="/tmp/$HOST-mysql_cacti_stats.txt"
if [ "$ITEM" = "running-slave" ]; then
Make patch with diff file and replace original wrapper:
patch /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
mv /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper-old.sh
mv /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper-new.sh /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh
On the database node you have to extract file userparameter_percona_mysql.conf and change
sed -i 's/\(^.*,\)\(.*\s\)\(.*\)/\1 wget -qO - "zabbix-mysql.php-server.your-network?\3\&host=db-mysql.your-network"/g' ./userparameter_percona_mysql.conf
Restart zabbix service on the database node and add “Percona MySQL Server Template” to your node on Zabbix server.
End.
No comments yet.