ok-system-helper是一个简单的系统硬件的实时信息收集工具,使用python3.x开发

Overview

ok-system-helper

ok-system-helper是一个简单的系统硬件的实时信息收集工具,使用python3.x开发,支持哪些硬件:CPU、内存、SWAP、磁盘、网卡流量。用户可在自己的项目中直接引入、开箱即用,或者结合flask等web框架轻松做成http接口供前端调用,亦可通过注册中心(Eureka、Consul、Nacos等)的加持,做成微服务供其他系统调用。

提供哪些方法

方法名称 说明
cpu() 获取cpu的使用信息
memory() 获取 '物理内存' 的使用信息
swap() 获取 '交换内存' 的使用信息
disk() 获取磁盘的使用信息
net() 获取自开机以来,网卡的IO信息

提示:具体每个方法使用说明,请参考system_helper.py源码中的注释。

配置说明

配置文件config.conf(如果不需要开启流量统计功能及对外提供HTTP服务,则不需要该配置文件)

[application]
name=ok-system-helper
host=127.0.0.1
port=7002

[webservice]
appid=123456   # 请求HTTP服务时的唯一验证码(作为GET请求的参数携带)

[redis]
host=127.0.0.1
port=6379
password=foobared

[mysql]
host=127.0.0.1
port=3306
dbname=blog
username=root
password=root

使用举例

from core.system_helper import SysInfosCollector

collector = SysInfosCollector()

print(collector.cpu())
'''
{
	'platform': 'windows',
	'physical_count': 4,  # 物理数量
	'logical_count': 8,  # 逻辑数量
	'usage_percent': 6.8,
	'user': 0.4,
	'system': 1.6,
	'idle': 97.7,
	'interrupt': 0.2,
	'dpc': 0.2,
	'boot_time': '2019-09-12 18:49:43'
}
'''

print(collector.memory())
'''
{
	'total': 16331.78,  # 单位MB
	'available': 7945.26,
	'used': 8386.52,
	'free': 7945.26,
	'usage_percent': 51.4
}
'''

print(collector.swap())
'''
{
	'total': 18891.78,  # 单位MB
	'used': 15034.0,
	'free': 3857.78,
	'sin': 0.0,
	'sout': 0.0,
	'usage_percent': 79.6
}
'''

print(collector.disk())
'''
{
	'C:\\': {
		'total': 117.85,  # 单位GB
		'used': 91.86,
		'free': 25.98,
		'usage_percent': 78.0
	},
	'D:\\': {
		'total': 300.03,
		'used': 67.83,
		'free': 232.2,
		'usage_percent': 22.6
	},
	'E:\\': {
		'total': 599.64,
		'used': 185.56,
		'free': 414.07,
		'usage_percent': 30.9
	}
}
'''

print(collector.net())
'''
[{
	'name': '以太网',
	'ip': '192.168.1.4',
	'io_in': 165775.09,  # 单位MB
	'io_out': 26482.64  
}, {
	'name': 'WLAN 2',
	'ip': '169.254.209.196',
	'io_in': 0.0,
	'io_out': 0.0
}, {
	'name': '本地连接* 3',
	'ip': '169.254.211.243',
	'io_in': 0.0,
	'io_out': 0.0
}]
'''

提示:开启流量统计(需先建库建表,脚本tb_net_io.sql)功能及对外提供HTTP服务,请查看scheduled_task.py和web_service.py中的代码。

问题和建议

如果有什么问题、建议、BUG都可以在这个Issue和我讨论

公众号

关注不迷路,微信扫描下方二维码或搜索关键字“spartacus”,关注「spartacus」公众号,时刻收听spartacus更新通知!

在公众号后台回复“加群”,即可加入「spartacus」扯淡交流群!

mp_qrcode

许可证

Copyright [2022] [xlvchao]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You might also like...
gitfs is a FUSE file system that fully integrates with git - Version controlled file system

gitfs is a FUSE file system that fully integrates with git. You can mount a remote repository's branch locally, and any subsequent changes made to the files will be automatically committed to the remote.

 System monitor - A python-based real-time system monitoring tool
System monitor - A python-based real-time system monitoring tool

System monitor A python-based real-time system monitoring tool Screenshots Installation Run My project with these commands pip install -r requiremen

Waydroid is a container-based approach to boot a full Android system on a regular GNU/Linux system like Ubuntu.

Waydroid is a container-based approach to boot a full Android system on a regular GNU/Linux system like Ubuntu.

A System Metrics Monitoring Tool Built using Python3 , rabbitmq,Grafana and InfluxDB. Setup using docker compose. Use to monitor system performance with graphical interface of grafana , storage of influxdb and message queuing of rabbitmq System Design Assignments as part of Arpit's System Design Masterclass
System Design Assignments as part of Arpit's System Design Masterclass

System Design Assignments The repository contains a set of problem statements around Software Architecture and System Design as conducted by Arpit's S

Complete system for facial identity system. Include one-shot model, database operation, features visualization, monitoring

Complete system for facial identity system. Include one-shot model, database operation, features visualization, monitoring

Complete system for facial identity system

Complete system for facial identity system. Include one-shot model, database operation, features visualization, monitoring

