判断卷是否有error,有error重新挂载的脚本

#!/bin/bash

#卷的全路径示例

#pathexample =mount -t cetusfs 127.0.0.1:/cinderv/var/lib/cinder/volumes/0f6a20f4d81ed9db37f2a87260dd7181 

volumesPath=`df -h |awk '{print$1$6}'|grep volumes` #获取卷路径

pathRow=`df -h |awk '{print$1$6}'|grep volumes|wc -l` #列出卷的数量

#print pathRow

#print volumesPath

#strerror=`ll $volumesPath|grep error` #获取改卷是否有error字符

#判断如果$error不为空则umount出错卷,然后重启服务,mount卷,如果返回为空则endif

for i in NF

do

strerror=`df -h|grep volumes|awk 'NR == i{print$6}'`

str=`ls "$strerror"`


if [ -n "$strerror"]

then

umount "$volumesPath"

service cinder-volume restart

mount -t cetusfs "$volumePath"

fi

done

posted @ 2016-12-01 11:38  007+1  阅读(92)  评论(0编辑  收藏  举报