1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-20 10:50:08 +03:00

F #2095 Send HUP to collectd-client TM=(SSH|LVM) (#2839)

This commit is contained in:
Jan Orel 2019-01-26 01:01:12 +01:00 committed by Ruben S. Montero
parent def9661b4a
commit 16e717ce90
17 changed files with 40 additions and 5 deletions

View File

@ -88,13 +88,12 @@ class CollectdClient
# Collect the Data
ts = Time.now
data = run_probes
# Send signal to itself to run probes and send the data
Process.kill('HUP', $$)
run_probes_time = (Time.now - ts).to_i
# Send the Data
send data
# Sleep during the Cycle
sleep_time = @monitor_push_period - run_probes_time
sleep_time = 0 if sleep_time < 0
@ -130,4 +129,16 @@ sleep rand monitor_push_period
# Start push monitorization
client = CollectdClient.new(hypervisor, number, host, port, probes_args,
monitor_push_period)
Signal.trap('HUP') do
# ignore another HUP until we handle this one
this_handler = Signal.trap('HUP', 'IGNORE')
data = client.run_probes
client.send data
# set the handler back
Signal.trap('HUP', this_handler)
end
client.monitor

View File

@ -994,3 +994,9 @@ function get_nic_information {
OUTBOUND_PEAK_KB="${XPATH_ELEMENTS[j++]}"
ORDER="${XPATH_ELEMENTS[j++]}"
}
function hup_collectd
{
SEND_HUP='kill -HUP `cat /tmp/one-collectd-client.pid` || true'
ssh_exec_and_log_no_error $1 "$SEND_HUP"
}

View File

@ -67,4 +67,4 @@ EOF
)
ssh_exec_and_log $DST_HOST "$delete_file" "Error deleting $DST_PATH"
hup_collectd $DST_HOST

View File

@ -70,5 +70,6 @@ EOF
log "Making filesystem of ${SIZE}M and type $FSTYPE at $DST"
ssh_exec_and_log $DST_HOST "$MKSCRIPT" "Could not create image $DST_PATH"
hup_collectd $DST_HOST
exit 0

View File

@ -43,3 +43,4 @@ fi
ssh_exec_and_log "${SRC_HOST}" "qemu-img resize ${SRC_PATH} ${SIZE}M" \
"Error resizing image ${SRC_PATH}"
hup_collectd $SRC_HOST

View File

@ -142,4 +142,5 @@ EOF
ssh_exec_and_log "$DST_HOST" "$CLONE_CMD" \
"Error cloning $SRC_PATH to $LV_NAME"
hup_collectd $DST_HOST
exit 0

View File

@ -66,5 +66,6 @@ log "Dumping $SRC to $DST"
ssh_exec_and_log "$SRC_HOST" "$DUMP_CMD" \
"Error dumping $SRC to $DST"
hup_collectd $SRC_HOST
exit 0

View File

@ -84,3 +84,5 @@ else
ssh_exec_and_log "$DST_HOST" "$DELETE_CMD" \
"Error deleting $DST_PATH"
fi
hup_collectd $DST_HOST

View File

@ -154,3 +154,6 @@ fi
ssh_exec_and_log "$DST_HOST" "mv $SRC_PATH $DST_PATH" \
"Error moving VM files to another System DS: $SRC_PATH to $DST_PATH in $DST_HOST"
hup_collectd $DST_HOST
hup_collectd $SRC_HOST

View File

@ -75,5 +75,6 @@ ssh_exec_and_log "$SRC_HOST" "$DUMP_CMD" \
LOCK="tm-fs_lvm-${DS_SYS_ID}.lock"
exclusive "${LOCK}" 120 ssh_exec_and_log "$SRC_HOST" "$DELETE_CMD" \
"Error dumping $SRC to $DST"
hup_collectd $SRC_HOST
exit 0

View File

@ -93,3 +93,4 @@ if [ -n "$ORIGINAL_SIZE" -a "$SIZE" -gt "$ORIGINAL_SIZE" ]; then
"Error resizing image $DST"
fi
hup_collectd $DST_HOST

View File

@ -120,5 +120,6 @@ fi
log "Moving $SRC to datastore as $DST"
exec_and_log "$SCP -r $SRC $DST" "Error copying $SRC to $DST"
hup_collectd $SRC_HOST
exit 0

View File

@ -85,5 +85,7 @@ EOF
)
ssh_exec_and_log "$SRC_HOST" "$TAR_SSH" "Error copying disk directory to target host"
hup_collectd $DST_HOST
hup_collectd $SRC_HOST
exit 0

View File

@ -53,6 +53,7 @@ exec_and_log "$SCP -r $SRC $DST" "Error copying $SRC to $DST"
if $SSH $SRC_HOST ls ${SRC_PATH_SNAP} >/dev/null 2>&1; then
exec_and_log "rsync -r --delete ${SRC_HOST}:${SRC_PATH_SNAP}/ ${DST_SNAP}"
hup_collectd $SRC_HOST
fi
exit 0

View File

@ -82,4 +82,5 @@ EOT
ssh_exec_and_log "${SRC_HOST}" "${CMD}" \
"Error creating snapshot ${SNAP_PATH}"
hup_collectd $SRC_HOST

View File

@ -70,4 +70,5 @@ CURRENT_PATH=${DISK_PATH}
ssh_exec_and_log "${SRC_HOST}" "rm ${SNAP_PATH}" \
"Error deleting snapshot ${SNAP_PATH}"
hup_collectd $SRC_HOST

View File

@ -77,4 +77,5 @@ EOF
ssh_exec_and_log "${SRC_HOST}" "${CMD}" \
"Error reverting snapshot to ${SNAP_PATH}"
hup_collectd $SRC_HOST