Merge lp:~revin/percona-monitoring-plugins/zabbix-running-slave into lp:percona-monitoring-plugins

Proposed by Jervin R
Status: Needs review
Proposed branch: lp:~revin/percona-monitoring-plugins/zabbix-running-slave
Merge into: lp:percona-monitoring-plugins
Diff against target: 44 lines (+24/-1)
1 file modified
zabbix/scripts/get_mysql_stats_wrapper.sh (+24/-1)
To merge this branch: bzr merge lp:~revin/percona-monitoring-plugins/zabbix-running-slave
Reviewer Review Type Date Requested Status
Percona Toolkit developers Pending
Review via email: mp+238069@code.launchpad.net

Description of the change

By default the Zabbix wrapper get_mysql_stats_wrapper.sh checks a slave blindly even if a node is not supposed to be a slave. You can workaround this by stacking the templates from Zabbix and disabling the slave checks for non-slaves, however this does not work for HA like PRM where solave roles can move. I've added support for indicating node role into a file /etc/zabbix_agentd.conf.d/PERCONA_NODE_TYPE (master|prm|or empty/no file). For 'prm' it will consult crm_mon, for master, it will simply return a successful value.

To post a comment you must log in.

Unmerged revisions

181. By Jervin R

Changed return to 0 when crm_mon fails

180. By Jervin R

Better slave-running monitoring with known node types

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'zabbix/scripts/get_mysql_stats_wrapper.sh'
2--- zabbix/scripts/get_mysql_stats_wrapper.sh 2014-07-11 12:26:49 +0000
3+++ zabbix/scripts/get_mysql_stats_wrapper.sh 2014-10-12 06:36:14 +0000
4@@ -6,16 +6,39 @@
5 # This program is part of $PROJECT_NAME$
6 # License: GPL License (see COPYING)
7 # Copyright: $CURRENT_YEAR$ Percona
8-# Authors: Roman Vynar
9+# Authors: Roman Vynar, Jervin Real
10
11 ITEM=$1
12 HOST=localhost
13 DIR=`dirname $0`
14 CMD="/usr/bin/php -q $DIR/ss_get_mysql_stats.php --host $HOST --items gg"
15 CACHEFILE="/tmp/$HOST-mysql_cacti_stats.txt"
16+ME=$(uname -n)
17+NODE_TYPE_FILE=/etc/zabbix_agentd.conf.d/PERCONA_NODE_TYPE
18
19 if [ "$ITEM" = "running-slave" ]; then
20 # Check for running slave
21+ if [ -f $NODE_TYPE_FILE ]; then
22+ TYPE=$(cat $NODE_TYPE_FILE)
23+ if [ "$TYPE" == "prm" ]; then
24+ # We check the command first and see if
25+ # it has no issues, if there's an error
26+ # we return 0 since cannot check
27+ /usr/sbin/crm_mon -A1 > /dev/null 2>&1
28+ if [ "$?" -ne "0" ]; then echo 0; exit; fi
29+ # Then we check if our node is a slave
30+ # If its not marked as slave, we return 1
31+ /usr/sbin/crm_mon -A1 | egrep "Slave.*${ME}" > /dev/null 2>&1
32+ if [ "$?" -ne "0" ]; then
33+ echo 1
34+ exit
35+ fi
36+ elif [ "$TYPE" == "master" ]; then
37+ echo 1
38+ exit
39+ fi
40+ fi
41+
42 RES=`HOME=~zabbix mysql -e 'SHOW SLAVE STATUS\G' | egrep '(Slave_IO_Running|Slave_SQL_Running):' | awk -F: '{print $2}' | tr '\n' ','`
43 if [ "$RES" = " Yes, Yes," ]; then
44 echo 1

Subscribers

People subscribed via source and target branches