mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 06:46:09 +08:00
修改资源异常推送
This commit is contained in:
parent
6ec6e25855
commit
9a55968ed6
|
@ -128,18 +128,14 @@ check_server() {
|
||||||
disk_use=$(df -P | grep /dev | grep -v -E '(tmp|boot|shm)' | awk '{print $5}' | cut -f 1 -d "%")
|
disk_use=$(df -P | grep /dev | grep -v -E '(tmp|boot|shm)' | awk '{print $5}' | cut -f 1 -d "%")
|
||||||
|
|
||||||
eval echo -e "\#\# 当前CPU占用 $cpu_use% 内存占用 $mem_use% 磁盘占用 $disk_use% \\\n" $cmd
|
eval echo -e "\#\# 当前CPU占用 $cpu_use% 内存占用 $mem_use% 磁盘占用 $disk_use% \\\n" $cmd
|
||||||
if [[ $cpu_use -gt $cpu_warn ]]; then
|
if [[ $cpu_use -gt $cpu_warn ]] || [[ $mem_free -lt $mem_warn ]] || [[ $disk_use -gt $disk_warn ]]; then
|
||||||
notify_api "CPU异常警告" "当前CPU占用 $cpu_use%"
|
echo -e "\#\# 服务器资源占用异常,本次任务跳过执行" $cmd
|
||||||
exit 1
|
notify_api "服务器资源异常警告" "当前CPU占用 $cpu_use% 内存占用 $mem_use% 磁盘占用 $disk_use%"
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $mem_free -lt $mem_warn ]]; then
|
end_time=$(date '+%Y-%m-%d %H:%M:%S')
|
||||||
notify_api "内存异常警告" "当前内存占用 $mem_use%"
|
diff_time=$(($end_timestamp - $begin_timestamp))
|
||||||
exit 1
|
[[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time"
|
||||||
fi
|
eval echo -e "\\\n\#\# 执行结束... $end_time 耗时 $diff_time 秒" $cmd
|
||||||
|
|
||||||
if [[ $disk_use -gt $disk_warn ]]; then
|
|
||||||
notify_api "磁盘异常警告" "当前磁盘占用 $disk_use%"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user