1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-24 02:03:52 +03:00

feature #1613: Monitor for ceph datastore

This commit is contained in:
Jaime Melis 2013-07-09 19:09:08 +02:00
parent 622a0edbaf
commit 75ce560742
3 changed files with 75 additions and 1 deletions

View File

@ -1009,6 +1009,7 @@ DATASTORE_DRIVER_CEPH_SCRIPTS="src/datastore_mad/remotes/ceph/cp \
src/datastore_mad/remotes/ceph/mkfs \
src/datastore_mad/remotes/ceph/stat \
src/datastore_mad/remotes/ceph/rm \
src/datastore_mad/remotes/ceph/monitor \
src/datastore_mad/remotes/ceph/clone \
src/datastore_mad/remotes/ceph/ceph.conf"

View File

@ -0,0 +1,72 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
###############################################################################
# This script is used to monitor the free and used space of a datastore
###############################################################################
# -------- Set up the environment to source common tools & conf ------------
if [ -z "${ONE_LOCATION}" ]; then
LIB_LOCATION=/usr/lib/one
else
LIB_LOCATION=$ONE_LOCATION/lib
fi
. $LIB_LOCATION/sh/scripts_common.sh
DRIVER_PATH=$(dirname $0)
source ${DRIVER_PATH}/../libfs.sh
source ${DRIVER_PATH}/ceph.conf
# -------- Get datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
unset i XPATH_ELEMENTS
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/HOST \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/POOL_NAME)
HOST="${XPATH_ELEMENTS[0]}"
POOL_NAME="${XPATH_ELEMENTS[1]}"
# ------------ Compute datastore usage -------------
MONITOR_SCRIPT=$(cat <<EOF
$SUDO $RADOS df | $AWK '{
if (\$1 == "total") {
space = int(\$3/1024)
if (\$2 == "used") {var = "USED_MB" }
else if (\$2 == "avail") {var = "FREE_MB" }
else if (\$2 == "space") {var = "TOTAL_MB" }
print var "=" space
}
}'
EOF
)
ssh_monitor_and_log $HOST "$MONITOR_SCRIPT" | tr ' ' '\n'

View File

@ -36,6 +36,7 @@ MKFS=mkfs
MKISOFS=genisoimage
MKSWAP=mkswap
QEMU_IMG=qemu-img
RADOS=rados
RBD=rbd
READLINK=readlink
RM=rm
@ -334,7 +335,7 @@ EOF`
if [ $SSH_EXEC_RC -ne 0 ]; then
log_error "Command \"$2\" failed: $SSH_EXEC_OUT"
error_message "Cannot moinitor $1"
error_message "Cannot monitor $1"
exit $SSH_EXEC_RC
fi