Ganglia监控MySQL-Metrics

什么时候应该增加服务器

...名与密码都是 具体下载目录在 /2014年资料/4月/25日/Ganglia监控MySQL 下载方法见 2、修改脚本中的msyql用户名和密码 3、该脚本54和58号行机器不同需要进行修改(未查明原因),可以在$[ ]和$(())间...

1、下载mysql监控脚本: gmetric-mysql.sh 免费下载地址在 http://linux.linuxidc.com/ 用户名与密码都是www.linuxidc.com 具体下

1、下载mysql监控脚本: gmetric-mysql.sh

免费下载地址在

用户名与密码都是

具体下载目录在 /2014年资料/4月/25日/Ganglia监控MySQL

下载方法见



2、修改脚本中的msyql用户名和密码

3、该脚本54和58号行机器不同需要进行修改(未查明原因),可以在$[ ]和$(())间替换。 我的修改成DELTA_VALUE=$[ NEW_VALUE-PREVIOUS_VALUE ]、DELTA_TIMESTAMP=$[ NEW_TIMESTAMP-PREVIOUS_TIMESTAMP ]就好了。去掉了[]中的$

4、在crond执行该脚本

5、重启gmetad

附gmetric-mysql.sh
[root@node1 192.168.228.156]# cat /etc/ganglia/gmetric-mysql.sh
#! /bin/bash
#
# Get statistics from MySQL and feed them into Ganglia for monitoring.
#
# To use, simply adjust the path to gmetric and mysql credentials as appropriate.
#
# Author: David Winterbottom (david.winterbottom@gmail.com)
# Site:

# Config
declare -r GMETRIC=/usr/bin/gmetric
declare -r NEW_DATA_FILE=/tmp/mysql-stats.new
declare -r OLD_DATA_FILE=/tmp/mysql-stats.old
declare -r MYSQL_USER="root"
declare -r MYSQL_PASSWORD="123456"

# Sanity checks
if test -z "$GMETRIC" ; then
printf "The command $GMETRIC is not available";
exit 192
fi

