package main
import (
"database/sql"
"encoding/json"
"fmt"
"io"
"math/rand"
"net/http"
_ "os"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
)
type Alert struct {
Receiver string `json:"receiver"`
Status string `json:"status"`
Alerts []Alerts `json:"alerts"`
}
type Alerts struct {
Status string `json:"status"`
Labels Labels `json:"labels"`
Annotations Annotations `json:"annotations"`
StartsAt string `json:"startsAt"`
EndsAt string `json:"endsAt"`
GeneratorURL string `json:"generatorURL"`
Fingerprint string `json:"fingerprint"`
}
type Labels struct {
Alertname string `json:"name"`
Device string `json:"device"`
FSType string `json:"fstype"`
Instance string `json:"instance"`
Job string `json:"job"`
MountPoint string `json:"mountpoint"`
Severity string `json:"severity"`
System string `json:"system"`
Yunyingshang string `json:"yunyingshang"`
Judian string `json:"judian"`
}
type Annotations struct {
Description string `json:"description"`
Summary string `json:"summary"`
}
type Alarm struct {
IP string
System string
ISP string
Desc string
Judian string
Summary string
}
func NewAlarm(value Alerts) Alarm {
isp := value.Labels.Yunyingshang
if len(isp) == 0 {
isp = "wa"
}
ip := strings.Split(value.Labels.Ins
09-06
526
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)