Griesbacher / nagflux

A connector which copies performancedata from Nagios / Icinga(2) / Naemon to InfluxDB
GNU General Public License v2.0
65 stars 32 forks source link

Empty NAGFLUX:TAG #27

Closed datamuc closed 7 years ago

datamuc commented 7 years ago

The service_perfdata_file_template has \tNAGFLUX:TAG::$_SERVICENAGFLUX_TAG$ appended to it. The problem is, that now every service needs some sane value for it. Otherwise nagflux fails to parse the line:

metrics,host=localhost,service=Swap,command=check_local_swap,performanceLabel=swap,$_SERVICENAGFLUX_TAG$=,warn-fill=none,crit-fill=none,unit=MB value=974.0,warn=308.0,crit=205.0,min=0.0,max=1027.0 1487770865000

because the macro doesn't get expanded:

DATATYPE::SERVICEPERFDATA   TIMET::1487771589   HOSTNAME::localhost SERVICEDESC::Swap   SERVICEPERFDATA::swap=974MB;308;205;0;1027  SERVICECHECKCOMMAND::check_local_swap!30%!20%   HOSTSTATE::UP   HOSTSTATETYPE::HARD SERVICESTATE::OK    SERVICESTATETYPE::HARD  NAGFLUX:TAG::$_SERVICENAGFLUX_TAG$

I've tried to define a parent service with an empty _NAGFLUX_TAG which leads to nagflux crashes:

panic: assignment to entry in nil map

goroutine 165 [running]:
panic(0x70a4e0, 0xc4201373c0)
        /opt/projects/omd/rpm.topdir/BUILD/omd-2.21.20161208-labs-edition/packages/go-1.7/go-1.7.3/src/runtime/panic.go:500 +0x1a1
github.com/griesbacher/nagflux/collector/spoolfile.(*NagiosSpoolfileWorker).PerformanceDataIterator.func1(0xc42047fbf0, 0x76a86b, 0x7, 0xc42044c059, 0x13, 0xc42044c0bd, 0x11, 0xc420137383, 0xd, 0xc4201ca3c0, ...)
        /opt/projects/omd/rpm.topdir/BUILD/omd-2.21.20161208-labs-edition/packages/nagflux/go/src/github.com/griesbacher/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go:214 +0xc8e
created by github.com/griesbacher/nagflux/collector/spoolfile.(*NagiosSpoolfileWorker).PerformanceDataIterator
        /opt/projects/omd/rpm.topdir/BUILD/omd-2.21.20161208-labs-edition/packages/nagflux/go/src/github.com/griesbacher/nagflux/collector/spoolfile/nagiosSpoolfileWorker.go:245 +0x4f6

The field NAGFLUX:TAG field looks like this in the crashing case: NAGFLUX:TAG::. I guess a sane way would be to treat the field value NAGFLUX::TAG:: as if the field wasn't there at all.

Griesbacher commented 7 years ago

Sounds good to me. I'll figure something out. Just give me some time, I'm currently out of office.

Griesbacher commented 7 years ago
NAGFLUX:TAG::$_SERVICENAGFLUX_TAG$

as well as

NAGFLUX:TAG::

will be ignored now. The first, because there is no "=" within the data and the second because it's empty.