当前位置: 首页 > news >正文

宝安做棋牌网站建设哪家便宜中小微企业网站建设

宝安做棋牌网站建设哪家便宜,中小微企业网站建设,廊坊app网站制作,全国企业信用信息公示系统黑龙江简介: 这篇文章介绍了一款用于Linux系统的自动化硬件老化测试脚本。该脚本能够通过对CPU、内存、硬盘和GPU进行高强度负载测试,持续运行设定的时长(如1小时),以模拟长时间高负荷运行的环境,从而验证硬件的稳…

简介:

  这篇文章介绍了一款用于Linux系统的自动化硬件老化测试脚本。该脚本能够通过对CPU、内存、硬盘和GPU进行高强度负载测试,持续运行设定的时长(如1小时),以模拟长时间高负荷运行的环境,从而验证硬件的稳定性与可靠性。脚本还包括了系统资源监控,实时显示CPU温度、频率、内存使用情况等信息,并将测试结果记录到日志文件中。测试完成后,脚本会提供详细的反馈,并允许用户选择是否重新执行测试。通过这种方式,用户可以轻松地评估设备的性能和健康状况。

#!/bin/bash# 请设置老化时长(小时)
set_aging_time=1# 获取脚本绝对路径
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# echo "脚本所在的绝对路径是: ${SCRIPT_DIR}"# 日志存放路径
log_file=${SCRIPT_DIR}/log_file.log
stress_ng=${SCRIPT_DIR}/stress_ng.log# 安装stress-ng、figlet和glmark2-es2工具,当前环境为Ubuntu系统,根据系统替换相关安装命令
install_packages() {if command -v stress-ng > /dev/null 2>&1 && command -v figlet > /dev/null 2>&1 && command -v glmark2-es2 > /dev/null 2>&1; thenecho "All software has been installed."elsesudo apt updatesudo apt install -y stress-ngsudo apt install -y glmark2-es2sudo apt install -y figlet# 检查 stress-ng 是否缺失if ! command -v stress-ng > /dev/null 2>&1; thenecho "stress-ng is not installed"exit 1fi# 检查 figlet 是否缺失if ! command -v figlet > /dev/null 2>&1; thenecho "figlet is not installed"exit 1fi# 检查 glmark2-es2 是否缺失if ! command -v glmark2-es2 > /dev/null 2>&1; thenecho "glmark2-es2 is not installed"exit 1fifi
}# CPU stress test
run_cpu_test() {# 查看cpu信息 lscpustress-ng --cpu $(nproc) --metrics-brief --timeout ${aging_time}s >> ${stress_ng} 2>&1
}# Memory stress test
run_memory_test() {available_memory=$(free -m | grep -E 'Mem|内存' | awk '{print $7}')half_memory=$(echo "$available_memory / $(nproc)" | bc)# 运行内存分配释放模式stress-ng --vm $(nproc) --vm-bytes ${half_memory}M --metrics-brief --timeout ${aging_time}s >> ${stress_ng} 2>&1# 运行内存持续占用模式# stress-ng --vm 1 --vm-bytes ${available_memory}M --metrics-brief --vm-keep --timeout ${aging_time}s >> ${stress_ng} 2>&1
}#HDD stress test
run_disk_stress_test() {stress-ng --hdd $(nproc) -i $(nproc) --metrics-brief --timeout ${aging_time}s >> ${stress_ng} 2>&1
}# GPU stress test
run_gpu_test() {timeout ${aging_time} glmark2-es2  --run-forever --annotate > /dev/null 2>&1
}get_cpu_info() {# 当前 CPU 温度路径cpu_temp_path="/sys/class/thermal/thermal_zone1/temp"cat ${cpu_temp_path} > /dev/null 2>&1if [ $? -eq 0 ]; thencpu_temp=$(echo "scale=1; $(cat ${cpu_temp_path}) / 1000" | bc)elsecpu_temp=" ---"fi# 当前 CPU 频率路径cpu_cur_freq_path="/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq"cat ${cpu_cur_freq_path} > /dev/null 2>&1if [ $? -eq 0 ]; thencpu_cur_freq=$(echo "scale=2; $(cat ${cpu_cur_freq_path}) / 1000" | bc)elsecpu_cur_freq=" --- "fi# 获取当前CPU使用率cpu_usage=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}')
}get_memory_info() {# 获取总内存、已用内存、缓存memory_info=$(free -m)total_mem=$(echo "$memory_info" | grep -E 'Mem|内存' | awk '{print $2}')used_mem=$(echo "$memory_info" | grep -E 'Mem|内存' | awk '{print $3}')# 计算内存使用百分比(保留一位小数)used_percent=$(echo "scale=1; $used_mem * 100 / $total_mem" | bc)
}run_test() {touch ${SCRIPT_DIR}/start_state.zzecho "Device MAC: $(ip -o link show up | awk '$2 == "eth0:" {print $17}')" >> ${log_file}aging_time=$((set_aging_time * 60 * 60))echo "Aging duration: ${aging_time}S" >> ${log_file}run_cpu_test &run_memory_test &run_disk_stress_test &run_gpu_test &echo "start time: $(date)" >> ${log_file}start_time=$(date +%s)# 清屏clear# 隐藏光标:使用 ANSI 转义序列echo -e "\e[?25l"# 循环直到老化时间结束while true; docurrent_time=$(date +%s)  # 获取当前时间elapsed_time=$((current_time - start_time))  # 计算已老化时间# 将已老化时间转换为小时、分钟和秒hours=$((elapsed_time / 3600))minutes=$(( (elapsed_time % 3600) / 60 ))seconds=$((elapsed_time % 60))tput cup 0 0echo -n "Aging time: $(printf "%02d:%02d:%02d" $hours $minutes $seconds)    "get_cpu_infotput cup 2 0echo -n "CPU Usage: ${cpu_usage}%   |  CPU Temp: ${cpu_temp} °C   |  CPU Cur Freq: ${cpu_cur_freq} MHz    "get_memory_infotput cup 4 0echo -n "Total Mem: ${total_mem}M  |  Used Mem: ${used_mem}M     |  Mem Usage: ${used_percent}%    "# 检查是否已经达到老化时间if [ "$elapsed_time" -ge "$aging_time" ]; thenecho "stop time: $(date)" >> ${log_file}breakfi# 每隔1秒更新一次显示sleep 1done# 等待所有测试完成wait# 显示光标:使用 ANSI 转义序列echo -e "\e[?25h"	echo ""printf "Aging test passed, aging duration: %02d:%02d:%02d" $hours $minutes $seconds 2>&1 | tee -a ${log_file}echo ""echo -e "\033[32m$(figlet "PASS")\033[0m"touch ${SCRIPT_DIR}/end_state.zz
}install_packagesstart_state="${SCRIPT_DIR}/start_state.zz"
end_state="${SCRIPT_DIR}/end_state.zz"
if [[ -e "$start_state" ]] && [[ ! -e "$end_state" ]]; thenecho -e "\033[31m$(figlet "FAIL")\033[0m"read -p "Aging test failed, please choose whether to re-execute aging test? (y/n):" answerif [ "$answer" = "Y" ] || [ "$answer" == "y" ]; thenrm -rf ${SCRIPT_DIR}/log_file.logrm -rf ${SCRIPT_DIR}/stress_ng.logrm -rf ${SCRIPT_DIR}/start_state.zzrun_testelseexit 0fielif [[ -e "$start_state" ]] && [[ -e "$end_state" ]]; thenecho -e "\033[32m$(figlet "PASS")\033[0m"read -p "The equipment has completed the aging test and passed. Would you like to re-execute the aging test? (y/n):" answerif [ "$answer" = "Y" ] || [ "$answer" == "y" ]; thenrm -rf ${SCRIPT_DIR}/log_file.logrm -rf ${SCRIPT_DIR}/stress_ng.logrm -rf ${SCRIPT_DIR}/start_state.zzrm -rf ${SCRIPT_DIR}/end_state.zzrun_testelseexit 0fielserun_test
fi
http://www.yayakq.cn/news/500677/

