+ configurable color values for bars

master
Dominika Liberda 2021-06-17 13:20:36 +02:00
parent 363946c9a5
commit 8406cbedf8
2 changed files with 15 additions and 8 deletions

View File

@ -1,8 +1,15 @@
## app config
## your application-specific config goes here!
## DownTimeRobot app config
# DO NOT MODIFY THIS FILE!
# This file can be changed upstream as new features get added in. Instead,
# please use files under ../config/, especially master.sh.
cfg[useragent]="dtr/1.0 (https://git.sakamoto.pl/domi/dtr)"
cfg[bar_ok]=70 # below this level, pings are shown as green
cfg[bar_info]=200 # below this, they're yellow
cfg[bar_warn]=500 # below this, they're orange, and above, they're red (fail)
worker_add every_1min 60
worker_add every_5min 300
worker_add every_30min 1800

View File

@ -60,21 +60,21 @@ for i in $timedata; do
if [[ "$type" != "ping" ]]; then
echo -n '<div class="bar '
if [[ "$i" == 1 ]]; then
echo "green"
echo -n "green"
elif [[ "$i" == 0 ]]; then
echo "vermillion"
echo -n "vermillion"
else
echo "vermillion"
echo -n "vermillion"
fi
echo '" title=""></div>'
else
n="$(sed -E 's/\..*//' <<< "$i")"
echo -n '<div class="bar '
if [[ "$n" -lt 75 ]]; then
if [[ "$n" -lt "${cfg[bar_ok]}" ]]; then
echo -n "green"
elif [[ "$n" -lt 250 ]]; then
elif [[ "$n" -lt "${cfg[bar_info]}" ]]; then
echo -n "yellow"
elif [[ "$n" -lt 500 ]]; then
elif [[ "$n" -lt "${cfg[bar_warn]}" ]]; then
echo -n "orange"
else
echo -n "vermillion"