美文网首页
open-falcon 监控MySQL及自定义监控指标

open-falcon 监控MySQL及自定义监控指标

作者: 偏执的工匠 | 来源:发表于2018-06-07 21:09 被阅读0次

1. open-falcon安装

参考官方帮助文档,【二进制快速安装】一节,文档讲的很详细,这里不再赘述。
http://book.open-falcon.org/zh/quick_install/prepare.html
注意在CentOS7上可能出现dashboard主页无法出图的情况,可参考如下链接解决:
https://www.jianshu.com/p/facee956085f

2. 监控MySQL

MySQL的监控完全可以自己写程序采集,然后调用open-falcon agent提供的上报接口进行上报。然而网上已经有开源的MySQL监控脚本,直接拿来使用即可。如果想增加一些自定义监控项,可以考虑在开源代码的基础上进行修改,或者干脆自己写个上报程序。

基于open-falcon的开源MySQL监控程序源码地址:

# 安装go语言开发环境,此处略去

git clone https://github.com/open-falcon/mymon.git

cd mymon
go get ./...
go build -o mymon

# 后台运行
./mymon -c ./etc/mon.cfg &

在上面执行 go get ./...时,由于网络问题,部分依赖包无法自动下载,只能手动去github下载到$GOPATH目录:

git clone https://github.com/golang/crypto.git
git clone https://github.com/akrennmair/goconf.git
git clone https://github.com/sirupsen/logrus.git
git clone https://github.com/ziutek/mymysql.git
git clone https://github.com/golang/net.git
git clone https://github.com/golang/sys.git
git clone https://github.com/golang/tools.git

mymon每调用一次就向agent上报一次mysql采集到的数据,可以写个定时任务,每隔30秒运行一次,采集一次数据。效果图如下:


image.png image.png

3. 添加自定义监控指标

编写Python脚本,上报自定义监控指标。以下示例代码每隔60秒,上报一次 my-count 指标数据。

#!/usr/bin/env python
#!-*- coding:utf8 -*-

import requests
import time
import json
import random
import os

while True:
    time.sleep(60)
    info_list = []
    ts = int(time.time())
    print ts
    endpoint = os.popen('echo $HOSTNAME').read().strip()
    value = random.randint(1,100)
    dict_info= {
        "endpoint": endpoint,
        "metric": "my-count",
        "timestamp": ts,
        "step": 60,
        "value":value ,
        "counterType": "GAUGE",
        "tags": "my-tag",
    }
    info_list .append(dict_info)
    requests.post("http://127.0.0.1:1988/v1/push", data=json.dumps(info_list ))

在dashboard页面上查看自定义监控指标上报成功,如图:


image.png
image.png

相关文章

  • open-falcon 监控MySQL及自定义监控指标

    1. open-falcon安装 参考官方帮助文档,【二进制快速安装】一节,文档讲的很详细,这里不再赘述。http...

  • open-falcon监控指标

    1. jmx参数监控指标 通过jmx采集java进程的jvm信息,包括gc耗时、gc次数、gc吞吐、老年代使用率、...

  • 监控系统

    整体页面 需求 监控现状:基于open-falcon部署的哗啦啦监控系统,支持基础监控(io、cpu、mem等监控...

  • ZABBIX监控Mysql数据库实战

    一、Zabbix自定义Key监控Mysql Mysql的基础监控Zabbix Agent的安装进程存活检测端口 M...

  • 运维监控系统之Open-Falcon

    运维监控系统之Open-Falcon 一、Open-Falcon介绍 open-falcon是一款用golang和...

  • 第10章 Kubernetes集群资源监控

    一. Kubernetes监控指标与监控方案 1.Kubernetes监控指标 (1).集群监控 • 节点资源利用...

  • 监控笔记

    监控分类 系统 业务 监控方法 探针(probing) 内省(introspection) 监控指标 指标设计方法...

  • mysql 常用监控指标

    mysql 常用监控指标 TPS/QPS mysql.tps (Per Second) 平均每秒SQL语句执行次数...

  • Mysql-管理及监控类问题

    问题一: 对 mysql 那些指标进行监控 功能性image 问题二: 这些监控是如何来实现的 QPS:image...

  • 性能测试必备监控技能MySQL篇15

    前言 性能测试过程中,数据库相关指标的监控是不可忽视的,在这里我们就MySQL的监控配置及重点涉及性能的一些参数进...

网友评论

      本文标题:open-falcon 监控MySQL及自定义监控指标

      本文链接:https://www.haomeiwen.com/subject/ucagsftx.html