@author Danny0
监控应用并将数据保存到influxdb中, 目前已经实现Redis/Mysql/Nginx监控。
[influxdb 官方安装文档](http://docs.influxdata.com/influxdb/v1.2/introduction/installation/)
# 安装
## 源码安装
```
git clone https://github.com/peablog/monflux
python setup.py install
```
## pip安装
```
pip install monflux
```
# 使用
## 基础配置
首先在代码中添加influxdb的连接配置:
```
influx_config = {
"host": "127.0.0.1",
"port": 8086,
"username": "",
"password": "",
"database": ""
}
```
## Redis监控
设置redis连接的配置信息:
```
redis_config = {
"host": "127.0.0.1",
"password": "",
"port":
}
```
引入监控类并实例化:
```
from monflux import RedisMonitor
RedisMonitor(influx_config, redis_config, "redis_load").start()
```
第三个参数是influxdb保存的measurement
注:需要安装python redis客户端库,可通过`pip install redis`安装
## Mysql监控
设置Mysql连接的配置信息:
```
mysql_config = {
"host": "127.0.0.1",
"username": "",
"password": "",
"port": 3306
}
```
引入监控类并实例化:
```
from monflux import MysqlMonitor
MysqlMonitor(influx_config, mysql_config, "mysql_load").start()
```
注:需要安装python mysql客户端库,可通过`pip install mysql-python`安装
## Nginx监控
设置Nginx的配置信息:
```
nginx_config = {
"url": "http://10.110.95.67/nginx_status",
}
```
引入监控类并实例化:
```
from monflux import NginxMonitor
NginxMonitor(influx_config, nginx_config, "nginx_load").start()
```
## 其他
您可以参考Redis或者Nginx的监控实现来写您自己的插件。
具体教程待补充。
# 数据展现
可通过Grafana来展示保存到influxdb中的监控数据。
mysql配置示例:

mysql监控展示效果:

您还可以通过influxdata自家的Chronograf来展示,毕竟是influxdata自家的东西,对influxdb的支持应该要好一些。
# 类似工具
influxdb的开发商influxdata旗下本身已有一款监控工具:Telegraf. 它不仅支持自家的influxdb, 也支持Es、Kafka等其他流行开源工具, 支持的输入插件也非常多。
但它的使用方式是通过配置文件来实现的,部分配置感觉略复杂。
Metadata
Release files for monflux 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| monflux-0.0.5.tar.gz | 4.6 kB | Without provenance | Details for monflux-0.0.5.tar.gz |
Release files / monflux-0.0.5.tar.gz
| Download URL | monflux-0.0.5.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b754c5939f1552b95b8eed69b7e64c1723526d93ea1c2e6fb4a8a7e4a47b0d7
|
|
BLAKE2b-256 checksum How to use checksums |
91d49de1e0d1a5c3cf2fe1cc0840db4ac08cb66101bbb6f9dd2f6441a79d861a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for monflux 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.