Basic flask system for login, api, and status system

Flask Multi Site With Login This is a basic website login system with an uncomplete api system NOTICE : This is NOT complete and is made to be a bare

Face-Recognition-based-Attendance-System - An implementation of Attendance System in python.

Face-Recognition-based-Attendance-System A real time implementation of Attendance System in python. Pre-requisites To understand the implentation of F

IDCARD-VERIFYING-SYSTEM - The Student-Management-System-in-Python - Student Management System in Python
Student-Management-System-in-Python - Student Management System in Python

Student-Management-System-in-Python Student Management System in Python

Face-Recognition-Attendence-System - This face recognition Attendence system using Python

Face-Recognition-Attendence-System I have developed this face recognition Attend

Python script to scan log files/system for unauthorized access around system

checkLogs Python script to scan log files/system for unauthorized access around Linux systems Table of contents General info Getting started Usage Gen

Product-based-recommendation-system - A product based recommendation system which uses Machine learning algorithm such as KNN and cosine similarity Simple-System-Convert--C--F - Simple System Convert With Python
Simple-System-Convert--C--F - Simple System Convert With Python

Simple-System-Convert--C--F REQUIREMENTS Python version : 3 HOW TO USE Run the c

Real-Time-Student-Attendence-System - Real Time Student Attendence System

Real-Time-Student-Attendence-System The Student Attendance Management System Pro

E2e music remastering system - End-to-end Music Remastering System Using Self-supervised and Adversarial Training
E2e music remastering system - End-to-end Music Remastering System Using Self-supervised and Adversarial Training

End-to-end Music Remastering System This repository includes source code and pre

Indico - A feature-rich event management system, made @ CERN, the place where the Web was born.
Indico - A feature-rich event management system, made @ CERN, the place where the Web was born.

Indico Indico is: ? a general-purpose event management tool; ? fully web-based; ? feature-rich but also extensible through the use of plugins; ⚖️ O

Kotti is a high-level, Pythonic web application framework based on Pyramid and SQLAlchemy. It includes an extensible Content Management System called the Kotti CMS.

Kotti Kotti is a high-level, Pythonic web application framework based on Pyramid and SQLAlchemy. It includes an extensible Content Management System c

Owner
xlvchao
xlvchao
Jarvis: a personal assistant which can help you to manage your system

Jarvis Jarvis is personal AI based assistant which can help you to manage stuff in your computer. This is demo but I decided to make it more better so

null 2 Jun 2, 2022
Homeautomation system created with Raspberry Pi 3 and Firebase.

Homeautomation System - Raspberry Pi 3 Desenvolvido com Python, Flask com AJAX e Firebase permite o controle local e remoto Itens necessários Raspberr

Joselino Santos 0 Mar 9, 2022
Designed a system that can efficiently sort recyclables and transfer them to corresponding bins using Python, a Raspberry Pi, and Quanser Labs.

System for Sorting and Recycling Containers - Project 3 Table of contents Overview The challenge Screenshot My process Built with Code snippets What I

Mit Patel 2 Dec 2, 2022
ArduinoWaterHeaterIOT - IoT Probe of a solar PV water heating system - Arduino, Python, MQTT, MySQL

ArduinoWaterHeaterIOT IoT Probe of a solar PV water heating system - Arduino, Raspberry Pi, Python, MQTT, MySQL The Arduino sends the AC and DC watts

Jacques Fourie 1 Jan 11, 2022
ArucoFollow - A script for Robot Operating System and it is a part of a project Robot

ArucoFollow ArucoFollow is a script for Robot Operating System and it is a part

null 5 Jan 25, 2022
ok-mail-helper是一个基于imap/smtp协议邮件客户端,使用python3.x开发

ok-mail-helper ok-mail-helper是一个基于imap/smtp协议邮件客户端,使用python3.x开发,支持邮件接收并解析、邮件发送,用户可在自己的项目中直接引入、开箱即用,或者结合flask等web框架轻松做成http接口供前端调用、把邮箱管理集成到自己的系统中,亦可通过

xlvchao 1 Feb 8, 2022
A free and powerful system for awareness and research of the American judicial system.

CourtListener Started in 2009, CourtListener.com is the main initiative of Free Law Project. The goal of CourtListener.com is to provide high quality

Free Law Project 332 Dec 25, 2022
SysInfo is an app developed in python which gives Basic System Info , and some detailed graphs of system performance .

SysInfo SysInfo is an app developed in python which gives Basic System Info , and some detailed graphs of system performance . Installation Download t

null 5 Nov 8, 2021
System Tray Icon for PySimpleGUI (the tkinter version). Adds a system tray icon by using pystray and PIL

psgtray Add a System Tray Icon to your tkinter port of PySimpleGUI. Installation via pip Installation is via pip: python -m pip install psgtray or if

PySimpleGUI 38 Dec 30, 2022
A hotkey manager that runs in the system tray. Uses PySimpleGUI for the GUI and the system tray.

PySimpleHotkey PySimpleHotkey A hotkey manager that runs in the system tray. Uses PySimpleGUI for the GUI and the system tray. Packages Used This proj

PySimpleGUI 20 Nov 14, 2022