# Baking **Repository Path**: james_valley/barking ## Basic Information - **Project Name**: Baking - **Description**: 用于服务器物理机 烤机,进适配了centos系统和宝德、浪潮、戴尔的主机 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-08-30 - **Last Updated**: 2026-06-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 使用说明: 1. 暂不能实现格式化硬盘,需要手动格式化 2. 使用前需要确保 http://10.16.190.10/ 可以正常使用 3. 运行文件时会现在centos上安装一些依赖包,无需联网 # 运行脚本 在 Baking 目录下执行以下命令即可按照默认10分钟左右的时间烤机 *默认烤机时间受到网络、磁盘、CPU、内存性能影响时间不会为准确为10分钟 先 cd 到烤机脚本 Baking 目录下,执行: ```bash python Baking.py ``` 指定上烤机时间比如 1小时 ```bash python Baking.py 1 ``` # 目录结构 └── Baking ├── Baking.py :烤机脚本 ├── Readme.md :使用须知 └── *.rpm :脚本依赖的RPM包,运行时会自动安装 # 详细文档: ## 设备信息获取的相关命令 1、设备主要信息获取 ```bash #查看硬盘健康状态 smartctl -H /dev/sda #查看硬盘的读取速度及缓存速度速度 hdparm -tT /dev/sda #这将测试61202MB的内存,每个子进程使用256MB的内存,使用16个CPU,每个子进程使用4个CPU stressapptest -M 61202 -s 256 -C 16 -c 8 #使用所有可用的空闲内存 stressapptest -M 100% #使用2个CPU线程、2个IO进程、分配4个内存进程、每个进程分配256M不释放、4个256M硬盘读写进程 stress -c 2 -i 2 --vm 4 --vm-bytes 256m --vm-keep -d 4 --hdd-bytes 256m -v --verbose #获取设备序列号 dmidecode -t 1 | grep Serial | grep Number #获取设备CPU型号 lscpu | grep name #获取内存数量 dmidecode -t memory | grep Size #获取网卡信息 lspci | grep -i eth ``` 2、硬盘相关信息、smart检测,硬盘相关信息的获取与厂商有关 带RAID且型号RAID型号为PM8204的设备有:浪潮Inspur 带RAID的设备为:戴尔 无RAID的设备为:宝德OEM ```bash #带RAID且型号RAID型号为PM8204、带RAID、不带RAID #查看RAID信息 #带RAID会输出相关信息;不带RAID、RAID型号为PM8204无输出; lspci -v | grep Subsystem|wc -l #查看RAID型号 arcconf getconfig $硬盘槽位 | grep 'Controller Model'|cut -f2 -d: #查看硬盘Slot编号($硬盘槽位 或 $硬盘名称如sda) #带RAID且型号RAID型号为PM8204 lsscsi -g #最后一列的数字 #有RAID /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL | grep -i Slot | cut -f2 -d: #无RAID echo "不能获取硬盘槽位号, 使用 lsblk 来获取硬盘名称如sda" #获取硬盘容量和数量 #带RAID且型号RAID型号为PM8204 arcconf getconfig $硬盘槽位 pd | grep -E 'Total Size'|cut -f2 -d: lsscsi -g|wc -l # 带RAID smartctl -i /dev -d megaraid,$硬盘槽位 | grep 'User Capacity:' /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL | grep -i Slot | wc -l # 不带RAID lsblk | grep disk lsblk | grep disk | wc -l #查看硬盘smart参数 #带RAID且型号RAID型号为PM8204 arcconf getconfig $硬盘槽位 pd # 有RAID smartctl --all /dev/sdb -d megaraid,$硬盘槽位 # 无RAID smartctl --all /dev/$硬盘名称如sda #获取硬盘信息 #带RAID且型号RAID型号为PM8204 arcconf getconfig $硬盘槽位 pd | grep -E 'Total Size'|cut -f2 -d: #带RAID smartctl -i /dev/sda -d megaraid,$硬盘槽位 | grep -E 'Total Size'|cut -f2 -d: #不带RAID smartctl -i /dev/$硬盘名称如sda | grep -E 'Total Size'|cut -f2 -d: #是否支持SMART检测 #带RAID且型号RAID型号为PM8204 smartctl -d cciss,$硬盘槽位 -a $硬盘槽位 | grep 'SMART support is:' #带RAID smartctl --all /dev/sdb -d megaraid,$硬盘槽位 | grep 'SMART support is:' #不带RAID smartctl --all /dev/$硬盘名称如sda | grep 'SMART support is:' #获取硬盘型号 #带RAID且型号RAID型号为PM8204 smartctl -d cciss,$硬盘槽位 -a $硬盘槽位 | grep -E 'Device Model:|Product:'|cut -f2 -d: #带RAID smartctl -i /dev/sdb -d megaraid,$硬盘槽位 | grep -E 'Device Model:|Product:'|cut -f2 -d: #不带RAID smartctl -i /dev/$硬盘名称如sda | grep -E 'Device Model:|Product:'|cut -f2 -d: #SMART检测 #带RAID且型号RAID型号为PM8204 smartctl -d cciss,$硬盘槽位 -a $硬盘槽位 | grep -E '^197 |^198 |^199 '|awk '{print $10}' smartctl -d cciss,$硬盘槽位 -a $硬盘槽位 | grep -E "SMART Health Status:|SMART overall-health self-assessment test result:" | cut -f2 -d: #带RAID smartctl --all /dev/sdb -d megaraid,$硬盘槽位 | grep -E '^197 |^198 |^199 '|awk '{print $10}' smartctl --all /dev/sdb -d megaraid,$硬盘槽位 | grep -E "SMART Health Status:|SMART overall-health self-assessment test result:" | cut -f2 -d: #不带RAID smartctl --all /dev/$硬盘名称如sda | grep -E '^197 |^198 |^199 '|awk '{print $10}' smartctl --all /dev/$硬盘名称如sda | grep -E "SMART Health Status:|SMART overall-health self-assessment test result:" | cut -f2 -d: ``` # 烤内存 在使用python作为烤机脚本时单核CPU不能使得内存读写速度达到最大; python的多线程只能占用一个核心;故只能使用多进程烤内存。 ```python def get_memory_available(): """获取空闲内存的总容量(不包含缓存缓冲)(单位 MB)""" return int(os.popen("""free -m |grep "Mem" |awk '{print $7}' """).read().strip('\n').strip(' ')) # 多进程填充内存 def multiprocess_fill_memory(process_id, q, full_percentage): if process_id <= 0: return p = Process(target=multiprocess_fill_memory, args=(process_id - 1, q, full_percentage,)) p.start() main_8 = int(get_memory_available() * full_percentage // 100 // how_many_thread) mem = u"1" * 256 * 1024 * main_8 if process_id == 1: queue_list = [] while len(queue_list) < how_many_thread - 1: queue_len = q.get() queue_list.append(queue_len) peak_used_mem = get_memory_available() q.put(peak_used_mem) else: q.put(process_id) p.join() ``` # 烤CPU 多进程+死循环即可,使得CPU占用率为100% # 硬盘读写测试 借助工具 hdparm ,读写速度小于150MB/s的直接算不过 ```bash # hdparm -t /dev/$硬盘名称如sda | grep = | cut -f2 -d= ``` # 网络压力测试 网络压力测试,完成1000000次请求的速度{}Kbytes/sec