Ceph inconsistent 错误修复脚本
作者:互联网
#!/bin/bash health_state=$(ceph -s | grep health | awk '{print $2}') inconsistent_state=$(ceph -s | grep inconsistent) damaged_pg=$(ceph health detail | grep -A1 PG_DAMAGED | tail -1 | awk '{print $2}') date >>ceph-pg-repair.log case $health_state in "HEALTH_OK") echo "Cluster HEALTH_OK!" >>ceph-pg-repair.log ;; "HEALTH_WARN") echo "Cluster HEALTH_WARN!" >>ceph-pg-repair.log ;; "HEALTH_ERR") if [ -z "$inconsistent_state" ]; then echo "Cluster is not a consistency check problem!" >>ceph-pg-repair.log else if [ -z "$damaged_pg" ]; then echo "No PG with inconsistent found, please check manually!" >>ceph-pg-repair.log else ceph pg repair $damaged_pg if [ $? != 0 ]; then echo "Repair error, please check manually!" >>ceph-pg-repair.log fi fi fi ;; *) echo "Unknown state, please check manually!" >>ceph-pg-repair.log ;; esac echo "------------------------------------------------------------" >>ceph-pg-repair.log
标签:log,ceph,修复,repair,echo,Ceph,pg,inconsistent 来源: https://www.cnblogs.com/wang-hongwei/p/15878952.html