sni / lmd

Livestatus Multitool Daemon - Create livestatus federation from multiple sources
https://labs.consol.de/omd/packages/lmd/
GNU General Public License v3.0
42 stars 31 forks source link

Added Icinga2 specific columns #67

Closed vanscheijen closed 5 years ago

vanscheijen commented 5 years ago

Adds the address6 column for the hosts table, and check_source for both hosts and services table; when using Icinga2 as peer.

sni commented 5 years ago

You need to add the optional columns at the end, right there when the other optional columns got added.

vanscheijen commented 5 years ago

You need to add the optional columns at the end, right there when the other optional columns got added.

I did that at first, but it results in an immediate error after the first query that needs them:

[2019-04-29 16:48:16.514][Error][peer.go:2953] [Icinga2] Panic: runtime error: index out of range [2019-04-29 16:48:16.514][Error][peer.go:2954] [Icinga2] Version: 1.5.0 (Build: a6d11b4) [2019-04-29 16:48:16.514][Error][peer.go:2955] [Icinga2] goroutine 36 [running]: runtime/debug.Stack(0x8ed160, 0xc0313202f0, 0x2) /usr/lib/go/src/runtime/debug/stack.go:24 +0x9d main.logPanicExitPeer(0xc000247040) /lmd/lmd/peer.go:2955 +0x39f panic(0x919920, 0xdf3fe0) /usr/lib/go/src/runtime/panic.go:522 +0x1b5 main.(Peer).UpdateDeltaTableHosts(0xc000247040, 0xc032bc8000, 0x347, 0x0, 0x0) /lmd/lmd/peer.go:899 +0x9b8 main.(Peer).UpdateDeltaTableFullScan(0xc000247040, 0xc0001cea50, 0xc00d4d1900, 0x40, 0x1, 0xc00d4d1900, 0x40) /lmd/lmd/peer.go:1024 +0x892 main.(Peer).UpdateDeltaTableHosts(0xc000247040, 0xc00d4d1900, 0x40, 0x0, 0x0) /lmd/lmd/peer.go:870 +0x8ee main.(Peer).UpdateDeltaTables(0xc000247040, 0x9a874b) /lmd/lmd/peer.go:822 +0xcb3 main.(Peer).periodicUpdate(0xc000247040, 0xc0002d1ec6, 0xc0002d1ec8) /lmd/lmd/peer.go:435 +0x308 main.(Peer).updateLoop(0xc000247040) /lmd/lmd/peer.go:366 +0x2ad main.(Peer).Start.func1(0xc000247040) /lmd/lmd/peer.go:264 +0x59 created by main.(Peer).Start /lmd/lmd/peer.go:261 +0x1c9

After inserting the optional columns into the alphabetical order I no longer had any issues.

sni commented 5 years ago

could you try again? I reworked internal data storage and added you columns with 457008b.

vanscheijen commented 5 years ago

could you try again? I reworked internal data storage and added you columns with 457008b.

Thank you for the quick response. Unfortunately it now crashes inside buildDowntimeCommentsCache:

[2019-05-06 14:27:24.493][Error][peer.go:2519] [Icinga2] Panic: interface conversion: interface {} is nil, not string [2019-05-06 14:27:24.493][Error][peer.go:2520] [Icinga2] Version: 1.5.0 (Build: 457008b) [2019-05-06 14:27:24.493][Error][peer.go:2521] [Icinga2] goroutine 52 [running]: runtime/debug.Stack(0x8eb080, 0xc012514730, 0x2) /usr/lib/go/src/runtime/debug/stack.go:24 +0x9d main.logPanicExitPeer(0xc00023e000) /lmd/lmd/peer.go:2521 +0x39f panic(0x91bec0, 0xc0119fdb30) /usr/lib/go/src/runtime/panic.go:522 +0x1b5 main.(Peer).buildDowntimeCommentsCache(0xc00023e000, 0x9a49ed, 0x8, 0x1a3) /lmd/lmd/peer.go:2702 +0x4d1 main.(Peer).RebuildCommentsCache(0xc00023e000) /lmd/lmd/peer.go:2676 +0x44 main.(Peer).InitAllTables(0xc00023e000, 0xc00023c090) /lmd/lmd/peer.go:701 +0xff2 main.(Peer).updateLoop(0xc00023e000) /lmd/lmd/peer.go:304 +0x6bb main.(Peer).Start.func1(0xc00023e000) /lmd/lmd/peer.go:234 +0x59 created by main.(Peer).Start /lmd/lmd/peer.go:231 +0x1c9

sni commented 5 years ago

thanks for testing, i will try to find a icinga2 somewhere to test myself. Icinga2s livestatus often returns nil where other livestatus implementations return an empty string.

sni commented 5 years ago

latest HEAD should work fine with icinga2, could you please try again?

vanscheijen commented 5 years ago

Thank you for the overhaul, it is working so much better! Been testing for a few days and only got two types of errors, here are the examples:

