omni-lchen / zabbix-mongodb

MIT License
57 stars 72 forks source link

Working Criteria for MongoDB 4.0 with ReplicaSet #17

Open eligiable opened 5 years ago

eligiable commented 5 years ago

This is a Great Script, I've done some modifications according to the following environment:

Below are my configuration:

Appriciate your effort ...

nkgokul commented 5 years ago

Hi @eligiable thanks for sharing your environment. I have a similar set up with the differences being I am using Ubuntu 18.04 and Python 2.7.15rc1

When I run python zabbix-mongodb.py I am getting all the stats and they are being written on the screen. So I am assuming that there are no issues with python versino.

But when I run sh mongodb-stats.sh

I keep getting the following error.

close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr
zabbix_sender [26855]: invalid parameter "/etc/zabbix/zabbix_agentd.conf"

Looks like the issue is when the python script is being called form shell script. Any pointers to fix the issue would be great. Thanks in advance.

eligiable commented 5 years ago

Hi @nkgokul just install zabbix_sender, which is not by default installed with zabbix-agent or zabbix-server.

sudo apt install zabbix_sender and then try,

elton557 commented 4 years ago

Boa tarde,

No meu mongo que é um replica set ele apresenta esse erro [gandalf@node10-mongodb bin]$ sudo vim zabbix-mongodb.py [gandalf@node10-mongodb bin]$ sudo sh -x mongodb-stats.sh ++ get_MongoDB_metrics ++ python3 /usr/local/bin/zabbix-mongodb.py ++ /usr/bin/zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -i - Traceback (most recent call last): File "/usr/local/bin/zabbix-mongodb.py", line 245, in mongodb.get_oplog() File "/usr/local/bin/zabbix-mongodb.py", line 118, in get_oplog if op_first.count() > 0 and op_last.count() > 0: File "/usr/local/lib64/python3.6/site-packages/pymongo/cursor.py", line 787, in count cmd, self.collation, session=self.session) File "/usr/local/lib64/python3.6/site-packages/pymongo/collection.py", line 1600, in _count _cmd, self._read_preference_for(session), session) File "/usr/local/lib64/python3.6/site-packages/pymongo/mongo_client.py", line 1464, in _retryable_read return func(session, server, sock_info, slave_ok) File "/usr/local/lib64/python3.6/site-packages/pymongo/collection.py", line 1594, in _cmd session=session) File "/usr/local/lib64/python3.6/site-packages/pymongo/collection.py", line 250, in _command user_fields=user_fields) File "/usr/local/lib64/python3.6/site-packages/pymongo/pool.py", line 613, in command user_fields=user_fields) File "/usr/local/lib64/python3.6/site-packages/pymongo/network.py", line 159, in command codec_options=codec_options, user_fields=user_fields) File "/usr/local/lib64/python3.6/site-packages/pymongo/message.py", line 1534, in unpack_response self.raw_response(cursor_id) File "/usr/local/lib64/python3.6/site-packages/pymongo/message.py", line 1513, in raw_response error_object) pymongo.errors.OperationFailure: database error: Can't use 'local' database through mongos