shinken-monitoring / mod-livestatus

Shinken module for presenting data with a MK/Livestatus comptabile interface
GNU Affero General Public License v3.0
15 stars 20 forks source link

When Filtering for an all numeric host_name returns empty #39

Closed openglx closed 9 years ago

openglx commented 10 years ago

I've identified this on a Shinken 2.0.3 install (pip) on CentOS 6.5 x86_64 (Python 2.6.6, CherryPy 3.2.2). We have mod_livestatus and logsqlite enabled on a environment with realms and complete_broker_links enabled, but probably reproducible in the simplest environment possible.

When you query LiveStatusAPI to "GET hosts" and add "Filter: host_name = (all numeric host name)" it returns empty:

echo -e "GET hosts\nFilter: host_name = 19910200\n\n" | nc 0 50000 | hexdump 0000000 000a
0000001 (only one new line returned)

If your host_name has any non-numeric character (doesn't need to be the first), then it returns OK:

echo -e "GET hosts\nFilter: host_name = 00-12300\n\n" | nc 0 50000 | hexdump 0000000 6361 6563 7470 705f 7361 6973 6576 635f 0000010 6568 6b63 3b73 6361 6e6b 776f 656c 6764 0000020 6465 613b 6b63 6f6e 6c77 6465 6567 656d (several lines of output, meaning a complete output)

(NB: use of "hexdump" was just to clarify the output)

I suspect that we are not forcing the "equals to" comparison to be full text ("string"), then something internal fails.

Workaround: I've changed my comparison to be a regular expression (symbol ~) and it now works:

echo -e "GET hosts\nFilter: host_name ~ 19910200\n\n" | nc 0 50000 | hexdump 0000000 6361 6563 7470 705f 7361 6973 6576 635f 0000010 6568 6b63 3b73 6361 6e6b 776f 656c 6764 0000020 6465 613b 6b63 6f6e 6c77 6465 6567 656d (several lines of output, meaning a complete output)

david-guenault commented 10 years ago

thx we will test soon

david-guenault commented 10 years ago

confirmed

titilambert commented 10 years ago

Hello ! could you confirm the version of LiveStatus module ?

openglx commented 10 years ago

It shows as version 1.0 on /var/lib/shinken/inventory/livestatus/package.json

790f92d99890f2dea8c778ffcb884e75  /var/lib/shinken/modules/livestatus/counter.py
9550a2b96c7322402d2881b9aa1396c6  /var/lib/shinken/modules/livestatus/__init__.py
aa2f3a3f690aba17f7e41ec6fc06cc82  /var/lib/shinken/modules/livestatus/livestatus_command_query.py
d56e1634b62a6dc016f45f896a71fed3  /var/lib/shinken/modules/livestatus/livestatus_constraints.py
36c61f32c237aef948775fee12910725  /var/lib/shinken/modules/livestatus/livestatus_counters.py
eb475e9635c0da3a87a6a5e003c73332  /var/lib/shinken/modules/livestatus/livestatus_obj.py
a85a51e8c96f0f145c0567e3dd527241  /var/lib/shinken/modules/livestatus/livestatus_query_cache.py
c79fd3d85dbdf383975bd57c66f9dcef  /var/lib/shinken/modules/livestatus/livestatus_query_metainfo.py
9b01054a6948349767a5e8bda4488cb7  /var/lib/shinken/modules/livestatus/livestatus_query.py
557de60e0b10ba13bce7fa22eaa08093  /var/lib/shinken/modules/livestatus/livestatus_regenerator.py
d428f3d869d15ab335b2ea1be3cfa641  /var/lib/shinken/modules/livestatus/livestatus_request.py
15bdaddbfb16d16edeb8686052b4d9be  /var/lib/shinken/modules/livestatus/livestatus_response.py
f578205ee838cf8117d79622e8883c9d  /var/lib/shinken/modules/livestatus/livestatus_stack.py
e25b3506975aeb91c6e6487993df3dd4  /var/lib/shinken/modules/livestatus/livestatus_wait_query.py
22c1bf4e858a2139f7e4f647c9f070e5  /var/lib/shinken/modules/livestatus/log_line.py
29a9e873312b7e12c4b4633d1dacb0d7  /var/lib/shinken/modules/livestatus/mapping.py
dbd142341d0c5a385778df6cfb9aa301  /var/lib/shinken/modules/livestatus/module.py
olivierHa commented 10 years ago

I think it is forbidden to get a hostname with only numbers :

http://www.zytrax.com/books/dns/apa/names.html

2014-10-30 14:53 GMT+01:00 openglx notifications@github.com:

It shows as version 1.0 on /var/lib/shinken/inventory/livestatus/package.json

790f92d99890f2dea8c778ffcb884e75 /var/lib/shinken/modules/livestatus/counter.py 9550a2b96c7322402d2881b9aa1396c6 /var/lib/shinken/modules/livestatus/init.py aa2f3a3f690aba17f7e41ec6fc06cc82 /var/lib/shinken/modules/livestatus/livestatus_command_query.py d56e1634b62a6dc016f45f896a71fed3 /var/lib/shinken/modules/livestatus/livestatus_constraints.py 36c61f32c237aef948775fee12910725 /var/lib/shinken/modules/livestatus/livestatus_counters.py eb475e9635c0da3a87a6a5e003c73332 /var/lib/shinken/modules/livestatus/livestatus_obj.py a85a51e8c96f0f145c0567e3dd527241 /var/lib/shinken/modules/livestatus/livestatus_query_cache.py c79fd3d85dbdf383975bd57c66f9dcef /var/lib/shinken/modules/livestatus/livestatus_query_metainfo.py 9b01054a6948349767a5e8bda4488cb7 /var/lib/shinken/modules/livestatus/livestatus_query.py 557de60e0b10ba13bce7fa22eaa08093 /var/lib/shinken/modules/livestatus/livestatus_regenerator.py d428f3d869d15ab335b2ea1be3cfa641 /var/lib/shinken/modules/livestatus/livestatus_request.py 15bdaddbfb16d16edeb8686052b4d9be /var/lib/shinken/modules/livestatus/livestatus_response.py f578205ee838cf8117d79622e8883c9d /var/lib/shinken/modules/livestatus/livestatus_stack.py e25b3506975aeb91c6e6487993df3dd4 /var/lib/shinken/modules/livestatus/livestatus_wait_query.py 22c1bf4e858a2139f7e4f647c9f070e5 /var/lib/shinken/modules/livestatus/log_line.py 29a9e873312b7e12c4b4633d1dacb0d7 /var/lib/shinken/modules/livestatus/mapping.py dbd142341d0c5a385778df6cfb9aa301 /var/lib/shinken/modules/livestatus/module.py

— Reply to this email directly or view it on GitHub https://github.com/shinken-monitoring/mod-livestatus/issues/39#issuecomment-61094362 .

david-guenault commented 10 years ago

Yes for dns. But not for shinken hostnames Le 30 oct. 2014 15:43, "Olivier H" notifications@github.com a écrit :

I think it is forbidden to get a hostname with only numbers :

http://www.zytrax.com/books/dns/apa/names.html

2014-10-30 14:53 GMT+01:00 openglx notifications@github.com:

It shows as version 1.0 on /var/lib/shinken/inventory/livestatus/package.json

790f92d99890f2dea8c778ffcb884e75 /var/lib/shinken/modules/livestatus/counter.py 9550a2b96c7322402d2881b9aa1396c6 /var/lib/shinken/modules/livestatus/init.py aa2f3a3f690aba17f7e41ec6fc06cc82 /var/lib/shinken/modules/livestatus/livestatus_command_query.py d56e1634b62a6dc016f45f896a71fed3 /var/lib/shinken/modules/livestatus/livestatus_constraints.py 36c61f32c237aef948775fee12910725 /var/lib/shinken/modules/livestatus/livestatus_counters.py eb475e9635c0da3a87a6a5e003c73332 /var/lib/shinken/modules/livestatus/livestatus_obj.py a85a51e8c96f0f145c0567e3dd527241 /var/lib/shinken/modules/livestatus/livestatus_query_cache.py c79fd3d85dbdf383975bd57c66f9dcef /var/lib/shinken/modules/livestatus/livestatus_query_metainfo.py 9b01054a6948349767a5e8bda4488cb7 /var/lib/shinken/modules/livestatus/livestatus_query.py 557de60e0b10ba13bce7fa22eaa08093 /var/lib/shinken/modules/livestatus/livestatus_regenerator.py d428f3d869d15ab335b2ea1be3cfa641 /var/lib/shinken/modules/livestatus/livestatus_request.py 15bdaddbfb16d16edeb8686052b4d9be /var/lib/shinken/modules/livestatus/livestatus_response.py f578205ee838cf8117d79622e8883c9d /var/lib/shinken/modules/livestatus/livestatus_stack.py e25b3506975aeb91c6e6487993df3dd4 /var/lib/shinken/modules/livestatus/livestatus_wait_query.py 22c1bf4e858a2139f7e4f647c9f070e5 /var/lib/shinken/modules/livestatus/log_line.py 29a9e873312b7e12c4b4633d1dacb0d7 /var/lib/shinken/modules/livestatus/mapping.py dbd142341d0c5a385778df6cfb9aa301 /var/lib/shinken/modules/livestatus/module.py

— Reply to this email directly or view it on GitHub < https://github.com/shinken-monitoring/mod-livestatus/issues/39#issuecomment-61094362>

.

— Reply to this email directly or view it on GitHub https://github.com/shinken-monitoring/mod-livestatus/issues/39#issuecomment-61102925 .

gst commented 9 years ago

I agree that defining an (shinken-)host with only digits in its host_name attribute is rather risky.. for the reason that @olivierHa mention and for the fact that it raised this bug in LS. I'm quite sure it would have others negative consequences in others components of Shinken itself but also with others external softwares connected in a way or another to Shinken.

So I'd be in favor of requesting @openglx to not have shinken-hosts defined with an all numeric host_name... what about simply prefixing the host_name of all your hosts with (say) "host-" ??

openglx commented 9 years ago

@gst I concur, and thus I'm closing this issue as WONTFIX - it is not a bug but a misconfiguration from my side.

Thanks all for your analysis.