Browse Source

chg: [0km] make ``vps-stats`` action a little more friendlier in case of missing data

journalctl_limit
Valentin Lab 1 year ago
parent
commit
0ce7bf1b7a
  1. 37
      bin/0km

37
bin/0km

@ -1283,14 +1283,18 @@ cmdline.spec::cmd:vps-stats:run() {
return 1
}
while true; do
echo "${WHITE}Collecting stats${NORMAL}..."
{
if ssh:run "root@$vps" -- "[ -d '/var/lib/vps/rrd' ]"; then
echo "${WHITE}Collecting stats${NORMAL}..."
{
ssh:rsync "root@$vps:/var/lib/vps/rrd/" "${VAR_DIR}/rrd/${vps}"
} 3>&1 1>&2 2>&3 | prefix " ${DARKRED}\!${NORMAL} "
set_errlvl "${PIPESTATUS[0]}"
} 3>&1 1>&2 2>&3 | prefix " ${GRAY}|${NORMAL} "
echo " ${GRAY}..${NORMAL} ${DARKGREEN}done${NORMAL} collecting stats"
{
ssh:rsync "root@$vps:/var/lib/vps/rrd/" "${VAR_DIR}/rrd/${vps}"
} 3>&1 1>&2 2>&3 | prefix " ${DARKRED}\!${NORMAL} "
set_errlvl "${PIPESTATUS[0]}"
} 3>&1 1>&2 2>&3 | prefix " ${GRAY}|${NORMAL} "
echo " ${GRAY}..${NORMAL} ${DARKGREEN}done${NORMAL} collecting stats"
else
warn "No stats found. Did you run 'myc-update' on the vps ?."
fi
[ -z "$opt_follow" ] && break
echo "${WHITE}Sleeping ${DARKYELLOW}${opt_interval:-60}${NORMAL}s..."
sleep "${opt_interval:-60}"
@ -1343,15 +1347,18 @@ cmdline.spec::cmd:vps-stats:run() {
data_stop_ts=
for resource in "${resources[@]}"; do
for vps in "${VPS[@]}"; do
rrd_vps_path="$VAR_DIR/rrd/$vps"
[ -d "$rrd_vps_path" ] || {
warn "No data yet for vps '$vps'... Ignoring"
continue
}
((i++))
out=$(graph:def:"${resource}" "$vps" "$i" "${opts_rrdfetch[@]}")
printf "%s\n" "$out" >/tmp/toto.gnuplot
printf "%s\n" "$out"
{
{
rrd_vps_path="$VAR_DIR/rrd/$vps"
if [ -d "$rrd_vps_path" ]; then
graph:def:"${resource}" "$vps" "$i" "${opts_rrdfetch[@]}"
else
warn "No data yet, ignoring..."
fi
} 3>&1 1>&2 2>&3 | prefix " ${DARKRED}\!${GRAY} graph(${DARKCYAN}$vps${GRAY}:${WHITE}$resource${NORMAL})${NORMAL} "
set_errlvl "${PIPESTATUS[0]}"
} 3>&1 1>&2 2>&3 || continue 1
done
done
} >&$PFD

Loading…
Cancel
Save