From 94e501397241472d654eb865d9c10b4ef9981989 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zolt=C3=A1n=20Felleg?= Date: Mon, 30 Nov 2020 16:27:04 +0100 Subject: [PATCH] Updated temperature scripts (added heartbeating). --- sources/vhost1.usr/root/temperature.cfg | 8 +++--- sources/vhost1.usr/root/temperature.sh | 35 ++++++++++++++++++++++++- sources/vhost2.usr/root/temperature.cfg | 8 +++--- sources/vhost2.usr/root/temperature.sh | 35 ++++++++++++++++++++++++- 4 files changed, 78 insertions(+), 8 deletions(-) diff --git a/sources/vhost1.usr/root/temperature.cfg b/sources/vhost1.usr/root/temperature.cfg index 30ad422..4193cab 100644 --- a/sources/vhost1.usr/root/temperature.cfg +++ b/sources/vhost1.usr/root/temperature.cfg @@ -1,13 +1,15 @@ MODEM_IP="192.168.8.1" + # zfelleg fschnell rrendek mszabo PHONES=("+36209541513" "+36309502529" "+36309775888" "+36704581234") NUMBER_OF_PHONES=4 -WARNING_PHONES=("+36209541513" "+36309502529" "+36309775888" "+36704581234") -ERROR_PHONES=("+36209541513" "+36309502529" "+36309775888" "+36704581234") -CRITICAL_PHONES=("+36209541513" "+36309502529" "+36309775888" "+36704581234") + HEARTBEAT_PHONES=("+36303744065" "+36309502529" "+36309775888" "+36704581234") +NUMBER_OF_HEARTBEAT_PHONES=4 + WARNING_THRESHOLD=25 ERROR_THRESHOLD=30 CRITICAL_THRESHOLD=35 + HOST_SERIAL=$(hostname | cut -c 6) IMM_FQDN="vhost${HOST_SERIAL}imm.usr.user.hu" diff --git a/sources/vhost1.usr/root/temperature.sh b/sources/vhost1.usr/root/temperature.sh index 9dc4de7..ee8b7d0 100755 --- a/sources/vhost1.usr/root/temperature.sh +++ b/sources/vhost1.usr/root/temperature.sh @@ -103,6 +103,33 @@ log_temperature() { echo "${STR_DATE}: ${MESSAGE_TYPE}: $TEMPERATURE" | tee -a /tmp/temperature-${PRG_DATE}.log } +send_heartbeat_sms() { + MESSAGE_TYPE=$1 + TEMPERATURE=$2 + + + MESSAGE="Heartbeat ${MESSAGE_TYPE}: temperature is $TEMPERATURE" + SMS_TARGETS="" + i=0 + while [ $i -lt $NUMBER_OF_HEARTBEAT_PHONES ] + do + SMS_TARGETS="${SMS_TARGETS}${HEARTBEAT_PHONES[$i]}" + i=$(( $i + 1 )) + done + + curl --silent --request GET "http://$MODEM_IP/api/webserver/SesTokInfo" >ses_tok.xml + + SESSION_ID=$(sed 's|^.*\(.*\).*$|\1|' \(.*\).*$|\1|' -1${SMS_TARGETS}${MESSAGE}-11-1" \ + http://$MODEM_IP/api/sms/send-sms +} + send_sms() { MESSAGE_TYPE=$1 TEMPERATURE=$2 @@ -167,6 +194,12 @@ then exit 0 fi +DAY_HOUR_MINUTE=$(date "+%u%H%M") +if [ "$DAY_HOUR_MINUTE" == "21000" ] +then + send_heartbeat_sms $MESSAGE_TYPE $TEMPERATURE +fi + MINUTE_LASTDIGIT=$(date "+%M" | cut -c 2) case "$MINUTE_LASTDIGIT" in "1" | "3" | "5" | "7" | "9") @@ -192,5 +225,5 @@ then fi delete_logs delete_mail -delete_sent_smses delete_received_smses +delete_sent_smses diff --git a/sources/vhost2.usr/root/temperature.cfg b/sources/vhost2.usr/root/temperature.cfg index 30ad422..4193cab 100644 --- a/sources/vhost2.usr/root/temperature.cfg +++ b/sources/vhost2.usr/root/temperature.cfg @@ -1,13 +1,15 @@ MODEM_IP="192.168.8.1" + # zfelleg fschnell rrendek mszabo PHONES=("+36209541513" "+36309502529" "+36309775888" "+36704581234") NUMBER_OF_PHONES=4 -WARNING_PHONES=("+36209541513" "+36309502529" "+36309775888" "+36704581234") -ERROR_PHONES=("+36209541513" "+36309502529" "+36309775888" "+36704581234") -CRITICAL_PHONES=("+36209541513" "+36309502529" "+36309775888" "+36704581234") + HEARTBEAT_PHONES=("+36303744065" "+36309502529" "+36309775888" "+36704581234") +NUMBER_OF_HEARTBEAT_PHONES=4 + WARNING_THRESHOLD=25 ERROR_THRESHOLD=30 CRITICAL_THRESHOLD=35 + HOST_SERIAL=$(hostname | cut -c 6) IMM_FQDN="vhost${HOST_SERIAL}imm.usr.user.hu" diff --git a/sources/vhost2.usr/root/temperature.sh b/sources/vhost2.usr/root/temperature.sh index 9dc4de7..ee8b7d0 100755 --- a/sources/vhost2.usr/root/temperature.sh +++ b/sources/vhost2.usr/root/temperature.sh @@ -103,6 +103,33 @@ log_temperature() { echo "${STR_DATE}: ${MESSAGE_TYPE}: $TEMPERATURE" | tee -a /tmp/temperature-${PRG_DATE}.log } +send_heartbeat_sms() { + MESSAGE_TYPE=$1 + TEMPERATURE=$2 + + + MESSAGE="Heartbeat ${MESSAGE_TYPE}: temperature is $TEMPERATURE" + SMS_TARGETS="" + i=0 + while [ $i -lt $NUMBER_OF_HEARTBEAT_PHONES ] + do + SMS_TARGETS="${SMS_TARGETS}${HEARTBEAT_PHONES[$i]}" + i=$(( $i + 1 )) + done + + curl --silent --request GET "http://$MODEM_IP/api/webserver/SesTokInfo" >ses_tok.xml + + SESSION_ID=$(sed 's|^.*\(.*\).*$|\1|' \(.*\).*$|\1|' -1${SMS_TARGETS}${MESSAGE}-11-1" \ + http://$MODEM_IP/api/sms/send-sms +} + send_sms() { MESSAGE_TYPE=$1 TEMPERATURE=$2 @@ -167,6 +194,12 @@ then exit 0 fi +DAY_HOUR_MINUTE=$(date "+%u%H%M") +if [ "$DAY_HOUR_MINUTE" == "21000" ] +then + send_heartbeat_sms $MESSAGE_TYPE $TEMPERATURE +fi + MINUTE_LASTDIGIT=$(date "+%M" | cut -c 2) case "$MINUTE_LASTDIGIT" in "1" | "3" | "5" | "7" | "9") @@ -192,5 +225,5 @@ then fi delete_logs delete_mail -delete_sent_smses delete_received_smses +delete_sent_smses -- 2.54.0