Skip to content

Commit

Permalink
Autodetect monitoring format
Browse files Browse the repository at this point in the history
  • Loading branch information
kvaps committed Nov 11, 2021
1 parent c98e571 commit 0b460d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 0 additions & 4 deletions datastore/linstor_un/linstor_un.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,3 @@ DD_CONV=sparse
# temporarily during the create/mkfs processes. This directoy MUST exist,
# have enough space and be writeable by 'oneadmin'
STAGING_DIR=/var/tmp

# OpenNebula 5.12+ changed the monitoring data format
# Set to 1 for OpenNebula 5.10 and below
#LEGACY_MONITORING=1
9 changes: 7 additions & 2 deletions datastore/linstor_un/linstor_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ linstor_monitor_storpool() {
# @param $3 the ID of system datastore (to monitor)
#--------------------------------------------------------------------------------
linstor_monitor_resources() {
if [ -d "${0%/*}/../../im/kvm-probes.d/vm/monitor" ]; then
MONITOR_TAG=MONITOR
else
MONITOR_TAG=POLL
fi
echo "$1" "$2" | $JQ -rs "$(cat <<EOT
[
[
Expand All @@ -60,14 +65,14 @@ linstor_monitor_resources() {
]
| group_by(.vm_id)
| .[]
| "VM = [ ID = \(.[0].vm_id), $(test "$LEGACY_MONITORING" = 1 && echo POLL || echo MONITOR) = \"\(
| "VM = [ ID = \(.[0].vm_id), $MONITOR_TAG = \"\(
[
.[] | "DISK_SIZE=[ID=\(.disk_id),SIZE=\(.size/1024|tostring|split(".")[0])]",
(
.snapshots[] | "SNAPSHOT_SIZE=[ID=\(.snapshot_id),DISK_ID=\(.disk_id),SIZE=\(.size|tonumber/1024|tostring|split(".")[0])]"
)
]
| join(" ") $(test "$LEGACY_MONITORING" = 1 || echo "| @base64") +"\" ]"
| join(" ") $(test "$MONITOR_TAG" != MONITOR || echo "| @base64") +"\" ]"
)"
EOT
)"
Expand Down

0 comments on commit 0b460d2

Please sign in to comment.