https://github.com/raomuyang/cmd-oscillo
Record the system load at the execution of the command line and display it graphically
https://github.com/raomuyang/cmd-oscillo
cpu load memory system-load
Last synced: 2 months ago
JSON representation
Record the system load at the execution of the command line and display it graphically
- Host: GitHub
- URL: https://github.com/raomuyang/cmd-oscillo
- Owner: raomuyang
- License: apache-2.0
- Created: 2019-03-08T05:59:35.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-03-25T22:29:12.000Z (about 4 years ago)
- Last Synced: 2025-03-26T21:07:57.583Z (3 months ago)
- Topics: cpu, load, memory, system-load
- Language: Python
- Size: 1.83 MB
- Stars: 8
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# oscillo
记录命令执行过程中对系统产生的负载,以图片的形式展现出来
Record the system load at the execution of the command line and display it graphically


## 安装方式 / Installation
* Install from pypi
```shell
pip install oscillo
```* Install from local
```shell
python setup.py install
```## 使用方式 / Usage
### 通过命令行参数启动 / Boot start by command line parameter
命令行参数的格式是 `": "`:
* `name`: 命令行的别名/id (任意字符串),当`--commands/-c`参数指定多个命令时,该值将作为命令的唯一标识,不可重复
* `command [args]`: 需要测试资源消耗的命令,比如 `gzip file.ext`示例如下,监控gzip压缩一个文件时耗费的cpu、memory和时间:
```
oscillo -c 'gzip: gzip file.ext' -o output-file
```* -c 代表将执行一个linux cmd 命令。参数后面可以跟以空格隔开的多个参数
* -o 结果输出文件:
命令执行完成后,会在当前目录下生成一个`.log` 文件。文本结构是json 格式. 数据结构如下
```
{
"test": {
"elapsed": 0.022143125534057617, //总执行时间
"cpu": [],
"memory": []
}
}```
同时会产生一个`.png`文件,``由`-o`参数指定,默认值为`metrix``-c/--commands` 可以接受多个参数,以空格隔开,任务会线性执行。使用场景:对比多个命令对资源的消耗
e.g.:
对比`gzip`和`tar`命令对资源的消耗:```shell
oscillo -c 't1: gzip file.ext' 't2: tar czf target.tar.gz file1' -o output
```在控制台上,`oscillo`会打印summary信息,其中包含命令的耗时、最大内存使用、最大cpu使用、退出码等,效果如下:


### 通过配置文件启动 / Boot start by config file
当命令很长或者很多时,可以使用配置文件启动
Whe the commands is too many, you can boot start by config file```shell
oscillo --config [-g]
```## 配置文件模板 / Config file
The command line in commands will be executed in order
```yml
# Demo
commands:
-
name: gzip
cmd: gzip big-file
-
name: tar
cmd: tar -zcf tmp.tar.gz big-fileoutput: gzip-and-tar-gz
```