# Function for submiting metrics
function record_value
{
if [ $# -lt 1 ]; then
printf "You must specify a look-up value\n"
exit 192
fi
LOOKUP_VAR=$1
GANGLIA_NAME=${2-unspecified}
GANGLIA_TYPE=${3-float}
GANGLIA_UNITS=${4-units}
GANGLIA_VALUE=`grep "$LOOKUP_VAR[^_]" "$NEW_DATA_FILE" | awk '{print $2}'`
printf " * $GANGLIA_NAME: $GANGLIA_VALUE\n"
$GMETRIC --type "$GANGLIA_TYPE" --name "$GANGLIA_NAME" --value $GANGLIA_VALUE --unit "$GANGLIA_UNITS"
}

# Function for submitting delta metrics
function record_value_rate
{
if [ $# -lt 1 ]; then
printf "You must specify a look-up value\n"
exit 192
fi
MYSQL_VAR=$1
GANGLIA_NAME=${2-unspecified}
GANGLIA_TYPE=${3-float}
GANGLIA_UNITS=${4-"per second"}

# Get values from old and new files
PREVIOUS_VALUE=`grep "$MYSQL_VAR[^_]" "$OLD_DATA_FILE" | awk '{print $2}'`
NEW_VALUE=`grep "$MYSQL_VAR[^_]" "$NEW_DATA_FILE" | awk '{print $2}'`
# DELTA_VALUE=$[ $NEW_VALUE-$PREVIOUS_VALUE ]
DELTA_VALUE=$[ NEW_VALUE-PREVIOUS_VALUE ]
# DELTA_TIMESTAMP=$[ NEW_TIMESTAMP-PREVIOUS_TIMESTAMP ]
PREVIOUS_TIMESTAMP=`date -r "$OLD_DATA_FILE" +%s`
NEW_TIMESTAMP=`date -r "$NEW_DATA_FILE" +%s`
# DELTA_TIMESTAMP=$[ $NEW_TIMESTAMP-$PREVIOUS_TIMESTAMP ]
DELTA_TIMESTAMP=$[ NEW_TIMESTAMP-PREVIOUS_TIMESTAMP ]
if [ $DELTA_VALUE -lt 0 ] || [ $DELTA_TIMESTAMP -lt 0 ]; then
# Something strange here - MYSQL may just have started. Ignore for now
printf "Weird data value - skipping\n"
else
# Need to pipe to bc to perform floating point operations
DELTA_RATE=`echo "scale=4; $DELTA_VALUE/$DELTA_TIMESTAMP" | bc -l`
printf " * $GANGLIA_NAME -- Previous value: $PREVIOUS_VALUE, new value: $NEW_VALUE, delta: $DELTA_VALUE, previous timestamp: $PREVIOUS_TIMESTAMP, new timestamp: $NEW_TIMESTAMP, delta: $DELTA_TIMESTAMP, $DELTA_RATE per second\n"
$GMETRIC --type "$GANGLIA_TYPE" --name "$GANGLIA_NAME" --value $DELTA_VALUE --unit "$GANGLIA_UNITS"
fi
}

# Read MySQL statistics into a temporary file
mysql --user=$MYSQL_USER --password=$MYSQL_PASSWORD --execute "SHOW GLOBAL STATUS" > "$NEW_DATA_FILE"

# Submit metrics
record_value_rate "Connections" "MYSQL_CONNECTIONS" "float" "Connections/sec"
record_value_rate "Com_update" "MYSQL_UPDATE_QUERIES" "float" "Queries/sec"
record_value_rate "Com_select" "MYSQL_SELECT_QUERIES" "float" "Queries/sec"
record_value_rate "Com_insert" "MYSQL_INSERT_QUERIES" "float" "Queries/sec"
record_value_rate "Com_delete" "MYSQL_DELETE_QUERIES" "float" "Queries/sec"
record_value_rate "Created_tmp_tables" "MYSQL_CREATED_TMP_TABLES" "float" "Tables created/sec"
record_value_rate "Slow_queries" "MYSQL_SLOW_QUERIES" "float" "Queries/sec"
record_value_rate "Qcache_hits" "MYSQL_QUERY_CACHE_HITS" "float" "Hits/sec"
record_value "Qcache_queries_in_cache" "MYSQL_QUERIES_IN_CACHE" "float" "Queries"
record_value_rate "Questions" "MYSQL_QUESTIONS" "float" "Questions/sec"
record_value_rate "Threads_connected" "MYSQL_THREADS_CONNECTED" "float" "Threads connected/sec"
record_value "Threads_running" "MYSQL_THREADS_RUNNING" "float" "Threads running"

# Copy data
cp "$NEW_DATA_FILE" "$OLD_DATA_FILE"

6、监控效果:

相关阅读:

Ganglia 3.1.x下扩展Python模块(翻译自官方wiki)

使用Ganglia监控Hadoop集群

在VMware Workstation的Ubuntu下安装和配置Hadoop与Ganglia

Ganglia安装部署之一建立Grid

Ganglia 极其简单安装教程yum版

Ganglia快速开始向导(翻译自官方wiki)

CentOS集群上安装Ganglia-3.6.0监控Hadoop-2.2.0和HBase-0.96.0

本文永久更新链接地址:

Ganglia监控MySQL

...名与密码都是 具体下载目录在 /2014年资料/4月/25日/Ganglia监控MySQL 下载方法见 2、修改脚本中的msyql用户名和密码 3、该脚本54和58号行机器不同需要进行修改(未查明原因),可以在$[ ]和$(())间...

将RRD数据库中数据导入MYSQL中_MySQL

...示图等。RRDTOOL同时也提供了很多语言的API以方便操作。 Ganglia是一个分布式的监控系统,采用RRD数据库进行数据存储和可视化。Hadoop源码包里即有一个与ganglia相关的配置文件,修改一些参数和对ganglia进行一些设置即可对hadoop集...

有人用过ganglia吗解决办法

有人用过ganglia吗[img=http://124.127.116.37/ganglia_web5/graph.php?g=load_report&z=medium&c=unspecified&m=load_one&r=hour&s=descending&hc=4&mc=2&st=1263181

有人用过ganglia吗解决办法

有人用过ganglia吗[img=http://124.127.116.37/ganglia_web5/graph.php?g=load_report&z=medium&c=unspecified&m=load_one&r=hour&s=descending&hc=4&mc=2&st=1263181

有人用过ganglia吗解决方案

有人用过ganglia吗如果我要修改图片的标题,“unspecified cluster ”,应该在哪个文件修改?没多少分,大家帮帮忙。。。------解决方案-------------------- 搜一下就知道了

有人用过ganglia吗解决方案

有人用过ganglia吗如果我要修改图片的标题,“unspecified cluster ”,应该在哪个文件修改?没多少分,大家帮帮忙。。。------解决方案--------------------搜一下就知道了

HBase:迁移到新的监测系统Metrics2

...本,HBase就开始使用Hadoop的metrics系统导出监测信息到JMX、Ganglia或其他监测接收器。随着HBase的监测系统功能不断增长,Hadoop开发者们开发了一个叫做Metrics2的新Metrics系统。当Metrics2完成后,就会废弃Metrics1。现在是时候更新H

MySQL多IDC部署注意事项

...,并且每个IDC的监控系统都能独立工作,可以参考zabbix,ganglia(两个开源企业级监控系统)

Announcement: MySQL Performance Monitoring in SPM_MySQL

...together in an uneasy coexistence that is often far from seamless. Think Ganglia+Nagios. SPM takes all that hassle away and makes it easy and c

推荐10个监控脚本的实例教程

...唯一标识当日数据库表空间的id构造tbs7. Ganglia监控MySQL简介:1、下载mysql监控脚本: gmetric-mysql.sh 免费下载地址在 http://linux.linuxidc.com/ 用户名与密码都是www.linuxidc.com 具体下