sending notifications on failure.

This commit is contained in:
Jason Kulatunga
2020-10-01 18:59:08 -06:00
parent 1246f5bba9
commit 6377a258f6
4 changed files with 153 additions and 45 deletions
@@ -1,14 +1,12 @@
package handler
import (
"fmt"
"github.com/analogj/scrutiny/webapp/backend/pkg/config"
dbModels "github.com/analogj/scrutiny/webapp/backend/pkg/models/db"
"github.com/analogj/scrutiny/webapp/backend/pkg/notify"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"net/http"
"os"
)
// Send test notification
@@ -17,15 +15,14 @@ func SendTestNotification(c *gin.Context) {
logger := c.MustGet("LOGGER").(logrus.FieldLogger)
testNotify := notify.Notify{
Logger: logger,
Config: appConfig,
Payload: notify.Payload{
Mailer: os.Args[0],
Subject: fmt.Sprintf("Scrutiny SMART error (EmailTest) detected on disk: XXXXX"),
FailureType: "EmailTest",
Device: "/dev/sda",
DeviceType: "ata",
DeviceString: "/dev/sda",
Message: "TEST EMAIL from smartd for device: /dev/sda",
DeviceSerial: "FAKEWDDJ324KSO",
DeviceType: dbModels.DeviceProtocolAta,
DeviceName: "/dev/sda",
Test: true,
},
}
err := testNotify.Send()