因为k8s集群版本太低,升级版本太麻烦,所以就通过脚本监控了。
#!/bin/bash declare -A gbdict #将AWK内容转成数组 array=($(/usr/local/bin/crictl stats|grep -v CONTAINER|awk '{if($4 ~ "GB")print $1,$4}')) for(( i=0;i<${#array[@]}-1;i+=2)) do gbdict[${array[i]}]=${array[i+1]} #获取pod对应的数据量 pod_disk_size=`echo ${array[i+1]} |awk -F 'GB' '{print $1}'` #比较pod 数据是否大于10G big_small=`echo "$pod_disk_size > 10"|bc` if [ $big_small -eq 1 ];then #echo ${array[i]},${array[i+1]} res=`/usr/local/bin/crictl ps -a|grep ${array[i]}|awk '{print $7,$9}'` echo $res > /tmp/check_pod_disk.log /opt/scripts/dingding_base_by_url.py "https://oapi.dingtalk.com/robot/send?access_token=xxx" "tke $res pod使用空间超过10G。" fi done