We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
一个脚本的事 #!/bin/bash #author:yangshu #检查磁盘使用率 #检查Inode使用率 #检查内存使用率 #v1.0.7 增加CPU监控 #V1.0.8 增加告警阈值红色显示 #V1.0.9 修复告警多个指标判断逻辑 check_disk_usage() { local alert_percent=$1 local output=$(df -PTl | grep "/dev" | grep -Ev "tmpfs|sr0|cdrom|:" | sed 's/%//g' | awk -v var="$alert_percent" '{if($6>var) print "告警目录: "$7 " 使用率 " $6"%"}') if [[ -z "$output" ]]; then return 0 else echo -e "磁盘使用率超过 $alert_percent% \t $output" return 1 fi }
check_inode_usage() { local alert_percent=$1 local output=$(df -PTil | grep "/dev" | grep -Ev "tmpfs|sr0|cdrom|:" | sed 's/%//g' | awk -v var="$alert_percent" '{if($6>var) print $0}') if [[ -z "$output" ]]; then return 0 else echo -e "innode使用率超过 $alert_percent% \t $output" return 1 fi }
check_memory_usage() { local alert_percent=$1 local output=$(free | grep Mem | awk '{printf("%.0f"), $3/$2*100}') if [[ $output -gt $alert_percent ]]; then echo -e "内存使用率超过 $alert_percent% \t 当前为$output%" return 1 fi return 0 }
check_cpu_usage() { local alert_percent=$1 local output=$(top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}') if (( $(echo "$output > $alert_percent" | bc -l) )); then echo -e "CPU使用率超过 $alert_percent% \t 当前为$output%" return 1 fi return 0 }
main() { disk=$(check_disk_usage 90) inode=$(check_inode_usage 80) memory=$(check_memory_usage 95) cpu=$(check_cpu_usage 90) all_check=$disk$inode$memory$cpu if [[ -z $all_check ]]; then echo -e "\t 巡检正常 \t" return 0 else echo -e "\t 巡检异常\n \t$all_check \t" return 1 fi }
main
Sorry, something went wrong.
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: