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. 23
      bin/0km

23
bin/0km

@ -1283,6 +1283,7 @@ cmdline.spec::cmd:vps-stats:run() {
return 1 return 1
} }
while true; do while true; do
if ssh:run "root@$vps" -- "[ -d '/var/lib/vps/rrd' ]"; then
echo "${WHITE}Collecting stats${NORMAL}..." echo "${WHITE}Collecting stats${NORMAL}..."
{ {
{ {
@ -1291,6 +1292,9 @@ cmdline.spec::cmd:vps-stats:run() {
set_errlvl "${PIPESTATUS[0]}" set_errlvl "${PIPESTATUS[0]}"
} 3>&1 1>&2 2>&3 | prefix " ${GRAY}|${NORMAL} " } 3>&1 1>&2 2>&3 | prefix " ${GRAY}|${NORMAL} "
echo " ${GRAY}..${NORMAL} ${DARKGREEN}done${NORMAL} collecting stats" 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 [ -z "$opt_follow" ] && break
echo "${WHITE}Sleeping ${DARKYELLOW}${opt_interval:-60}${NORMAL}s..." echo "${WHITE}Sleeping ${DARKYELLOW}${opt_interval:-60}${NORMAL}s..."
sleep "${opt_interval:-60}" sleep "${opt_interval:-60}"
@ -1343,15 +1347,18 @@ cmdline.spec::cmd:vps-stats:run() {
data_stop_ts= data_stop_ts=
for resource in "${resources[@]}"; do for resource in "${resources[@]}"; do
for vps in "${VPS[@]}"; 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++)) ((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
done done
} >&$PFD } >&$PFD

Loading…
Cancel
Save