Created
May 16, 2017 01:44
-
-
Save stellarhopper/f52ac8205acd6a429fc742815113be54 to your computer and use it in GitHub Desktop.
lanfest-weathermap-creator
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
#!/bin/bash | |
out="weathermap.conf" | |
rrd_start=41 | |
gen_header() | |
{ | |
cat << EOF | |
HTMLSTYLE overlib | |
WIDTH 800 | |
HEIGHT 600 | |
BACKGROUND LANFestNetworkBackground.png | |
HTMLOUTPUTFILE weathermap.html | |
IMAGEOUTPUTFILE weathermap.png | |
NODE seat | |
LABELFONT 1 | |
USESCALE seat | |
EOF | |
} | |
gen_footer() | |
{ | |
cat <<- EOF | |
SCALE seat 1 2 0 255 0 255 0 0 | |
EOF | |
} | |
gen_node() | |
{ | |
local node="$1" | |
local x_pos="$2" | |
local y_pos="$3" | |
local rrd="$4" | |
cat << EOF | |
NODE $node | |
TEMPLATE seat | |
POSITION $x_pos $y_pos | |
LABEL $node | |
TARGET gauge:/var/lib/cacti/rra/lanfest-core_int_status_${rrd}.rrd:int_status:- | |
EOF | |
} | |
gen_header > $out | |
rows=( A B C D E F G H ) | |
n_seats=36 | |
x_jmp=( 71 87 71 72 71 90 72 ) | |
y_jmp=24 | |
x=200 | |
rrd=$((rrd_start - 1)) | |
rrd_jmp=18 | |
rrd_brk=18 | |
for (( i=0; i<${#rows[@]}; i++ )); do | |
row=${rows[$i]} | |
y=107 | |
for (( j=1; j<=$n_seats; j++ )); do | |
gen_node "${row}${j}" "$x" "$((y+=y_jmp))" "$((rrd+=1))" >> $out | |
[ $j -eq $rrd_brk ] && rrd=$((rrd+rrd_jmp)) | |
done | |
rrd=$((rrd - (2*rrd_jmp*(1-(i%2))))) | |
x=$((x + ${x_jmp[$((i%${#x_jmp[@]}))]} )) | |
done | |
gen_footer >> $out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment