Giter Club home page Giter Club logo

system-info-api's Introduction

system-info-api

python的系统信息web api。包括restful和socketio,方便绘制可视化图表

Python system information web api. Including restful and socketio, convenient to draw visual charts

说明

此项目包含基于flask的restful api以及socketio,分为两种方式提供服务。

  1. 系统信息:背景线程将会每间隔数秒更新系统信息(cpu、内存、硬盘、负载等),并在本地进行缓存,缓存形式包括json文件以及内存(变量)。
  2. 主动推送:每当背景线程更新系统信息,socketio将会广播这些系统信息数据。
  3. 被动获取:你可以通过访问web api来主动获取已经缓存的系统信息,这些缓存信息会随着背景线程的运行而更新。

systemInfo.py

systemInfo.py模块中包含所有可用的系统信息函数(所有api可以在此处找到,包含一些说明) 项目地址:https://github.com/Pure-Peace/system-info

main.py

包含背景线程以及flask、socketio。

运行

虚拟环境

当前提供windows x64下已安装依赖的虚拟环境(python3.8): https://github.com/Pure-Peace/system-info-api/blob/master/venv_windows.zip

sc

将其解压到项目目录下,运行run.bat即可

非虚拟环境

请手动安装python3解释器,并使用命令安装依赖

pip install -r requirements.txt

然后运行

python main.py

运行后,访问地址

http://localhost:5678

即启动成功

{
"message": "hello",
"status": 1
}

[初次]运行后等待5-8秒,项目目录下将会出现缓存的json文件

例如

cpuInfo.json
memInfo.json
ioInfo.json
networkInfo.json
loadInfo.json

这些文件的内容将会不断更新。

您可以通过下列地址访问这些系统信息的缓存:

http://localhost:5678/cpu_constants
http://localhost:5678/cpu_info
http://localhost:5678/io_info
http://localhost:5678/mem_info
http://localhost:5678/network_info
http://localhost:5678/load_info

测试socketio

打开python服务端后,用浏览器打开socketio.html

demo

在网页建立一个socketio对象,连接到服务端 socketio:https://socket.io/#examples

以下是socketio的更新事件(event):

update_cpu
update_io
update_mem
update_net
update_load

Pure-Peace

system-info-api's People

Contributors

pure-peace avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.