ceph-monitor.patch

ceph pool monitoring patch: removed comments - Laurent Grawet, 08/27/2015 12:01 PM

Download (1.52 KB)

View differences:

/var/lib/one/remotes/datastore/ceph/monitor 2015-08-27 13:54:36.147348793 +0200
61 61
fi
62 62

  
63 63
if [ -n "$CEPH_USER" ]; then
64
    RADOS="$RADOS --id ${CEPH_USER}"
64
    CEPH="ceph --id ${CEPH_USER}"
65 65
fi
66 66

  
67 67
# ------------ Compute datastore usage -------------
68 68

  
69 69
MONITOR_SCRIPT=$(cat <<EOF
70
$RADOS df -p ${POOL_NAME}| $AWK '{
71
    if (\$1 == "total") {
72

  
73
        space = int(\$3/1024)
74

  
75
        if      (\$2 == "used")  {var = "USED_MB"}
76
        else if (\$2 == "avail") {var = "FREE_MB"}
77
        else if (\$2 == "space") {var = "TOTAL_MB"}
78

  
79
        print var "=" space
80
    }
81
}'
70
$CEPH df --format xml
82 71
EOF
83 72
)
84 73

  
......
86 75
MONITOR_STATUS=$?
87 76

  
88 77
if [ "$MONITOR_STATUS" = "0" ]; then
89
    echo "$MONITOR_DATA" | tr ' ' '\n'
78
    XPATH="${DRIVER_PATH}/../xpath.rb --stdin"
79
    
80
    unset i j XPATH_ELEMENTS
81

  
82
    while IFS= read -r -d '' element; do
83
        XPATH_ELEMENTS[i++]="$element"
84
    done < <(echo $MONITOR_DATA | $XPATH \
85
                        "/stats/pools/pool[name = \"${POOL_NAME}\"]/stats/bytes_used" \
86
                        "/stats/pools/pool[name = \"${POOL_NAME}\"]/stats/max_avail")
87

  
88
    BYTES_USED="${XPATH_ELEMENTS[j++]}"
89
    MAX_AVAIL="${XPATH_ELEMENTS[j++]}"
90
    FREE="$(expr $MAX_AVAIL - $BYTES_USED)"
91

  
92
    echo "USED_MB=$(($BYTES_USED / 1024**2))
93
          TOTAL_MB=$(($MAX_AVAIL / 1024**2))
94
          FREE_MB=$(($FREE / 1024**2))" | tr -d ' '
90 95
else
91 96
    echo "$MONITOR_DATA"
92 97
    exit $MONITOR_STATUS