# monitors
[![Build Status](https://travis-ci.com/Pactortester/monitors.svg?branch=master)](https://travis-ci.com/Pactortester/monitors) ![PyPI](https://img.shields.io/pypi/v/monitors) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/monitors) ![GitHub top language](https://img.shields.io/github/languages/top/Pactortester/monitors) [![Downloads](https://pepy.tech/badge/monitors)](https://pepy.tech/project/monitors) ![GitHub stars](https://img.shields.io/github/stars/Pactortester/monitors?style=social) ![https://blog.csdn.net/flower_drop](https://img.shields.io/badge/csdn-%40flower__drop-orange)
## Logo
![](https://files.mdnice.com/user/17535/0ce07240-b2ea-4739-aede-b67a2bc8b757.png)
## 仓库地址:
- github:https://github.com/Pactortester/monitors.git
- pypi:https://pypi.org/project/monitors/#history
## 背景介绍
专项测试,桌面端应用程序使用过程中,对CPU,内存,磁盘使用率,网络流量进行监控并展现.
## 解决方案
### 需求梳理
1. 简单方便 傻瓜式操作
2. 数据持久化,数据可保存
3. 数据可视化,清晰明了
解决方案来了,如下
>minitor作为监控服务,influxdb做为数据收集,Grafana图表可视化展示,干就完了!
## 前提准备
1. 你需要安装好 influxdb
2. 你还需要安装好 grafana
>看到这,你是不是又慌乱了,怎么还需要这么多准备工作。莫慌,教程都给你准备好了,乖,张开嘴,吃~
- [Linux下安装配置Grafana压测监控服务-安装InfluxDB
](https://mp.weixin.qq.com/s?__biz=MzIxMjE1ODAzOA==&mid=2650631463&idx=1&sn=cc3125d39b5559eca88a23ed1e7164d9&chksm=8f439e1eb83417083a98da8bd717fcfe2f5399e4f6c7ec031be61812562544956256965182d7&token=430212778&lang=zh_CN#rd)
- [Linux下安装配置Grafana压测监控服务-安装Grafana](https://mp.weixin.qq.com/s?__biz=MzIxMjE1ODAzOA==&mid=2650631478&idx=1&sn=df8f41d086d7421400e9ea4673d9f3cc&chksm=8f439e0fb834171908af65152a9b4de25f648809f5dea1877a650835f968732540c9bd34d744&token=430212778&lang=zh_CN#rd)
## 安装服务
```
pip install -U monitors
```
## 启动服务
```python
# -*- coding: utf-8 -*-
"""
@Project :monitors
@File :monitor.py
@Author :lijiawei
@Date :2021/9/6 4:13 下午
"""
from monitors.monitor_set import Settings as ST
import argparse
parser = argparse.ArgumentParser(description='manual to this script')
parser.add_argument("-name", type=str)
args = parser.parse_args()
name = args.name
# 服务端ip
ST.host = '127.0.0.1'
# influxdb 端口
ST.port = 8086
# influxdb 账号
ST.password = '*********'
# influxdb 数据库
ST.database = 'test_database'
# Grafana apikey
ST.apikey = '********'
# influxdb 表
ST.table = name
from monitors.monitor_util import monitor_on
monitor_on()
```
>注意:脚本内容禁止任何修改!
## 运行命令
```
python monitor.py -name=test_monitor
```
![](https://files.mdnice.com/user/17535/315d2617-bcbc-4497-a258-effa717d6521.png)
>参数说明:name 必须为唯一值
## 查看结果
打开 Grafana url 登录后 查看监控图表
![](https://files.mdnice.com/user/17535/aaa6a355-d8e6-4847-9049-474a45040989.png)
>Grafana账号密码:test/test
## 停止监控
按下 CTRL + C,监控服务已停止!
![](https://files.mdnice.com/user/17535/dce8bbb5-2a5c-4ac6-abac-4f9f8c43a620.png)
## 后续方案
在推广使用过程中,发现尽管已经做的如此简单,还是有同学不会使用,一步三个坑,后续我计划把【minitors】监控服务,打包成可执行文件,有完整的页面交互,防止大家掉坑!
## 视频分析
```
点击应用图标 弹窗1 关闭弹窗1 欢迎页 滑动欢迎页 弹窗2 关闭弹窗2 首页
^ ^ ^ ^ ^
| | | | |
|---------logo1-------|-------logo2-------|--------.......------|------......------|
稳定阶段(个): 2 1 1 1 1 1 2
| | | | |
v v v v v
A B C D E
```
##
以上便是 monitors 的基本用法介绍。
如果您有发现错误,或者您对 monitors 有任何建议,欢迎到 [monitors Issues](https://github.com/Pactortester/monitors/issues) 发表,非常感谢您的支持。您的反馈和建议非常宝贵,希望您的参与能帮助 monitors 做得更好。
Raw data
{
"_id": null,
"home_page": "https://github.com/openutx",
"name": "monitors",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "grafana,monitors,process monitor,system monitor,influxdb",
"author": "lijiawei",
"author_email": "jiawei.li2@qq.com",
"download_url": "https://files.pythonhosted.org/packages/8b/5d/bdcb16ba6681a10184a14f789de23110dab940c876d12d3dd4d4a2dc6f2e/monitors-1.1.2.tar.gz",
"platform": "any",
"description": "# monitors\n\n\n[![Build Status](https://travis-ci.com/Pactortester/monitors.svg?branch=master)](https://travis-ci.com/Pactortester/monitors) ![PyPI](https://img.shields.io/pypi/v/monitors) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/monitors) ![GitHub top language](https://img.shields.io/github/languages/top/Pactortester/monitors) [![Downloads](https://pepy.tech/badge/monitors)](https://pepy.tech/project/monitors) ![GitHub stars](https://img.shields.io/github/stars/Pactortester/monitors?style=social) ![https://blog.csdn.net/flower_drop](https://img.shields.io/badge/csdn-%40flower__drop-orange)\n\n\n## Logo\n\n\n![](https://files.mdnice.com/user/17535/0ce07240-b2ea-4739-aede-b67a2bc8b757.png)\n\n\n## \u4ed3\u5e93\u5730\u5740\uff1a\n\n\n- github\uff1ahttps://github.com/Pactortester/monitors.git\n- pypi\uff1ahttps://pypi.org/project/monitors/#history\n\n## \u80cc\u666f\u4ecb\u7ecd\n\u4e13\u9879\u6d4b\u8bd5\uff0c\u684c\u9762\u7aef\u5e94\u7528\u7a0b\u5e8f\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u5bf9CPU\uff0c\u5185\u5b58\uff0c\u78c1\u76d8\u4f7f\u7528\u7387\uff0c\u7f51\u7edc\u6d41\u91cf\u8fdb\u884c\u76d1\u63a7\u5e76\u5c55\u73b0.\n\n## \u89e3\u51b3\u65b9\u6848\n\n### \u9700\u6c42\u68b3\u7406\n1. \u7b80\u5355\u65b9\u4fbf \u50bb\u74dc\u5f0f\u64cd\u4f5c\n2. \u6570\u636e\u6301\u4e45\u5316\uff0c\u6570\u636e\u53ef\u4fdd\u5b58\n3. \u6570\u636e\u53ef\u89c6\u5316\uff0c\u6e05\u6670\u660e\u4e86\n\n\u89e3\u51b3\u65b9\u6848\u6765\u4e86\uff0c\u5982\u4e0b\n>minitor\u4f5c\u4e3a\u76d1\u63a7\u670d\u52a1\uff0cinfluxdb\u505a\u4e3a\u6570\u636e\u6536\u96c6\uff0cGrafana\u56fe\u8868\u53ef\u89c6\u5316\u5c55\u793a\uff0c\u5e72\u5c31\u5b8c\u4e86\uff01\n\n## \u524d\u63d0\u51c6\u5907\n1. \u4f60\u9700\u8981\u5b89\u88c5\u597d influxdb\n2. \u4f60\u8fd8\u9700\u8981\u5b89\u88c5\u597d grafana\n\n>\u770b\u5230\u8fd9\uff0c\u4f60\u662f\u4e0d\u662f\u53c8\u614c\u4e71\u4e86\uff0c\u600e\u4e48\u8fd8\u9700\u8981\u8fd9\u4e48\u591a\u51c6\u5907\u5de5\u4f5c\u3002\u83ab\u614c\uff0c\u6559\u7a0b\u90fd\u7ed9\u4f60\u51c6\u5907\u597d\u4e86\uff0c\u4e56\uff0c\u5f20\u5f00\u5634\uff0c\u5403\uff5e\n\n- [Linux\u4e0b\u5b89\u88c5\u914d\u7f6eGrafana\u538b\u6d4b\u76d1\u63a7\u670d\u52a1-\u5b89\u88c5InfluxDB\n](https://mp.weixin.qq.com/s?__biz=MzIxMjE1ODAzOA==&mid=2650631463&idx=1&sn=cc3125d39b5559eca88a23ed1e7164d9&chksm=8f439e1eb83417083a98da8bd717fcfe2f5399e4f6c7ec031be61812562544956256965182d7&token=430212778&lang=zh_CN#rd)\n- [Linux\u4e0b\u5b89\u88c5\u914d\u7f6eGrafana\u538b\u6d4b\u76d1\u63a7\u670d\u52a1-\u5b89\u88c5Grafana](https://mp.weixin.qq.com/s?__biz=MzIxMjE1ODAzOA==&mid=2650631478&idx=1&sn=df8f41d086d7421400e9ea4673d9f3cc&chksm=8f439e0fb834171908af65152a9b4de25f648809f5dea1877a650835f968732540c9bd34d744&token=430212778&lang=zh_CN#rd)\n\n## \u5b89\u88c5\u670d\u52a1\n```\npip install -U monitors\n```\n\n\n## \u542f\u52a8\u670d\u52a1\n\n```python\n# -*- coding: utf-8 -*-\n\"\"\"\n@Project \uff1amonitors \n@File \uff1amonitor.py\n@Author \uff1alijiawei\n@Date \uff1a2021/9/6 4:13 \u4e0b\u5348 \n\"\"\"\n\nfrom monitors.monitor_set import Settings as ST\nimport argparse\n\n\nparser = argparse.ArgumentParser(description='manual to this script')\nparser.add_argument(\"-name\", type=str)\n\nargs = parser.parse_args()\nname = args.name\n\n# \u670d\u52a1\u7aefip\nST.host = '127.0.0.1'\n# influxdb \u7aef\u53e3\nST.port = 8086\n# influxdb \u8d26\u53f7\nST.password = '*********'\n# influxdb \u6570\u636e\u5e93\nST.database = 'test_database'\n# Grafana apikey\nST.apikey = '********'\n# influxdb \u8868\nST.table = name\n\nfrom monitors.monitor_util import monitor_on\n\nmonitor_on()\n```\n\n\n>\u6ce8\u610f\uff1a\u811a\u672c\u5185\u5bb9\u7981\u6b62\u4efb\u4f55\u4fee\u6539\uff01\n\n## \u8fd0\u884c\u547d\u4ee4\n\n```\npython monitor.py -name=test_monitor\n\n```\n\n![](https://files.mdnice.com/user/17535/315d2617-bcbc-4497-a258-effa717d6521.png)\n\n>\u53c2\u6570\u8bf4\u660e\uff1aname \u5fc5\u987b\u4e3a\u552f\u4e00\u503c\n\n## \u67e5\u770b\u7ed3\u679c\n\n\u6253\u5f00 Grafana url \u767b\u5f55\u540e \u67e5\u770b\u76d1\u63a7\u56fe\u8868\n\n![](https://files.mdnice.com/user/17535/aaa6a355-d8e6-4847-9049-474a45040989.png)\n\n>Grafana\u8d26\u53f7\u5bc6\u7801\uff1atest/test\n\n## \u505c\u6b62\u76d1\u63a7\n\u6309\u4e0b CTRL + C\uff0c\u76d1\u63a7\u670d\u52a1\u5df2\u505c\u6b62\uff01\n\n\n![](https://files.mdnice.com/user/17535/dce8bbb5-2a5c-4ac6-abac-4f9f8c43a620.png)\n\n## \u540e\u7eed\u65b9\u6848\n\n\u5728\u63a8\u5e7f\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u53d1\u73b0\u5c3d\u7ba1\u5df2\u7ecf\u505a\u7684\u5982\u6b64\u7b80\u5355\uff0c\u8fd8\u662f\u6709\u540c\u5b66\u4e0d\u4f1a\u4f7f\u7528\uff0c\u4e00\u6b65\u4e09\u4e2a\u5751\uff0c\u540e\u7eed\u6211\u8ba1\u5212\u628a\u3010minitors\u3011\u76d1\u63a7\u670d\u52a1\uff0c\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u6709\u5b8c\u6574\u7684\u9875\u9762\u4ea4\u4e92\uff0c\u9632\u6b62\u5927\u5bb6\u6389\u5751\uff01\n\n## \u89c6\u9891\u5206\u6790\n\n```\n \u70b9\u51fb\u5e94\u7528\u56fe\u6807 \u5f39\u7a971 \u5173\u95ed\u5f39\u7a971 \u6b22\u8fce\u9875 \u6ed1\u52a8\u6b22\u8fce\u9875 \u5f39\u7a972 \u5173\u95ed\u5f39\u7a972 \u9996\u9875\n ^ ^ ^ ^ ^ \n | | | | |\n |---------logo1-------|-------logo2-------|--------.......------|------......------|\n\n\u7a33\u5b9a\u9636\u6bb5\uff08\u4e2a\uff09\uff1a 2 1 1 1 1 1 2\n\n | | | | |\n v v v v v\n A B C D E\n```\n\n## \n\n\u4ee5\u4e0a\u4fbf\u662f monitors \u7684\u57fa\u672c\u7528\u6cd5\u4ecb\u7ecd\u3002\n\n\u5982\u679c\u60a8\u6709\u53d1\u73b0\u9519\u8bef\uff0c\u6216\u8005\u60a8\u5bf9 monitors \u6709\u4efb\u4f55\u5efa\u8bae\uff0c\u6b22\u8fce\u5230 [monitors Issues](https://github.com/Pactortester/monitors/issues) \u53d1\u8868\uff0c\u975e\u5e38\u611f\u8c22\u60a8\u7684\u652f\u6301\u3002\u60a8\u7684\u53cd\u9988\u548c\u5efa\u8bae\u975e\u5e38\u5b9d\u8d35\uff0c\u5e0c\u671b\u60a8\u7684\u53c2\u4e0e\u80fd\u5e2e\u52a9 monitors \u505a\u5f97\u66f4\u597d\u3002\n",
"bugtrack_url": null,
"license": "MIT Licence",
"summary": "monitor tools",
"version": "1.1.2",
"project_urls": {
"Homepage": "https://github.com/openutx"
},
"split_keywords": [
"grafana",
"monitors",
"process monitor",
"system monitor",
"influxdb"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "78db7e69dc7df509553ecd040c15c50550d970c1c58d7b6db3ee2034ff5a015d",
"md5": "d7d7bfe1244a67d499940d069f3f66d3",
"sha256": "e3547363632ded3481101623c76c60b999d07a2425943e181649183457dfabd7"
},
"downloads": -1,
"filename": "monitors-1.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d7d7bfe1244a67d499940d069f3f66d3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 59080,
"upload_time": "2023-05-05T13:22:52",
"upload_time_iso_8601": "2023-05-05T13:22:52.105578Z",
"url": "https://files.pythonhosted.org/packages/78/db/7e69dc7df509553ecd040c15c50550d970c1c58d7b6db3ee2034ff5a015d/monitors-1.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8b5dbdcb16ba6681a10184a14f789de23110dab940c876d12d3dd4d4a2dc6f2e",
"md5": "4ce745238b8d911f8c60c344f594a0dc",
"sha256": "510571e985acd172344e864b8495e46b7a494ea629a21146d94fcceeca87fc8c"
},
"downloads": -1,
"filename": "monitors-1.1.2.tar.gz",
"has_sig": false,
"md5_digest": "4ce745238b8d911f8c60c344f594a0dc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 50395,
"upload_time": "2023-05-05T13:22:54",
"upload_time_iso_8601": "2023-05-05T13:22:54.017524Z",
"url": "https://files.pythonhosted.org/packages/8b/5d/bdcb16ba6681a10184a14f789de23110dab940c876d12d3dd4d4a2dc6f2e/monitors-1.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-05 13:22:54",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "monitors"
}