[2019-05-27 09:15:26.720][Error][peer.go:2513] [Icinga2] Panic: runtime error: invalid memory address or nil pointer dereference
[2019-05-27 09:15:26.720][Error][peer.go:2514] [Icinga2] Version: 1.5.0 (Build: 50ec4b6)
[2019-05-27 09:15:26.720][Error][peer.go:2515] [Icinga2] goroutine 62 [running]:
runtime/debug.Stack(0x9549c0, 0xc00c7aace0, 0x2)
        /usr/lib/go/src/runtime/debug/stack.go:24 +0x9d
main.logPanicExitPeer(0xc0000941c0)
        /lab/lmd/lmd/peer.go:2515 +0x39f
panic(0x985060, 0xef20c0)
        /usr/lib/go/src/runtime/panic.go:522 +0x1b5
main.(*Peer).UpdateDeltaCommentsOrDowntimes(0xc0000941c0, 0xa22a4f, 0x8, 0x0, 0x0)
        /lab/lmd/lmd/peer.go:1055 +0x197
main.(*Peer).UpdateDeltaTables(0xc0000941c0, 0xa23dfb)
        /lab/lmd/lmd/peer.go:807 +0xc3f
main.(*Peer).periodicUpdate(0xc0000941c0, 0xc073c7bec6, 0xc073c7bec8)
        /lab/lmd/lmd/peer.go:406 +0x2fb
main.(*Peer).updateLoop(0xc0000941c0)
        /lab/lmd/lmd/peer.go:337 +0x29f
main.(*Peer).Start.func1(0xc0000941c0)
        /lab/lmd/lmd/peer.go:235 +0x59
created by main.(*Peer).Start
        /lab/lmd/lmd/peer.go:232 +0x1c9 
[2019-05-27 09:15:26.720][Error][peer.go:2517] [Icinga2] LastQuery:
[2019-05-27 09:15:26.720][Error][peer.go:2518] [Icinga2] GET comments
ResponseHeader: fixed16
OutputFormat: json
KeepAlive: on
Stats: id != -1
Stats: max id

[2019-05-27 09:15:26.720][Error][peer.go:2519] [Icinga2] LastResponse:
[2019-05-27 09:15:26.720][Error][peer.go:2520] [Icinga2] [[572.0,583.0]]
[2019-05-27 09:23:50.684][Error][peer.go:2513] [Icinga2] Panic: runtime error: invalid memory address or nil pointer dereference
[2019-05-27 09:23:50.684][Error][peer.go:2514] [Icinga2] Version: 1.5.0 (Build: 50ec4b6)
[2019-05-27 09:23:50.684][Error][peer.go:2515] [Icinga2] goroutine 1397 [running]:
runtime/debug.Stack(0x9549c0, 0xc03fa17f50, 0x2)
        /usr/lib/go/src/runtime/debug/stack.go:24 +0x9d
main.logPanicExitPeer(0xc00023e000)
        /lab/lmd/lmd/peer.go:2515 +0x39f
panic(0x985060, 0xef20c0)
        /usr/lib/go/src/runtime/panic.go:522 +0x1b5
main.(*DataRow).GetStringList(0x0, 0xc0001d9b80, 0xa22ec7)
        /lab/lmd/lmd/datarow.go:152 +0x41
main.(*DataRow).GetStringList(0xc03fb0c600, 0xc0001ee690, 0xc03c784800)
        /lab/lmd/lmd/datarow.go:156 +0x19b
main.(*Filter).Match(0xc059e67e80, 0xc03fb0c600, 0xc0080f5d00)
        /lab/lmd/lmd/filter.go:443 +0x161
main.(*DataRow).MatchFilter(0xc03fb0c600, 0xc059e67e80, 0xc007647900)
        /lab/lmd/lmd/datarow.go:450 +0x325
main.(*DataRow).MatchFilter(0xc03fb0c600, 0xc059e67f80, 0x0)
        /lab/lmd/lmd/datarow.go:417 +0x9e
main.(*DataRow).MatchFilter(0xc03fb0c600, 0xc05b296080, 0xc000240000)
        /lab/lmd/lmd/datarow.go:417 +0x9e
main.(*Peer).gatherResultRows(0xc00023e000, 0xc0750d1500, 0xc036245e80, 0xc0750d1560)
        /lab/lmd/lmd/peer.go:2385 +0x100
main.(*Peer).BuildLocalResponseData(0xc00023e000, 0xc0750d1500, 0xc0750d1560)
        /lab/lmd/lmd/peer.go:2285 +0x26a
main.(*Response).BuildLocalResponse.func2(0xc0750d1500, 0xc0750d1560, 0xc00023e000, 0xc004248450)
        /lab/lmd/lmd/response.go:504 +0x183
created by main.(*Response).BuildLocalResponse
        /lab/lmd/lmd/response.go:497 +0x23e
jacobbaungard commented 5 years ago

check_source is also present in naemon version of livestatus - how would we go about adding this column to both Naemon and Icinga2?

sni commented 5 years ago

added with 45436f5f7a5