# monitor **Repository Path**: xia100/monitor ## Basic Information - **Project Name**: monitor - **Description**: 一个用来监控某个进程cpu和gpu资源使用的脚本 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2024-11-21 - **Last Updated**: 2024-11-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # shell_monitor **使用shell来检测特定程序的CPU/GPU资源利用情况,可以输出到log文件并动态显示。** ## Getting started 1. 先使用start_monitor.sh 来监测指定的程序,由于程序名可能重复,所以只支持pid形式,这里假设pid为8888。 ```shell ./start_monitor.sh 8888 ``` start_monitor.sh支持以下参数 ```shell Usage: ./start_monitor.sh [-hi] prog -h show help message. -i seconds set the recording interval in seconds,default 1s. ``` 2. 如果需要在后台执行,可以使用以下命令 ```shell nohup ./start_monitor.sh 8888 2>&1 >log.txt & ``` 3. 上述命令会生产log日志文件,可以使用visual.py脚本可视化 需要安装matplotlib ```python pip install matplotlib ``` 使用方法: ```shell usage: visual.py [-h] [-n N] log_file visualize log file. positional arguments: log_file the log file to draw. optional arguments: -h, --help show this help message and exit -n N sample n records to draw. 比如对于上面产生的log.txt,均匀抽取100条数据可视化,执行 python visual.py -n 100 log.txt ``` ## Example **查看example文件夹内的log日志和图片**