mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-30 22:50:10 +03:00
feature #4139: monitor local ds disks with specific probes
This commit is contained in:
parent
a3b38b9b0d
commit
48a714a858
@ -915,6 +915,7 @@ TM_SSH_FILES="src/tm_mad/ssh/clone \
|
||||
src/tm_mad/ssh/snap_delete \
|
||||
src/tm_mad/ssh/snap_revert \
|
||||
src/tm_mad/ssh/monitor \
|
||||
src/tm_mad/ssh/monitor_ds \
|
||||
src/tm_mad/ssh/cpds"
|
||||
|
||||
TM_DUMMY_FILES="src/tm_mad/dummy/clone \
|
||||
|
@ -1,9 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2016, OpenNebula Project, OpenNebula Systems #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
#Arguments: hypervisor ds_location collectd_port monitor_push_period host_id hostname
|
||||
HYPERVISOR=$1
|
||||
DATASTORE_LOCATION=${2:-"/var/lib/one/datastores"}
|
||||
|
||||
DRIVER_PATH=$(dirname $0)
|
||||
REMOTES_DIR="${DRIVER_PATH}/../.."
|
||||
|
||||
mkdir -p "$DATASTORE_LOCATION"
|
||||
|
||||
USED_MB=$(df -B1M -P $DATASTORE_LOCATION 2>/dev/null | tail -n 1 | awk '{print $3}')
|
||||
@ -40,36 +59,12 @@ for ds in $dirs; do
|
||||
echo " FREE_MB = $FREE_MB"
|
||||
echo "]"
|
||||
|
||||
# Skip if datastore is not marked for monitoring (ssh)
|
||||
# Skip if datastore is not marked for local monitoring
|
||||
[ -e "${dir}/.monitor" ] || continue
|
||||
|
||||
vms=$(ls "$dir" | grep '^[0-9]\+$')
|
||||
DRIVER=$(cat ${dir}/.monitor)
|
||||
[ -z "$DRIVER" ] && DRIVER="ssh" # default is ssh
|
||||
|
||||
for vm in $vms; do
|
||||
vmdir="${dir}/${vm}"
|
||||
disks=$(ls "$vmdir" | grep '^disk\.[0-9]\+$')
|
||||
|
||||
[ -z "$disks" ] && continue
|
||||
|
||||
echo -n "VM=[ID=$vm,POLL=\""
|
||||
|
||||
for disk in $disks; do
|
||||
disk_id="$(echo "$disk" | cut -d. -f2)"
|
||||
disk_size="$(du -mL "${vmdir}/${disk}" | awk '{print $1}')"
|
||||
snap_dir="${vmdir}/${disk}.snap"
|
||||
|
||||
echo -n "DISK_SIZE=[ID=${disk_id},SIZE=${disk_size}] "
|
||||
|
||||
if [ -e "$snap_dir" ]; then
|
||||
snaps="$(ls "$snap_dir" | grep '^[0-9]$')"
|
||||
|
||||
for snap in $snaps; do
|
||||
snap_size="$(du -mL "${snap_dir}/${snap}" | awk '{print $1}')"
|
||||
echo -n "SNAPSHOT_SIZE=[ID=${snap},DISK_ID=${disk_id},SIZE=${snap_size}] "
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
echo "\"]"
|
||||
done
|
||||
SCRIPT_PATH="${REMOTES_DIR}/tm/$DRIVER/monitor_ds"
|
||||
[ -e "$SCRIPTS_PATH" ] && "$SCRIPTS_PATH" "$dir"
|
||||
done
|
||||
|
@ -410,8 +410,8 @@ EOF
|
||||
echo "$SSH_EXEC_OUT"
|
||||
}
|
||||
|
||||
# Creates path ($2) at $1. If third parameter is "monitor" creates the
|
||||
# file ".monitor" in the directory. Used for ssh disk monitoring
|
||||
# Creates path ($2) at $1. If there is a third parameter it is writen as
|
||||
# file ".monitor" in the directory. Used for local disk monitoring
|
||||
function ssh_make_path
|
||||
{
|
||||
SSH_EXEC_ERR=`$SSH $1 sh -s 2>&1 1>/dev/null <<EOF
|
||||
@ -419,8 +419,8 @@ set -e
|
||||
if [ ! -d $2 ]; then
|
||||
mkdir -p $2
|
||||
|
||||
if [ "monitor" = "$3" ]; then
|
||||
touch "\$(dirname $2)/.monitor"
|
||||
if [ -n "$3" ]; then
|
||||
echo "$3" > "\$(dirname $2)/.monitor"
|
||||
fi
|
||||
fi
|
||||
EOF`
|
||||
|
@ -53,7 +53,7 @@ DST_HOST=`arg_host $DST`
|
||||
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
ssh_make_path $DST_HOST $DST_DIR "monitor"
|
||||
ssh_make_path $DST_HOST $DST_DIR "ssh"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Get Image information
|
||||
|
@ -64,7 +64,7 @@ if [ "$SRC" == "$DST" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ssh_make_path "$DST_HOST" "$DST_DIR" "monitor"
|
||||
ssh_make_path "$DST_HOST" "$DST_DIR" "ssh"
|
||||
|
||||
log "Moving $SRC to $DST"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user