基于 Njmon + InfluxDB + Grafana 实现性能指标实时可视监控

引言

最近逛 nmon 官 时,发现了一个新工具 njmon,功能与 nmon 类似,但输出为 JSON 格式,可以用于服务器性能统计。

可以使用 njmon 来向 InfluxDB 存储服务器性能统计数据,再通过 Grafana 实时读取展示,来实现性能测试过程中的实时可视化监控服务器性能指标的目的。

当然,传统的 nmon、InfluxDB+Grafana+Jmeter等都可以实现。

验证环境

CentOS Linux release 7.6.1810 (Core)

整体架构

原图链接:
http://nmon.sourceforge.net/docs/nmon_outline_800.png

InfluxDB

InfluxDB 是一个由 InfluxData 开发的开源时序型数据。它由 Go 写成,着力于高性能地查询与存储时序型数据。InfluxDB 被广泛应用于存储系统的监控数据,IoT 行业的实时数据等场景。

InfluxDB 的语法是类 SQL 的,增删改查与 mysql 相同。InfluxDB 中的 measurement 对应的关系型数据库中的 table 。默认端口是 8086。

安装 & 启动

官方教程:
https://docs.influxdata.com/influxdb/v1.7/introduction/installation/

配置 InfluxDB 的 yum 源:


yum 安装


创建 njmon 库


启用用户认证

添加用户,设置权限。


InfluxDB 默认是禁用认证策略的。


njmon

njmon = nmon + JSON format + real-time push to a stats database + instant graphing of “all the stats you can eat” (AIX and Linux)

This njmon is a major overhaul of nmon for the next 10 years:

– Load more stats

– JSON format is self documenting, flexible and the performance stats format for many new tools

– Direct real-time loading of the JSON into modern open source time aware databases

– New age browser based graphing tools allow dynamic data choice and graph style per VM, per server or across the estateAll this will be covered and more including many demo’s.

与 nmon 类似,但输出为 JSON 格式,可以用于服务器性能统计。

njmon 更多知识见我之前文章“nmon 的下一代工具 njmon”。

安装 njmon

官方下载总目录:
https://sourceforge.net/projects/nmon/files/


njmon 统计的指标项


关于 jq 的功能和使用,可以参见我之前写的文章 “linux 下强大的 JSON 解析命令 jq”。

安装 njmon_tools


采集数据到 InfluxDB

官方设置了多种采集方式,本教程基于 njmon2influx.py 采集方式。

修改配置文件 njmond.conf


采集数据


InfluxDB 查询数据


Grafana

Grafana 是一个跨平台的开源的度量分析和可视化工具,可以通过将采集的数据查询然后可视化的展示,并及时通知

安装

官方教程:
https://grafana.com/grafana/download


启动


默认密码:admin / admin,登录地址:http://x.x.x.x:3000

安装插件


配置

添加数据源

选择 InfluxDB,并配置

导入仪表盘模板
njmon 模板链接:
https://grafana.com/grafana/dashboards?search=njmon

选择 “njmon Single Host njmon for Linux v11” 模板:

复制 ID ,在 Grafana 中导入即可:

选择 InfluxDB。

导入完成。

查看监控数据

参考资料

http://nmon.sourceforge.net/pmwiki.php?n=site.njmon

https://docs.influxdata.com/influxdb/v1.7/introduction/installation/

https://www.readkong.com/page/njmon-is-nmon-but-saving-to-json-format-for-modern-4222619

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年2月13日
下一篇 2020年2月13日

相关推荐