相关文章:

  • 网站本地环境搭建教程后端需要学什么
  • 北京做网站的人鞍山网络
  • 建设审批网站查询水网站建设
  • 永久免费的自建网站东莞网站推广策划
  • 公司网站开发视频联通北京网站备案
  • 网站备案查询不了邢台建网站的公司
  • redis做缓存的网站并发数新乡市网站建设
  • 大尺度做爰网站网站建设研究方法
  • 湖南省住房和城乡建设厅门户网站找谁做网站
  • 360网站地图怎么做东山县建设局网站
  • 凡科可以做游戏网站吗口碑好的网站建设公司哪家好
  • 如何做一个网站的seo建站工作室
  • 安徽城乡建设厅官方网站一学一做教育视频网站
  • 科技类网站简介怎么做网站建设客户目标模板
  • 如何查看网站有没有收录网站建设需什么软件
  • 优质网站建设报价做设计需要知道的几个网站吗
  • 网站降权查询工作室建设基础
  • 天河做网站公司在那可以做公司网站
  • cn网站网站建设 账务处理
  • 北京网站设计济南兴田德润团队怎么样wordpress插件有何用
  • 二级域名怎么指向另外一个网站能利用双股铜芯电话线做网站吗
  • 专业北京网站建设公司排名番禺做哪些做网站的
  • 网站我优化外汇seo公司
  • cdn网站加速有用吗wordpress自带分页函数
  • 宁波网站制作与推广开锁公司网站建设
  • 自己做的网站访问速度慢旅游网站开发意义和背景
  • 新兴县建设局网站工程建设项目审批流程图
  • 长辛店网站建设商城设计app网站建设
  • 西宁网站托管建筑信用信息查询平台
  • 高端装饰公司网站设计网站怎么申请域名