Last active
June 13, 2024 13:49
-
-
Save jul/09c98c42d563da6d49d52470e2adac1b to your computer and use it in GitHub Desktop.
shell script to plot all local or one rrd archive on the terminal (requires gnuplot-lite)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
X=${1:-123} | |
Y=${2:-43} | |
STYLE=${3:-'p pt "+"'} | |
[[ "$1" == "-h" ]] && { echo "USAGE: Graph all rrd in the local directory"; exit ; } | |
plot_rrd () { | |
X=${2} | |
Y=${3} | |
STYLE=${4} | |
rdtool fetch $1 AVERAGE~ | |
LC_ALL=C rrdtool fetch $1 AVERAGE |\ | |
perl -ane 'm!^(\d+): ([\d\+\-\.e]+)$! and print "$1 $2\n";'|\ | |
gnuplot -p -e "set xdata time;set terminal dumb $X $Y ; | |
set timefmt \"%s\";set xtics rotate by 45 right; | |
set format x \"%m/%d/%Y %H:%M\"; | |
plot \"-\" using 1:2 with $STYLE " | |
} | |
if [[ "$1" == *rrd ]]; then | |
X=${2:-123} | |
Y=${3:-43} | |
STYLE=${4:-'p pt "+"'} | |
plot_rrd "$1" "$X" "$Y" "$STYLE"; | |
else | |
for i in *rrd; do~ | |
echo "$i"; plot_rrd "$i" $X $Y 'l lines "-"';~ | |
echo "*****************************************************************************************************************************" | |
done 2>/dev/null | less; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment