From 0ebebf6430086cb8ea0553869464e762c6584e08 Mon Sep 17 00:00:00 2001 From: Herbert Fischer Date: Mon, 13 Nov 2017 15:24:25 +0100 Subject: [PATCH] Fix output --- event.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/event.go b/event.go index 8244578..64f5ca7 100644 --- a/event.go +++ b/event.go @@ -50,10 +50,15 @@ func newIPMIEvent(stdOutLine string) (*ipmiEvent, error) { return event, nil } +func spacesToUnderscore(str string) string { + return strings.Replace(str, " ", "_", -1) +} + func (ev ipmiEvent) InfluxDB(checkName, hostname string) string { return fmt.Sprintf( - `%s,host="%s",event_id=%s,error_level="%s",event_type="%s",sensor_name="%s" error_message="%s",state=%d %d`, - checkName, hostname, ev.ID, ev.Level, ev.Type, ev.Sensor, ev.Message, ev.State, ev.Time.UnixNano()) + `%s,host=%s,event_type=%s,error_level=%s,sensor_name=%s event_id=%s,error_message="%s",state=%d %d`, + checkName, hostname, spacesToUnderscore(ev.Type), spacesToUnderscore(ev.Level), spacesToUnderscore(ev.Sensor), + ev.ID, ev.Message, ev.State, ev.Time.UnixNano()) } func newEmptyIPMIEvent() *ipmiEvent {