From 5cd34ebb4bb570f7e240e9a6825703f97e259696 Mon Sep 17 00:00:00 2001 From: Sheogorath <sheogorath@shivering-isles.com> Date: Wed, 23 Nov 2022 03:07:02 +0100 Subject: [PATCH] feat: Add alert script This patch adds my prometheus-query-exposer script, which allows to query the query-exposer on a regular basis and automatically adjust the LED colour to indicate current alert situation. --- Dockerfile-ubuntu | 10 ++++++---- alerts.sh | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100755 alerts.sh diff --git a/Dockerfile-ubuntu b/Dockerfile-ubuntu index 4ff97519..021e4240 100644 --- a/Dockerfile-ubuntu +++ b/Dockerfile-ubuntu @@ -1,4 +1,4 @@ -FROM ubuntu +FROM docker.io/library/ubuntu:22.04 MAINTAINER Rob Powell <rob.p.tec@gmail.com> ENV DEBIAN_FRONTEND noninteractive @@ -8,8 +8,10 @@ RUN apt-get update RUN apt-get install -y \ build-essential \ pkg-config \ - libudev-dev - + libudev-dev \ + git \ + make \ + curl RUN mkdir /home/blinkdev @@ -23,4 +25,4 @@ RUN make ENV PATH ${HOME}/commandline:${PATH} -CMD ["blink1-tool", "-t 1000", "--random=100"] \ No newline at end of file +CMD ["alerts.sh"] diff --git a/alerts.sh b/alerts.sh new file mode 100755 index 00000000..ef34cd22 --- /dev/null +++ b/alerts.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -x + +QUERY_EXPOSER_URL=${QUERY_EXPOSER_URL:-http://localhost:8080/} + +CODE="$(curl "${QUERY_EXPOSER_URL}")" + +if [ $? -gt 0 ]; then + blink1-tool -m 1000 --rgb=0,0,128 + exit 1 +fi + +if [ "$CODE" = "1" ]; then + blink1-tool -m 1000 --rgb=128,96,0 +elif [ "$CODE" = "2" ]; then + blink1-tool -m 1000 --rgb=128,0,0 +elif [ "$CODE" = "0" ] || [ "$CODE" = "" ]; then + blink1-tool -m 1000 --rgb=0,128,0 +fi -- GitLab