|
@ -1421,7 +1421,7 @@ cmdline.spec::cmd:vps-stats:run() { |
|
|
opts_rrdfetch+=(-e "$end") |
|
|
opts_rrdfetch+=(-e "$end") |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
local resources=(c.memory c.network load_avg) |
|
|
|
|
|
|
|
|
local resources=(c.memory c.network load_avg disk) |
|
|
if [ -n "${opt_resource}" ]; then |
|
|
if [ -n "${opt_resource}" ]; then |
|
|
resources=(${opt_resource//,/ }) |
|
|
resources=(${opt_resource//,/ }) |
|
|
fi |
|
|
fi |
|
@ -1768,6 +1768,65 @@ graph:def:load_avg() { |
|
|
echo |
|
|
echo |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
graph:def:disk() { |
|
|
|
|
|
local vps="$1" i="$2" |
|
|
|
|
|
shift 2 |
|
|
|
|
|
local opts_rrdfetch=("$@") |
|
|
|
|
|
rrd_vps_path="$VAR_DIR/rrd/$vps" |
|
|
|
|
|
[ -f "$rrd_vps_path/$resource.rrd" ] || { |
|
|
|
|
|
warn "No containers data yet for vps '$vps'... Ignoring" |
|
|
|
|
|
return 0 |
|
|
|
|
|
} |
|
|
|
|
|
gnuplot_line_config=( |
|
|
|
|
|
"set term qt $i title \"$vps $resource\" replotonresize noraise" |
|
|
|
|
|
"set title '$vps'" |
|
|
|
|
|
"set xdata time" |
|
|
|
|
|
"set timefmt '%s'" |
|
|
|
|
|
"set ylabel '${resource//_/\\_} Usage'" |
|
|
|
|
|
"set format y '%s'" |
|
|
|
|
|
"set ytics format '%g GiB'" |
|
|
|
|
|
"set mouse mouseformat 6" |
|
|
|
|
|
"set yrange [0:*] " |
|
|
|
|
|
"set border behind" |
|
|
|
|
|
) |
|
|
|
|
|
printf "%s\n" "${gnuplot_line_config[@]}" |
|
|
|
|
|
first=1 |
|
|
|
|
|
for value in used:2 size:3; do |
|
|
|
|
|
label="${value%:*}" |
|
|
|
|
|
col_num="${value#*:}" |
|
|
|
|
|
rrdfetch_cmd="'< rrdtool fetch \"$rrd_vps_path/$resource.rrd\"" |
|
|
|
|
|
rrdfetch_cmd+=" AVERAGE ${opts_rrdfetch[*]} | \\"$'\n' |
|
|
|
|
|
rrdfetch_cmd+=" tail -n +2 | \\"$'\n' |
|
|
|
|
|
rrdfetch_cmd+=" egrep -v \"^$\" | sed -r \"s/ -?nan/ -/g;s/^([0-9]+): /\\1 /g\"'" |
|
|
|
|
|
rrdfetch_cmd_bash=$(eval echo "${rrdfetch_cmd}") |
|
|
|
|
|
rrdfetch_cmd_bash=${rrdfetch_cmd_bash#< } |
|
|
|
|
|
first_ts= |
|
|
|
|
|
first_ts=$(eval "$rrdfetch_cmd_bash" | head -n 1 | cut -f 1 -d " ") |
|
|
|
|
|
if [ -z "$first_ts" ]; then |
|
|
|
|
|
warn "No data for $resource on vps $vps, skipping..." |
|
|
|
|
|
continue |
|
|
|
|
|
fi |
|
|
|
|
|
last_ts=$(eval "$rrdfetch_cmd_bash" | tail -n 1 | cut -f 1 -d " ") |
|
|
|
|
|
if [[ -z "$data_start_ts" ]] || [[ "$data_start_ts" > "$first_ts" ]]; then |
|
|
|
|
|
data_start_ts="$first_ts" |
|
|
|
|
|
fi |
|
|
|
|
|
if [[ -z "$data_stop_ts" ]] || [[ "$data_stop_ts" < "$last_ts" ]]; then |
|
|
|
|
|
data_stop_ts="$last_ts" |
|
|
|
|
|
fi |
|
|
|
|
|
if [ -n "$first" ]; then |
|
|
|
|
|
first= |
|
|
|
|
|
echo "plot \\" |
|
|
|
|
|
else |
|
|
|
|
|
echo ", \\" |
|
|
|
|
|
fi |
|
|
|
|
|
container="${container//\'/}" |
|
|
|
|
|
container="${container//@/\\@}" |
|
|
|
|
|
echo -n " ${rrdfetch_cmd} u 1:(\$${col_num}/(1024*1024)) w lines title '${label}'" |
|
|
|
|
|
done |
|
|
|
|
|
echo |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|