Zabbixã ã¨æ¨æºã§Template_App_MySQLã¨ãããã³ãã¬ã¼ããå ¥ã£ã¦ããã®ã§ãããæ®å¿µãªããzabbix-agentdå´ã«å¯¾å¿ããUserParametersãè¨å®ããã¦ããªãã¨ä½¿ãã¾ããã
TMTOWTDI(æ£è§£ã¯ã²ã¨ã¤ãããªã)ã¨ããPerlã®æ¨èªã®ã¨ãããèªåã®ããæ¹ã§UserParametersãè¨å®ããã°è¯ãã®ã§ãããåã£æããã¨ãã¦èªåã®ããæ¹ãç´¹ä»ãã¾ãã
MySQLã«æ¥ç¶ã§ããããã«ããï¼MySQLã¦ã¼ã¶ã®æºåï¼
Debian/Ubuntuã§ã¯ã管çç³»ã®ãã¼ã«ã§å ±éã«ä½¿ãããdebian-sys-maintãã¨ããMySQLã¦ã¼ã¶ãç¨æããã¦ããã®ã§ããã使ãã¾ãããã®ã¦ã¼ã¶ã®æ å ±ã¯ã/etc/mysql/debian.cnf ã«rootã ããèªããç¶æ ã§ç¨æããã¦ãã¾ãã
RedHat/CentOSã§ã¯ããããã®ã¯ç¡ãã®ã§ãèªåã§ã¦ã¼ã¶ãä½ããrootã¦ã¼ã¶ã使ã£ã¦ä¸ããã以ä¸ã§ã¯debian-sys-maintã¦ã¼ã¶ãããåæã§é²ãã¾ãã
zabbix-agentdã¯zabbixã¦ã¼ã¶ã§åä½ãããã/etc/mysql/debian.cnfã¨ã¯å¥ã«ãzabbixã¦ã¼ã¶ãèªãããã¡ã¤ã«ãä½æãã¾ããã©ãã§ãè¯ãã§ãããzabbixã¦ã¼ã¶ã®ãã¼ã ãã£ã¬ã¯ããªï¼ãã®è¨äºã§ã¯ /opt/zabbix ï¼ã使ãã¾ãã
% sudo cp /etc/mysql/debian.cnf /opt/zabbix/.my.cnf % sudo chown root:zabbix /opt/zabbix/.my.cnf % sudo chmod 640 /opt/zabbix/.my.cnf
UserParameterãæ¸ããè¨å®ãã¡ã¤ã«ãç¨æãã
ã¡ã¤ã³ã®è¨å®ãã¡ã¤ã«zabbix-agend.confã«ãã®ã¾ã¾UserParameterã追è¨ãã¦ãè¯ãã®ã§ãããåãã¦ããã®ã好ããªã®ã§Include ãã£ã¬ã¯ãã£ãã§èªã¾ããå¥ãã£ã¬ã¯ããªã«ãæ°ããè¨å®ãã¡ã¤ã«ãç¨æãã¾ããããã§ã¯ã/opt/zabbix/agent_include/userparameter_mysql.conf ã¨ãã¾ãã
ãããªæãã§æ¸ãã¾ãã
UserParameter=mysql.status[*],mysqladmin --defaults-extra-file=/opt/zabbix/.my.cnf extended-status 2>/dev/null | awk '/ $1 /{print $$4}' UserParameter=mysql.ping,mysqladmin --defaults-extra-file=/opt/zabbix/.my.cnf ping | grep alive | wc -l UserParameter=mysql.version,mysqladmin -V UserParameter=mysql.slave[*],mysql --defaults-extra-file=/opt/zabbix/.my.cnf -e "show slave status\G" | perl -ne 'print $$1 if /$1:\s*(.*)$/' | sed s/Yes/1/ | sed s/No/0/
å¤ãåããã確èªããã
Zabbixãµã¼ããåãã¦ããã¹ãã§ãzabbix_getã³ãã³ãã§åä½ã確èªãã¾ãã
% zabbix_get -s ï¼å¯¾è±¡ã®ãã¹ãåï¼ -k 'mysql.ping' 1 % zabbix_get -s ï¼å¯¾è±¡ã®ãã¹ãåï¼ -k 'mysql.version' mysqladmin Ver 8.42 Distrib 5.5.29, for debian-linux-gnu on x86_64 % zabbix_get -s ï¼å¯¾è±¡ã®ãã¹ãåï¼ -k 'mysql.status[Uptime]' 241382 % zabbix_get -s ï¼å¯¾è±¡ã®ãã¹ãåï¼ -k 'mysql.slave[Slave_IO_State]' Waiting for master to send event
ãããªæãã§å¤ãåããã°å¤§ä¸å¤«ã§ãã*1
ãã³ãã¬ã¼ããç´ä»ãã
ãã¨ã¯ãZabbixã®ç®¡çç»é¢ã§Template_App_MySQLãã³ãã¬ã¼ãã«ç´ä»ãã¦ãã°ããå¾ ã¤ã ãã§ãã
ã¹ã¬ã¼ããµã¼ãã®ãã³ãã¬ã¼ã(ãã¾ã)
å®ã¯ä¸è¨ã«å«ã¾ãã mysql.slave[*] ã¯æ¨æºã® Template_App_MySQL ãã³ãã¬ã¼ãã§ã¯è¨å®ããã¦ããªãã®ã§ãæå ã§ä½¿ã£ã¦ããã¹ã¬ã¼ããµã¼ãç¨ãã³ãã¬ã¼ã Template_App_MySQL_Slave ãå ¬éãã¦ããã¾ãã
IO/SQLã¹ã¬ãããæ¢ã¾ã£ããæãããªã¬ã¼ãå ¥ã£ã¦ã¾ãã
Chefã¯ãã¯ããã¯(ãã¾ã)
ä¸è¨ããã£ã¦ãããChefã¯ãã¯ããã¯ãç½®ãã¨ãã¾ãã
opscode-cookbook/mysql ã使ã£ã¦ãã人ã§ããã°ãnode.mysql.server_debian_password ããã®ã¾ã¾ä½¿ãããã«ããã®ã§ ãinclude_recipe 'zabbix::agent_mysql'ãããã ãã§ããã§ãã
2013-05-01 追å
PullRequestæãã¾ããã
*1:å½ç¶ãªãã mysql.slave ã¯ã¬ããªã±ã¼ã·ã§ã³ã®ã¹ã¬ã¼ããµã¼ãã§ã®ã¿åãã¾ãã