This commit is contained in:
davidnewhall2 2019-12-29 03:51:08 -08:00
parent 634b470e69
commit 8a73d031a7
4 changed files with 66 additions and 26 deletions

View File

@ -1,10 +1,9 @@
script: echo
script: ./dashboards.sh check
deploy:
- provider: script
script: ./deploy-dashboards.sh
script: ./dashboards.sh deploy
on:
branch: master
env:
matrix:
secure: "JR1XtNTutuh+z+3gkuvwMV2et2iP9YjqFi1CEUJW1thU0byoSAcoMBev12BqIe6eAwd0Y0JvQ62IX46+lygkGmsAclLHHjnLiwXIIJCfUPKTKV+J2WkV0xs6VbNIfXCrJtYN270UZNUswjyR2zkZpkkylEXitqUc9rWDWbxV/3IXpW4/yjUNK+bEP2ZFot8Gg3jqh/HMLEnCI6nXfdIQjGC2WLxlZSdxM27UMKwMQ+4/j2VQM/c0ZL+M/6rz6KMFlmcMoir4AJezGqghPSYnO3YlRAh2Do/6TZiWxKVAeL2i5akZirwAYEfTNh2no5RpPPHNoM9YB/rJ5fwQ2FSRbR4Xk1H35JsNypuqRD5AvErL6CQDRLGeEPQFhHyZGsBtg0qCwxjnKxIWLZc4Ig3v+MpqCE/mvESS/UIyv8nO9+a+8/ZBpiJIP42vEH3RtHFJMoGf85a00Nf/yU27wbMRMBesnSawmEFSFoo4R1MVjevh0QQjzZt703pVT8JEhZdNYAw/AAdSKmBKQBkPl5XVDQ4Vt+/DQhu7KhD8BQoBhz4BKiT8vZa8WczwCowFADlmKcrXTuoh0SwAuIDgFCayhTPO447yaSXFfZG8wO6RulhzsybiOS+oieaTtWVy1ODX4/bd6BqkksR/UwJ3SNeOeLV1SYU2+vAI8poYRK6the4="

63
dashboards.sh Executable file
View File

@ -0,0 +1,63 @@
#/bin/bash
declare -a DASHMAP
WHERE="v2.0.0/"
# Map of grafana.com public shared dashboard ID to filename.
DASHMAP[11312]="UniFi-Poller_ USW Insights - Prometheus.json"
DASHMAP[10417]="UniFi-Poller_ USW Insights - InfluxDB.json"
DASHMAP[11313]="UniFi-Poller_ USG Insights - Prometheus.json"
DASHMAP[10416]="UniFi-Poller_ USG Insights - InfluxDB.json"
DASHMAP[11314]="UniFi-Poller_ UAP Insights - Prometheus.json"
DASHMAP[10415]="UniFi-Poller_ UAP Insights - InfluxDB.json"
DASHMAP[11311]="UniFi-Poller_ Network Sites - Prometheus.json"
DASHMAP[10414]="UniFi-Poller_ Network Sites - InfluxDB.json"
DASHMAP[11315]="UniFi-Poller_ Client Insights - Prometheus.json"
DASHMAP[10418]="UniFi-Poller_ Client Insights - InfluxDB.json"
DASHMAP[11310]="UniFi-Poller_ Client DPI - Prometheus.json"
function check {
SAVEIFS=$IFS
# unobtainium
IFS=$(echo -en "\n\b")
for file in ${WHERE}*; do
found=0
[ "$file" != "${WHERE}README.md" ] || continue
for i in ${!DASHMAP[@]}; do
if [ "${WHERE}${DASHMAP[$i]}" == "$file" ]; then
found=1
echo "found! $file -> $i"
break
fi
done
if [ "$found" = "0" ]; then
IFS=$SAVEIFS
echo "uh oh. file not found in DASHMAP: $file"
exit 2
fi
done
IFS=$SAVEIFS
}
function deploy {
for i in ${!DASHMAP[@]}; do
echo "curl -H \"Content-Type: multipart/form-data\" \
https://grafana.com/api/dashboards/$i/revisions --form \"json=@${WHERE}${DASHMAP[$i]};type=application/json\""
curl -H "Content-Type: multipart/form-data" -H "Authorization: Bearer ${GRAFANA_API_KEY}" \
"https://grafana.com/api/dashboards/$i/revisions" --form "json=@${WHERE}${DASHMAP[$i]};type=application/json"
done
}
if [ "$1" = "deploy" ]; then
deploy
elif [ "$1" = "check" ]; then
check
else
echo "provide command: deploy or check"
exit 1
fi

View File

@ -1,23 +0,0 @@
#/bin/bash
declare -a DASHMAP
WHERE="v2.0.0/"
DASHMAP[11312]="UniFi-Poller_ USW Insights - Prometheus.json"
DASHMAP[10417]="UniFi-Poller_ USW Insights - InfluxDB.json"
DASHMAP[11313]="UniFi-Poller_ USG Insights - Prometheus.json"
DASHMAP[10416]="UniFi-Poller_ USG Insights - InfluxDB.json"
DASHMAP[11314]="UniFi-Poller_ UAP Insights - Prometheus.json"
DASHMAP[10415]="UniFi-Poller_ UAP Insights - InfluxDB.json"
DASHMAP[11311]="UniFi-Poller_ Network Sites - Prometheus.json"
DASHMAP[10414]="UniFi-Poller_ Network Sites - InfluxDB.json"
DASHMAP[11315]="UniFi-Poller_ Client Insights - Prometheus.json"
DASHMAP[10418]="UniFi-Poller_ Client Insights - InfluxDB.json"
for i in ${!DASHMAP[@]}; do
echo "curl -H \"Content-Type: multipart/form-data\" \
https://grafana.com/api/dashboards/$i/revisions --form \"json=@${WHERE}${DASHMAP[$i]};type=application/json\""
curl -H "Content-Type: multipart/form-data" -H "Authorization: Bearer ${GRAFANA_API_KEY}" \
"https://grafana.com/api/dashboards/$i/revisions" --form "json=@${WHERE}${DASHMAP[$i]};type=application/json"
done

1
v2.0.0/README.md Normal file
View File

@ -0,0 +1 @@
These are the production dashboards.