-
Notifications
You must be signed in to change notification settings - Fork 30
/
DowntimeData.go
37 lines (32 loc) · 1.28 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
33
34
35
36
37
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)
}
//PrintForInfluxDB prints the data in influxdb lineformat
func (downtime DowntimeData) PrintForInfluxDB(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("")
}
//PrintForElasticsearch prints in the elasticsearch json format
func (downtime DowntimeData) PrintForElasticsearch(version float32, index string) string {
return ""
}