# resource_consumer **Repository Path**: yunwe/resource_consumer ## Basic Information - **Project Name**: resource_consumer - **Description**: 占用Linux系统指定的资源使用率 - **Primary Language**: Unknown - **License**: AFL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-08-28 - **Last Updated**: 2024-08-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: Go语言, Linux ## README # resource_consumer #### 介绍 占用Linux系统指定的资源使用率 ## 软件架构 Golang shell ## 使用说明 ### mem_consumer ```shell ./mem_rc_linux 2G ``` 默认最大占用1G内存,不会持续占用参数指定的最大资源,内存占用隔几分钟更新1次 日志示例: ```shell [root@cdh01 monitor]# ./mem_rc [2024-08-28 12:39:42] info Using 121969 KB memory ``` ### cpu_consumer cpu_consumer 需要放在脚本同文件夹,或者修改脚本指定程序路径 ```shell ./cpu_controller.sh 60 ``` 会启动3个CPU占用程序,随机占用10s到120s,最大60%的CPU资源 日志示例 ```shell [root@cdh01 monitor]# ./controller_cpu.sh 60 [2024-08-30 09:47:41] 启动程序1... 将占用CPU 21% [2024-08-30 09:47:41] 程序1将运行 16 秒... [2024-08-30 09:47:41] info Target CPU usage: 21% [2024-08-30 09:47:41] 启动程序2... 将占用CPU 21% [2024-08-30 09:47:41] 关闭程序1... [2024-08-30 09:47:41] 程序2将运行 24 秒... [2024-08-30 09:47:57] info Target CPU usage: 21% ./controller_cpu.sh: 行 79: 2795964 已终止 $PROGRAM -u $U_VALUE1 ```