Некоторые проверки не удались
CI / test (push) Successful in 2m5s
Docker / Build and publish worker image (push) Failing after 31s
54 строки
1.8 KiB
Go
54 строки
1.8 KiB
Go
package notifyrender
|
|
|
|
import (
|
|
"bytes"
|
|
"html/template"
|
|
|
|
"rocketgit.ru/rsmon/worker/app/models"
|
|
)
|
|
|
|
var (
|
|
// DownOneSubject provides functionality.
|
|
DownOneSubject *template.Template
|
|
// DownOneBody provides functionality.
|
|
DownOneBody *template.Template
|
|
// DownOneHTML provides functionality.
|
|
DownOneHTML *template.Template
|
|
)
|
|
|
|
func init() {
|
|
DownOneSubject = template.Must(template.New("down_one_subject").Parse(`Не доступен {{.Monitor.GetLabel}}`))
|
|
// DownOneBody provides functionality.
|
|
DownOneBody = template.Must(template.New("down_one_body").Parse(`Монитор {{.Monitor.GetLabel}} не доступен :warning:
|
|
|
|
Проверки: {{.ChecksDown}}.
|
|
Ошибка: {{.Reason}}
|
|
|
|
Начало события: {{.StartTime.Format "02.01.2006 15:04:05"}}
|
|
|
|
Недоступные проверки:
|
|
{{range .Checks}}
|
|
{{.Kind}} - {{if .Name}}{{.Name}}{{else}}Нет имени{{end}} - {{if .URL}}{{.URL}}{{else}}URL не указан{{end}} {{if .Error}}({{.Error}}){{end}}
|
|
{{end}}`))
|
|
|
|
DownOneHTML = template.Must(template.New("down_one_html").Parse(`<h4>Монитор {{.Monitor.GetLabel}} не доступен</h4>
|
|
|
|
Проверки: {{.ChecksDown}}.
|
|
<h5 style='background-color: red;'>Ошибка:</h5>
|
|
{{.Reason}}
|
|
|
|
<div>Начало события: {{.StartTime.Format "02.01.2006 15:04:05"}}</div>
|
|
|
|
<h5>Недоступные проверки:<h5>
|
|
{{range .Checks}}
|
|
<div>
|
|
{{.Kind}} - {{if .Name}}{{.Name}}{{else}}Нет имени{{end}} - {{if .URL}}{{.URL}}{{else}}URL не указан{{end}} {{if .Error}}({{.Error}}){{end}}
|
|
</div>
|
|
{{end}}`))
|
|
}
|
|
|
|
// TextDownOne provides functionality.
|
|
func TextDownOne(event *models.Event) (bytes.Buffer, bytes.Buffer, bytes.Buffer, bytes.Buffer) {
|
|
return executeTemplates(event, DownOneSubject, DownOneBody, DownOneHTML, " :warning:")
|
|
}
|