drewkerrigan/nagios-http-json

Key may not contain ,

Closed this issue · 1 comments

Hi,
we are trying to use your plugin to monitor our ActiveMQ. Unfortunately the batch checking does not work and we now have to create one check / queue.

During the experiments we found that if one of the keys in your json contains a , the python script will fail in line 202 on the split().
E.g. ActiveMQ returns a status key of this form: "org.apache.activemq:brokerName=static-broker-1-master,destinationName=your-queue-name,destinationType=Queue,type=Broker"

As you can see this contians multiple , that you actually cannot get rid of.

There exists a workaround. If you specify the exact queue name and attribute you are looking for in the url the result will just contain a "value" key. This means no bulk checking, though...

What do you think? Is this worth a fix?

Hi, I just tested this and the issue here is the separator, which is . by default

CLI option: [-f SEPARATOR]

See also:

        def test_separator(self):
            rules = RulesHelper()
            rules.separator = '_'
            self.check_data(
                rules.dash_q(
                    ['(0)_gauges_jvm.buffers.direct.capacity(1)_value,1234']),
                '''[{ "gauges": { "jvm.buffers.direct.capacity": [
                {"value": 215415},{"value": 1234}]}}]''',
                OK_CODE)
            self.check_data(
                rules.dash_q(
                    ['(*)_gauges_jvm.buffers.direct.capacity(1)_value,1234']),
                '''[{ "gauges": { "jvm.buffers.direct.capacity": [
                {"value": 215415},{"value": 1234}]}},
                { "gauges": { "jvm.buffers.direct.capacity": [
                {"value": 215415},{"value": 1235}]}}]''',
                WARNING_CODE)