-
Notifications
You must be signed in to change notification settings - Fork 30
/
DowntimeData.go
32 lines (28 loc) · 1.1 KB
/
DowntimeData.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package livestatus
import (
"fmt"
"github.com/griesbacher/nagflux/helper"
"github.com/griesbacher/nagflux/logging"
"strings"
)
//DowntimeData adds Comments types to the livestatus data
type DowntimeData struct {
Data
endTime string
}
func (downtime *DowntimeData) sanitizeValues() {
downtime.Data.sanitizeValues()
downtime.endTime = helper.SanitizeInfluxInput(downtime.endTime)
}
//Print prints the data in influxdb lineformat
func (downtime DowntimeData) Print(version float32) string {
downtime.sanitizeValues()
if version >= 0.9 {
tags := ",type=downtime,author=" + downtime.author
start := fmt.Sprintf("%s%s value=\"%s\" %s", downtime.getTablename(), tags, strings.TrimSpace("Downtime start: <br>"+downtime.comment), helper.CastStringTimeFromSToMs(downtime.entryTime))
end := fmt.Sprintf("%s%s value=\"%s\" %s", downtime.getTablename(), tags, strings.TrimSpace("Downtime end: <br>"+downtime.comment), helper.CastStringTimeFromSToMs(downtime.endTime))
return start + "\n" + end
}
logging.GetLogger().Criticalf("This influxversion [%f] given in the config is not supportet", version)
panic("")
}