MySQL Monitor Script

Overview

README.md

Introduction

mymon(MySQL-Monitor) 是Open-Falcon用来监控MySQL数据库运行状态的一个插件,采集包括global status, global variables, slave status以及innodb status等MySQL运行状态信息。

Installation

# Build
go get -u github.com/open-falcon/mymon
cd $GOPATH/src/github.com/open-falcon/mymon
make

# Add to crontab
echo '* * * * * cd ${WORKPATH} && ./mymon -c etc/myMon.cfg' > /etc/cron.d/mymon

Configuration

配置文件采用INI标准。

[default]
basedir = . # 工作目录
log_dir = ./fixtures # 日志目录,默认日志文件为myMon.log,旧版本有log_file项,如果同时设置了,会优先采用log_file
ignore_file = ./falconignore # 配置忽略的metric项
snapshot_dir = ./snapshot # 保存快照(process, innodb status)的目录
snapshot_day = 10 # 保存快照的时间(日)
log_level  = 5 #  日志级别[RFC5424]
# 0 LevelEmergency
# 1 LevelAlert
# 2 LevelCritical
# 3 LevelError
# 4 LevelWarning
# 5 LevelNotice
# 6 LevelInformational
# 7 LevelDebug
falcon_client=http://127.0.0.1:1988/v1/push # falcon agent连接地址

[mysql]
user=root # 数据库用户名
password=1tIsB1g3rt # 您的数据库密码
host=127.0.0.1 # 数据库连接地址
port=3306 # 数据库端口

Metric

采集的metric信息,请参考./metrics.txt。该文件仅供参考,实际采集信息会根据MySQL版本、配置的不同而变化。

ignore项

ignore项配置,是用来屏蔽之前在falcon中设好的报警项,会将原有的metric更改名称之后上传,使原有的报警策略不再生效。由于falcon中的屏蔽策略,只能屏蔽endpoint级别,所以在mymon中的ignore功能是帮助提高了报警屏蔽粒度,而非忽略该metric的上报。

同步延迟

关于同步延迟检测的metric有两个: Seconds_Behind_MasterHeartbeats_Behind_Master

Seconds_Behind_Master是MySQLSHOW SLAVE STATUS输出的状态变量。由于低版本的MySQL还不支持HEARTBEAT_EVENT,在低版本的MySQL中该状态可能会由于IO线程假死导致测量不准确,因此mymon增加了Heartbeats_Behind_Master。它依赖于pt-heartbeat,统计基于pt-heartbeat生成的mysql.heartbeat表中的ts字段值与从库当前时间差。如果未配置pt-heartbeat,则该项上报-1值。

关于pt-heartbeat的配置使用,链接如下: https://www.percona.com/doc/percona-toolkit/LATEST/pt-heartbeat.html

Contributors

