From 68bb320caa828ff829c16c96336836740f900894 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Tue, 25 Jun 2024 08:35:18 +0200 Subject: [PATCH] Update 30-monitoring.sh --- .../rootfs/custom-services.d/30-monitoring.sh | 53 +++++++++---------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/birdnet-pi/rootfs/custom-services.d/30-monitoring.sh b/birdnet-pi/rootfs/custom-services.d/30-monitoring.sh index d1bf6307e..ced548eac 100755 --- a/birdnet-pi/rootfs/custom-services.d/30-monitoring.sh +++ b/birdnet-pi/rootfs/custom-services.d/30-monitoring.sh @@ -25,33 +25,32 @@ chown -R pi:pi "$ingest_dir" chmod -R 755 "$ingest_dir" function apprisemessage() { - # Set failed check so it only runs once - touch "$HOME"/BirdNET-Pi/failed_servicescheck - NOTIFICATION="" - STOPPEDSERVICE="
Stopped services: " - services=(birdnet_analysis - chart_viewer - spectrogram_viewer - icecast2 - birdnet_recording - birdnet_log - birdnet_stats) - for i in "${services[@]}"; do - if [[ "$(sudo systemctl is-active "${i}".service)" == "inactive" ]]; then - STOPPEDSERVICE+="${i}; " - fi - done - NOTIFICATION+="$STOPPEDSERVICE" - NOTIFICATION+="
Additional informations: " - NOTIFICATION+="
Since: ${LASTCHECK:-unknown}" - NOTIFICATION+="
System: ${SITE_NAME:-$(hostname)}" - NOTIFICATION+="
Available disk space: $(df -h "$(readlink -f "$HOME/BirdSongs")" | awk 'NR==2 {print $4}')" - if [ -n "$BIRDNETPI_URL" ]; then - NOTIFICATION+="
Access your BirdNET-Pi" - fi - TITLE="BirdNET-Analyzer stopped" - $HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t "$TITLE" -b "${NOTIFICATION}" --input-format=html --config="$HOME/BirdNET-Pi/apprise.txt" + # Set failed check so it only runs once + touch "$HOME"/BirdNET-Pi/failed_servicescheck + NOTIFICATION="" + STOPPEDSERVICE="
Stopped services: " + services=(birdnet_analysis + chart_viewer + spectrogram_viewer + icecast2 + birdnet_recording + birdnet_log + birdnet_stats) + for i in "${services[@]}"; do + if [[ "$(sudo systemctl is-active "${i}".service)" == "inactive" ]]; then + STOPPEDSERVICE+="${i}; " fi + done + NOTIFICATION+="$STOPPEDSERVICE" + NOTIFICATION+="
Additional informations: " + NOTIFICATION+="
Since: ${LASTCHECK:-unknown}" + NOTIFICATION+="
System: ${SITE_NAME:-$(hostname)}" + NOTIFICATION+="
Available disk space: $(df -h "$(readlink -f "$HOME/BirdSongs")" | awk 'NR==2 {print $4}')" + if [ -n "$BIRDNETPI_URL" ]; then + NOTIFICATION+="
Access your BirdNET-Pi" + fi + TITLE="BirdNET-Analyzer stopped" + $HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t "$TITLE" -b "${NOTIFICATION}" --input-format=html --config="$HOME/BirdNET-Pi/apprise.txt" } while true; do @@ -81,7 +80,7 @@ while true; do if ((wavs > 100)) && [[ "$state" == "active" ]]; then sudo systemctl stop "$srv" bashio::log.red "$(date) WARNING stopped $srv service" - if [ -s "$HOME/BirdNET-Pi/apprise.txt" ]; then apprisealert(); fi + if [ -s "$HOME/BirdNET-Pi/apprise.txt" ]; then apprisealert; fi elif ((wavs <= 100)) && [[ "$state" != "active" ]]; then sudo systemctl start $srv bashio::log.yellow "$(date) INFO started $srv service"