mirror of
https://github.com/fankes/beszel.git
synced 2025-10-20 02:09:28 +08:00
update alert notification titles
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/mail"
|
"net/mail"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containrrr/shoutrrr"
|
"github.com/containrrr/shoutrrr"
|
||||||
@@ -295,19 +296,24 @@ func (am *AlertManager) HandleSystemAlerts(systemRecord *models.Record, systemIn
|
|||||||
|
|
||||||
func (am *AlertManager) sendSystemAlert(alert SystemAlertData) {
|
func (am *AlertManager) sendSystemAlert(alert SystemAlertData) {
|
||||||
// log.Printf("Sending alert %s: val %f | count %d | threshold %f\n", alert.name, alert.val, alert.count, alert.threshold)
|
// log.Printf("Sending alert %s: val %f | count %d | threshold %f\n", alert.name, alert.val, alert.count, alert.threshold)
|
||||||
|
|
||||||
systemName := alert.systemRecord.GetString("name")
|
systemName := alert.systemRecord.GetString("name")
|
||||||
|
|
||||||
// change Disk to Disk usage
|
// change Disk to Disk usage
|
||||||
if alert.name == "Disk" {
|
if alert.name == "Disk" {
|
||||||
alert.name = "Disk usage"
|
alert.name += " usage"
|
||||||
|
}
|
||||||
|
|
||||||
|
// make title alert name lowercase if not CPU
|
||||||
|
titleAlertName := alert.name
|
||||||
|
if titleAlertName != "CPU" {
|
||||||
|
titleAlertName = strings.ToLower(titleAlertName)
|
||||||
}
|
}
|
||||||
|
|
||||||
var subject string
|
var subject string
|
||||||
if alert.triggered {
|
if alert.triggered {
|
||||||
subject = fmt.Sprintf("%s above threshold on %s", alert.name, systemName)
|
subject = fmt.Sprintf("%s %s above threshold", systemName, titleAlertName)
|
||||||
} else {
|
} else {
|
||||||
subject = fmt.Sprintf("%s below threshold on %s", alert.name, systemName)
|
subject = fmt.Sprintf("%s %s below threshold", systemName, titleAlertName)
|
||||||
}
|
}
|
||||||
minutesLabel := "minute"
|
minutesLabel := "minute"
|
||||||
if alert.min > 1 {
|
if alert.min > 1 {
|
||||||
|
Reference in New Issue
Block a user