Metadata-Version: 2.1
Name: xmovsystemmonitor
Version: 0.8.0
Summary: A Python library for xmov systemmonitor
Author-email: jiangbin <07jiangbin@gmail.com>
License: MIT
Project-URL: Homepage, https://git.xmov.ai/jiangbin/xmovsystemmonitor
Project-URL: Repository, https://git.xmov.ai/jiangbin/xmovsystemmonitor
Project-URL: Issues, https://git.xmov.ai/jiangbin/xmovsystemmonitor
Keywords: python,xmov,systemmonitor
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: psutil
Requires-Dist: fastapi
Requires-Dist: uvicorn
Provides-Extra: dev
Requires-Dist: twine; extra == "dev"
Requires-Dist: pip-tools; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-cov>=2.0; extra == "dev"
Requires-Dist: black>=22.0; extra == "dev"
Requires-Dist: flake8>=4.0; extra == "dev"
Requires-Dist: mypy>=0.900; extra == "dev"

# xmovsystemmonitor

一个用于监测系统CPU和内存使用率的工具，提供HTTP API接口，可以用于监控系统性能（内存、CPU）。

## Features


## 安装

```bash
# 本地
pip install xmovsystemmonitor -i https://pypi.org/simple/
# 阿里云
pip install xmovsystemmonitor -i http://pypi.aliyun.com/simple/
```

## 用法

```bash
python -m xmovsystemmonitor 
# 指定主机和端口, 并指定最大记录数量
python -m xmovsystemmonitor --host 0.0.0.0 --port 8000 --max-num 3000
```

## 开发测试
```python
import pytest
import requests
import json
from functools import partial

json_dump = partial(json.dumps, indent=4, ensure_ascii=False)


def test_get_system_info():
    response = requests.get("http://localhost:8000/")
    print(response.json())
    assert response.status_code == 200
    assert "cpu_percent" in response.json()
    assert "memory_percent" in response.json()

def test_start_monitoring():
    response = requests.get("http://localhost:8000/start-monitoring")
    print(response.json())
    assert response.status_code == 200
    assert "message" in response.json()
    assert response.json()["message"] == "监控已启动"

def test_stop_monitoring():
    response = requests.get("http://localhost:8000/stop-monitoring")
    print(response.json())
    assert response.status_code == 200
    assert "message" in response.json()
    assert response.json()["message"] == "监控已停止"

def test_statistic():
    response = requests.get("http://localhost:8000/statistic")
    print(json_dump(response.json()))
    assert response.status_code == 200
    assert "cpu_percent" in response.json()
    assert "memory_percent" in response.json()
    assert "data_list" in response.json()

```


### 开发配置

```bash
# 克隆仓库
git clone git@github.com:atanx/xmovsystemmonitor.git
cd xmovsystemmonitor

# 安装开发依赖
pip install -e ".[dev]"

# 手动修改修改__init__.py中的__version__， 然后打包
make build

# 上传到xmov-pypi, 需要安装twine， 配置~/.pypirc
make upload
```

    
