migrate to new server

This commit is contained in:
2021-04-10 21:04:02 +02:00
parent 23aa879522
commit f1a6e6df86
6 changed files with 20477 additions and 13 deletions
+7 -3
View File
@@ -9,6 +9,7 @@ import (
"io/ioutil"
"log"
"net/http"
"os"
"strconv"
"strings"
"time"
@@ -212,7 +213,7 @@ func InsertAlert(prefix string, deveui string, email string, threshold int) {
_, err := conn.Do("SET", prefix+deveui+":"+email, threshold)
if err != nil {
logit("InsertAlert: Error inserting: " + prefix + deveui + ":" + email)
logit("InsertAlert: Error inserting: " + prefix + deveui + ":" + email)
}
}
@@ -280,7 +281,10 @@ func getLastMetrics(deveui string) OneMetric {
}
// Set headers
req.Header.Set("Authorization", "Token nKYCoz3TA-LItYXG988DjdiStMhrfKmFXQqzxrjzJJ7Ek_iUttzFSE9lfe3s6q99EMdcrjuGlDAjp4Y0VnNRXw==")
var INFLUX_RO_TOKEN = os.Getenv("INFLUX_RO_TOKEN")
// Set headers
req.Header.Set("Authorization", "Token "+INFLUX_RO_TOKEN)
req.Header.Set("accept", "application/csv")
req.Header.Set("content-type", "application/vnd.flux")
@@ -335,7 +339,7 @@ func CheckThreshold(d string, vp int, u2 string, last_metric OneMetric, info_thr
if vp <= alert_threshold {
if AlarmNotAlreadySent("alarm_sent_accu:", d, u2, alert_threshold) {
sendEmailAccu(u2, alias, d, last_metric.BatteryPercent, alert_threshold, "ALARM")
InsertAlert("alarm_sent_accu:", d , u2, alert_threshold)
InsertAlert("alarm_sent_accu:", d, u2, alert_threshold)
}
return false
}