Comments
  • go get报错,ssdb问题

    go get报错,ssdb问题

    [[email protected]_0_4_centos mymon]# go get ./... src/github.com/ssdb/gossdb/test.go:7:2: local import "./ssdb" in non-local package

    这个是什么问题没看懂,求指导,谢谢

    opened by Ezail3 2
  • go get导致的 panic: runtime error: invalid memory address or nil pointer dereference

    go get导致的 panic: runtime error: invalid memory address or nil pointer dereference

    系统版本 CentOS Linux release 7.2.1511 (Core)

    golang版本 go version go version go1.9.4 linux/amd64

    安装源 yum info golang 已加载插件:fastestmirror Repository epel is listed more than once in the configuration Loading mirror speeds from cached hostfile 已安装的软件包 名称 :golang 架构 :x86_64 版本 :1.9.4 发布 :1.el7 大小 :6.8 M 源 :installed 来自源:base 简介 : The Go Programming Language 网址 :http://golang.org/ 协议 : BSD and Public Domain 描述 : The Go Programming Language.

    $GOPATH 和 $GOROOT 设置

    GOROOT=/usr/lib/golang GOPATH=/opt/golang

    报错信息: 命令执行时路径 /opt/golang/src/github.com/open-falcon/mymon

    [[email protected] mymon]# go get ./... && echo ok

    golang.org/x/sys/unix

    panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x97ca2b]

    goroutine 1 [running]: cmd/compile/internal/gc.dumpasmhdr() /usr/lib/golang/src/cmd/compile/internal/gc/export.go:389 +0x2ab cmd/compile/internal/gc.Main(0xb770d0) /usr/lib/golang/src/cmd/compile/internal/gc/main.go:633 +0x280d main.main() /usr/lib/golang/src/cmd/compile/main.go:49 +0x95 [[email protected] mymon]#

    不明白为什么执行 go get 都会得到一个 panic 错误 请问如何解决呢?

    opened by willre 2
  • 2020/03/12 19:08:14.880 [E] [main.go:88] Error: Received #1227 error from MySQL server:

    2020/03/12 19:08:14.880 [E] [main.go:88] Error: Received #1227 error from MySQL server: "Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation"

    cat myMon.log 2020/03/12 19:08:14.880 [E] [main.go:88] Error: Received #1227 error from MySQL server: "Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation" 2020/03/12 19:11:09.089 [E] [main.go:88] Error: Received #1227 error from MySQL server: "Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation" 2020/03/12 19:21:04.166 [E] [main.go:88] Error: Received #1227 error from MySQL server: "Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation" 2020/03/12 19:21:05.800 [E] [main.go:88] Error: Received #1227 error from MySQL server: "Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation" 2020/03/12 19:21:08.247 [E] [main.go:88] Error: Received #1227 error from MySQL server: "Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation" 2020/03/12 19:26:31.090 [E] [main.go:88] Error: Received #1227 error from MySQL server: "Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation" 2020/03/12 19:56:12.483 [E] [main.go:88] Error: Received #1227 error from MySQL server: "Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation" 2020/03/12 19:56:13.374 [E] [main.go:88] Error: Received #1227 error from MySQL server: "Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation" 2020/03/12 19:56:13.976 [E] [main.go:88] Error: Received #1227 error from MySQL server: "Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation" 2020/03/12 19:56:19.560 [E] [main.go:88] Error: Received #1227 error from MySQL server: "Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation" 2020/03/12 20:02:29.209 [E] [main.go:88] Error: Received #1227 error from MySQL server: "Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation" You have mail in /var/spool/mail/root

    opened by 13691432320 1
  • fix config panic and do not collect binary logs when binary log is disabled

    fix config panic and do not collect binary logs when binary log is disabled

    修复两个bug:

    • 当默认配置文件myMon.cfgetc/myMon.cfg不存在时,直接返回配置文件不错在的报错
    • bin-log没有开启的时候,ShowBinaryLogs方法返回的errr不为nil,导致fetchData方法直接退出,已经收集到的所有信息都不能上报,修复方法是: 先检查bin-log是否启用,如果没有启用就退出,返回nil error #51 @MistShi @UlricQin
    opened by mdh67899 0
  • 修复vendor.json: 添加github.com/go-ini/ini

    修复vendor.json: 添加github.com/go-ini/ini

    vendor.json缺少github.com/go-ini/ini包的配置,执行make命令编二进制包的时候有以下报错:

    Run gofmt on all source files ...
    gofmt -l -s -w ...
    ==> Checking that build is using go version >= 1.10...
    go build -o mymon
    common/config.go:20:2: cannot find package "github.com/go-ini/ini" in any of:
    	/home/mdh67899/go/src/github.com/open-falcon/mymon/vendor/github.com/go-ini/ini (vendor tree)
    	/usr/local/go/src/github.com/go-ini/ini (from $GOROOT)
    	/home/mdh67899/go/src/github.com/go-ini/ini (from $GOPATH)
    Makefile:43: recipe for target 'build' failed
    make: *** [build] Error 1
    

    @UlricQin @MistShi

    opened by mdh67899 0
  • 合并小米内部新增功能更新至社区版

    合并小米内部新增功能更新至社区版

    更新日志

    [version] - 2018-7-25

    本次更新,主要是在代码规范、代码结构及代码测试上的更新,增加了少量必要的监控项。

    Added

    • 新增了项目的单元测试和集成测试,目前整体测试覆盖率在83.3%。
    • 新增了监控项longest_transactionIs_slavebinlog_file_size等。
    • 新增了CHANGES.md文件。
    • 新增了vendor包管理。
    • 新增了源代码文件头Copyright信息。
    • 新增了Makefile文件。

    Fixed

    • 修复了binlogFileSize返回空值的bug 。
    • 修复了当没有mysql.heartbeat表或数据为空时,数组越界报错问题。

    Changed

    • 修改了README.md文件。
    • 修改了NOTICE文件。
    • 修改了日志级别为RFC5424标准的7个日志级别。

    Refactored

    • 整理了文件结构,合并了SHOW相关的监控变量。
    • 抽出了common包,包含数据库配置、日志配置、配置文件以及utils相关代码。
    • 更改了大量变量名、函数名、编码方式、注释,增强可读性并通过gometalinter语法检查。
    • 通过正则重构了falconignore文件解析相关代码。
    • 对部分重复代码进行了抽象重构。
    opened by martianzhang 0
  • 希望能最小化赋权

    希望能最小化赋权

    简单粗暴的root权限,在安全方面不太靠谱,希望能够按照使用到的权限进行赋权,专账号专用。 粗略看了一下源码,主要是show engine和主从相关的查看权限(暂时没看到其他的 按照官网提供的权限表,目前是给了PROCESS和REPLICATION CLIENT权限,可以正常上报一些指标。 PS: 在指标列表里看到了aborted client 之类的指标,在mysql5.7版本中好像是在sys库里,但是在代码里未看到相关的操作。

    opened by woodywuuu 0
Owner
Open-Falcon
An open-source and enterprise-level monitoring system which is designed for modern distributed systems.
Open-Falcon
Kubernetes monitor

模式说明 对应配置项为collect_mode cadvisor_plugin | kubelet_agent | server_side 三选一 代码为同一套代码 模式名称 部署运行方式 collect_mode配置 说明 夜莺插件形式采集cadvisor raw api 可执行的插件由夜莺age

null 42 Nov 18, 2022
Open Source Supreme Monitor Based on GoLang

Open Source Supreme Monitor Based on GoLang A module built for personal use but ended up being worthy to have it open sourced.

SneakyKiwi 18 Nov 4, 2022
Monitor your network and internet speed with Docker & Prometheus

Stand-up a Docker Prometheus stack containing Prometheus, Grafana with blackbox-exporter, and speedtest-exporter to collect and graph home Internet reliability and throughput.

Jeff Geerling 1.2k Dec 26, 2022
SigNoz helps developer monitor applications and troubleshoot problems in their deployed applications

SigNoz helps developers monitor their applications & troubleshoot problems, an open-source alternative to DataDog, NewRelic, etc. ?? ??

SigNoz 10.8k Dec 27, 2022
Gowl is a process management and process monitoring tool at once. An infinite worker pool gives you the ability to control the pool and processes and monitor their status.

Gowl is a process management and process monitoring tool at once. An infinite worker pool gives you the ability to control the pool and processes and monitor their status.

Hamed Yousefi 40 Nov 10, 2022
Hidra is a tool to monitor all of your services without making a mess.

hidra Don't lose your mind monitoring your services. Hidra lends you its head. ICMP If you want to use ICMP scenario, you should activate on your syst

null 8 Nov 8, 2022
SigNoz helps developers monitor their applications & troubleshoot problems, an open-source alternative to DataDog, NewRelic, etc. 🔥 🖥. 👉 Open source Application Performance Monitoring (APM) & Observability tool

Monitor your applications and troubleshoot problems in your deployed applications, an open-source alternative to DataDog, New Relic, etc. Documentatio

SigNoz 4.7k Sep 24, 2021
Go Huobi Market Price Data Monitor

火币(Huobi)价格监控 由于部分交易对火币官方未提供价格监控,因此写了个小程序,长期屯币党可以用它来提醒各种现货价格。 该工具只需要提前安装Go环境和Redis即可。 消息推送使用的「钉钉」,需要提前配置好钉钉机器人(企业群类型、带webhook的机器人)。 使用方法 下载本项目 拷贝根目录下

ROC 6 Oct 13, 2022
Productivity analytics monitor 🧮

Productivity analytics monitor ??

John Forstmeier 0 Oct 8, 2021
Cloudprober is a monitoring software that makes it super-easy to monitor availability and performance of various components of your system.

Cloudprober is a monitoring software that makes it super-easy to monitor availability and performance of various components of your system. Cloudprobe

null 242 Dec 30, 2022
Monitor a process and trigger a notification.

noti Monitor a process and trigger a notification. Never sit and wait for some long-running process to finish. Noti can alert you when it's done. You

Jaime Piña 4k Jan 3, 2023
Monitor the performance of your Ethereum 2.0 staking pool.

eth-pools-metrics Monitor the performance of your Ethereum 2.0 staking pool. Just input the withdrawal credentials that were used in the deposit contr

Alvaro 27 Dec 30, 2022
Gomon - Go language based system monitor

Copyright © 2021 The Gomon Project. Welcome to Gomon, the Go language based system monitor Welcome to Gomon, the Go language based system monitor Over

zosmac 3 Nov 18, 2022
Monitor & detect crashes in your Kubernetes(K8s) cluster

kwatch kwatch helps you monitor all changes in your Kubernetes(K8s) cluster, detects crashes in your running apps in realtime, and publishes notificat

Abdelrahman Ahmed 707 Dec 28, 2022
Fast, zero config web endpoint change monitor

web monitor fast, zero config web endpoint change monitor. for comparing responses, a selected list of http headers and the full response body is stor

Robin Verton 39 Nov 17, 2022
Monitor pipe progress via output to standard error.

Pipe Monitor Monitor pipe progress via output to standard error. Similar to functionality provided by the Pipe Viewer (pv) command, except this comman

SoftCoil Development 6 Nov 14, 2022
Go-mysql-orm - Golang mysql orm,dedicated to easy use of mysql

golang mysql orm 个人学习项目, 一个易于使用的mysql-orm mapping struct to mysql table golang结构

magacy 164 Jan 7, 2023
Andrews-monitor - A Go program to monitor when times were available to order for Brown's Andrews dining hall. Used during the portion of the pandemic when the dining hall was only available for online order.

Andrews Dining Hall Monitor A Go program to monitor when times were available to order for Brown's Andrews dining hall. Used during the portion of the

null 0 Jan 1, 2022
Go web monitor - A web monitor with golang

Step Download “go installer” and install on your machine. Open VPN. Go to “web-m

null 0 Jan 6, 2022
Go MySQL Driver is a MySQL driver for Go's (golang) database/sql package

Go-MySQL-Driver A MySQL-Driver for Go's database/sql package Features Requirements Installation Usage DSN (Data Source Name) Password Protocol Address

Go SQL Drivers 12.9k Jan 4, 2023