ustream / nagios-consul-plugin

Plugin to integrate consul health checks into nagios
MIT License
24 stars 9 forks source link

At all time getting the help message when execute the script #2

Open sshah-biz opened 7 years ago

sshah-biz commented 7 years ago

This looks good script but whenever I run the command always getting the help message display.

Following is the command I run. python ./check-consul-health.py node --ServiceName=

When I run the health check using consul API with the curl it always works.

Please advice if there is anything wrong in the above command so I can use this nagios plugin.

-Sanjay

pepov commented 7 years ago

Hi!

No there is nothing wrong with the command above and you should be able to use it as is. I just ran the same on my machine with a locally started consul server like this:

docker run -p 8500:8500 -e 'CONSUL_LOCAL_CONFIG={"node_name": "dev"}' consul

It says that there is no matching check, which is good since it at least runs the command and finds the node:

./check-consul-health.py node dev dc1 --ServiceName=asd
There is no matching check!

I've tested it only with python 2.7.

sshah-biz commented 7 years ago

Thank you for quick response. I am using the Pythin version 2.76 (as shown below) python -V Python 2.7.6

Following is response when run the check ./check-consul-health.py node --ServiceName= Usage: check-consul-health.py node NODE DC [--addr=ADDR] [--CheckID=CheckID | --ServiceName=ServiceName] [--verbose] Arguments: NODE the consul node_name DC the consul datacenter Options: -h --help show this -v --verbose verbose output --addr=ADDR consul address [default: http://localhost:8500] --CheckID=CheckID CheckID matcher --ServiceName=ServiceName ServiceName matcher

When I run the curl command - curl -s http://localhost:8500/v1/health/service/?passing=1 | jq .

It print out the detail of service.

Not sure what is happening. If you think of something feel free to advice.

Thank you, Sanjay

pdroz commented 5 years ago

I also get the same thing.. Every time I run the check it just spits the Help screen back out at me.

here's an example of what im running: ./check_consul_health.py node nocon01p1 smf1 --CheckID=serfHealth Usage: check-consul-health.py node NODE DC [--addr=ADDR] [--CheckID=CheckID | --ServiceName=ServiceName] [--verbose] Arguments: NODE the consul node_name DC the consul datacenter Options: -h --help show this -v --verbose verbose output --addr=ADDR consul address [default: http://localhost:8500] --CheckID=CheckID CheckID matcher --ServiceName=ServiceName ServiceName matcher

pepov commented 5 years ago

It must be something with a buggy docopt version or just working differently on your platform but not sure why. It still works for me if I try locally on a Mac with python 2.7 and latest docopt. What platform do you try to run the command?

What is also weird is that the full usage message that you reported only prints for me if I explicitly add the -h flag, but not if I just make a mistake in the options/arguments. So I guess it's not an issue with how you specify the command but rather the help option get's triggered somehow.

pepov commented 5 years ago

What docopt version do you use, also what operating system you try running this on?

pdroz commented 5 years ago

I have not had a chance to test this out, but my theory is things are not working because we have ACL's enabled in our Consul cluster. I don't see anywhere to set a Token parameter and don't see any place in the code where tokens are being passed in with the requests. I imagine if I disable ACL's things will start working.