gpt4 book ai didi

linux - linux 中的 monitor-cpu 脚本

转载 作者:太空宇宙 更新时间:2023-11-04 12:57:46 24 4
gpt4 key购买 nike

 1  # this script checks average cpu load for last 5 minutes
2 # since this server has only one core the system will be fully #utilized when average cpu load values reach 1.00.
3 # This script will send warning alert if value exceedes 0.80 so that action can be taken promptly.
4 # finally it will display the top 10 users and their processes #with highest cpu utilization.
5 #!/bin/bash
6 up=$(uptime | awk '{ print$10 }'| sed 's/,$//')
7 if($up -gt 0.80];
8 echo "============================================" >> /tmp/load
9 ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10 >> /tmp/load
10 mail -s "warning alert on QA server , CPU load exceedes the warning threshold" priyank.dewli@qpay.com.qa issuing-alerts@nexxuspg.com < /tmp/load
11 exit

=======================
error after executing the script
line 12: syntax error: unexpected end of file

最佳答案

检查这一行:

if($up -gt 0.80];

我觉得你想要

if (( $(bc <<< "$up > 0.8") ))
then
echo ...
ps ...
mail ...
fi

关于linux - linux 中的 monitor-cpu 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35153870/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com