sensu-plugins / sensu-plugins-mongodb

This plugin provides native MongoDB instrumentation for monitoring and metrics collection, including: service health, database connectivity, replication lag/status, `oplog` monitoring, collection-specific metrics, and more.

Home Page:http://sensu-plugins.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

check-mongodb.py:23 syntax error

runningman84 opened this issue · comments

I got this issue on a ubuntu 14.04 machine connecting to MongoDB 2.4.x

/opt/sensu/embedded/bin/check-mongodb.py:23:in `load': /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugins-mongodb-0.0.2/bin/check-mongodb.py:46: syntax error, unexpected ':', expecting end-of-input (SyntaxError)
    from /opt/sensu/embedded/bin/check-mongodb.py:23:in `<main>'

@mattyjones I can replicate this as well:

babrams@ip-172-30-150-248:~$ check-mongodb.py -D -W 1 -C 3
/usr/local/bin/check-mongodb.py:23:in `load': /var/lib/gems/1.9.1/gems/sensu-plugins-mongodb-0.0.2/bin/check-mongodb.py:46: syntax error, unexpected ':', expecting $end (SyntaxError)
    from /usr/local/bin/check-mongodb.py:23:in `<main>'

After doing a bit of investigation (not much tbh) it seems its to be related to when ssl was added (not as an option) via commit: a631e53 as I am able to get it work without SSL connections up until that point...I have to start writing some mongo checks shortly so I can try to take a crack at it (possibly even a rewrite in ruby)

I have the old community plugin working:

root@ip-172-30-150-248:~# /etc/sensu/plugins/mongodb/check_mongodb.py -D -W 1 -C 3
OK - Connection took 0 seconds |connection_time=0.0;1.0;3.0

put together potential fix: #10 it needs testing against a mongo server wilth ssl. I will try to test over the weekend but if anyone has one they can test against my repo that would be appreciated.

@runningman84 can you confirm my patch worked for you?

yes it seems to work:

wget https://raw.githubusercontent.com/sge-babrams/sensu-plugins-mongodb/49626e1595e676a7b8e4a3463fdf7116f3a8a414/bin/check-mongodb.py
vagrant@default-ubuntu-1404:/tmp$ ./check-mongodb.py 
No module named pymongo
vagrant@default-ubuntu-1404:/tmp$ sudo apt-get install python-pymongo
vagrant@default-ubuntu-1404:/tmp$ ./check-mongodb.py 
OK - Connection took 0 seconds