Skip to main content

A Python library for xmov systemmonitor

Project description

xmovsystemmonitor

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

Features

安装

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

用法

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

开发测试

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()

开发配置

# 克隆仓库
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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xmovsystemmonitor-0.8.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xmovsystemmonitor-0.8.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file xmovsystemmonitor-0.8.0.tar.gz.

File metadata

  • Download URL: xmovsystemmonitor-0.8.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.19

File hashes

Hashes for xmovsystemmonitor-0.8.0.tar.gz
Algorithm Hash digest
SHA256 3151cd90f351382c192f0edb66c1929d0420369f42de103ffee8bfaa302aa18b
MD5 861e258696b0f45ca9568495585becc4
BLAKE2b-256 26e96ba08295567de28b5cff782bec345951be5832f8e0ed833ffa3fd06555b9

See more details on using hashes here.

File details

Details for the file xmovsystemmonitor-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for xmovsystemmonitor-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b31f473679d910f66e47d2c1f9ccaf09da3f3300ba7c4e2497545b343b5340bc
MD5 9496e7d9dc200c0a9f0195ed6b7f36d9
BLAKE2b-256 06c0259107b768faaf6e8705141343b346c6df34541197f3eee2d697685a4aad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page