Last active
June 13, 2024 17:44
-
-
Save jul/d9713a07718550170e06be13a760c4c1 to your computer and use it in GitHub Desktop.
compare to normalized rrd created by munin (encuring ds name is 42 foreach rra)
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 | |
[ -z "$2" ] && ( echo "give two rrd with a data serie named 42 to compare their series in ratio of first rrd "; exit 1; ) | |
X=${X:-200} | |
Y=${Y:-43} | |
S=${S:-$(( $( date +'%s' ) - ( 24 * 3600 * 7 * 1 ) )) } | |
TRM=${TRM:-"dumb $X $Y"} | |
LC_ALL=C rrdtool xport --json -t -s $S -e now \ | |
DEF:x=$1:42:AVERAGE \ | |
VDEF:y=x,MAXIMUM \ | |
VDEF:l=x,MINIMUM \ | |
CDEF:z=x,l,-,y,l,-,/ \ | |
DEF:a=$2:42:AVERAGE \ | |
VDEF:d=a,MAXIMUM \ | |
VDEF:k=a,MINIMUM \ | |
CDEF:e=a,k,-,d,k,-,/,y,l,-,*,l,+ \ | |
XPORT:x:ratio \ | |
XPORT:e:ratio | \ | |
jq -j -c -r '.data[] | .[0]," ",.[1]," ",.[2], "\n"' - > this.csv | |
gnuplot -p \ | |
-e "set xdata time;set terminal $TRM; | |
set timefmt \"%s\";set xtics rotate by 45 right; | |
set format x \"%m/%d/%Y %H:%M\"; | |
plot \"this.csv\" using 1:2 with l title \"$( echo $1 | tr "_" "-" )\", \ | |
\"this.csv\" using 1:3 with line lines \"-\" title \"$( echo $2 | tr "_" "-" )\" "; | |
# plot the rrd way | |
LC_ALL=C rrdtool graph graph.png --start $S --end now \ | |
-w $(( $X * 4 )) \ | |
-h $(( $Y * 4 )) \ | |
--watermark "`date`" \ | |
--title "$1 vs $2" \ | |
--font DEFAULT:7: \ | |
DEF:x=$1:42:AVERAGE \ | |
DEF:a=$2:42:AVERAGE \ | |
VDEF:y=x,MAXIMUM \ | |
VDEF:l=x,MINIMUM \ | |
CDEF:z=x,l,-,y,l,-,/ \ | |
VDEF:d=a,MAXIMUM \ | |
VDEF:k=a,MINIMUM \ | |
CDEF:e=a,k,-,d,k,-,/,y,l,-,*,l,+ \ | |
LINE1:x#FF00FF:"$1" \ | |
LINE2:e#0000FF:"ratio of $2" \ | |
GPRINT:x:LAST:"Cur\: %5.2lf" \ | |
GPRINT:x:AVERAGE:"Avg\: %5.2lf" \ | |
GPRINT:x:MAX:"Max\: %5.2lf" \ | |
GPRINT:x:MIN:"Min\: %5.2lf" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment