Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working Criteria for MongoDB 4.0 with ReplicaSet #17

Open
eligiable opened this issue Jan 9, 2019 · 3 comments
Open

Working Criteria for MongoDB 4.0 with ReplicaSet #17

eligiable opened this issue Jan 9, 2019 · 3 comments

Comments

@eligiable
Copy link

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

  • AWS
  • Ubuntu 16.04
  • Zabbix Agent 3.4
  • MongoDB 4
  • Python3

Below are my configuration:

  • Installing PyMongo
    sudo apt-get install build-essential python-dev python3-pip
    sudo pip3 install pymongo
  • Installing Zabbix_Sender
    sudo apt-get install zabbix-sender
  • Change python to python3 in mongodb-stats.sh
    python /usr/local/bin/zabbix-mongodb.py -- to --> python3 /usr/local/bin/zabbix-mongodb.py
  • Change Parameters under class MongoDB(object), in case of ReplicaSet
    self.mongo_host = "hostname"
  • Provide Credentials if you have enabled Security
    self.mongo_user = "username"
    self.mongo_password = "password"

Appriciate your effort ...

@nkgokul
Copy link

nkgokul commented Jan 29, 2019

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
Copy link
Author

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
Copy link

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

  • result='sent: 0; skipped: 0; total: 0'
    ++ echo 'sent: 0; skipped: 0; total: 0'
    ++ awk -F ';' '$1 ~ /^info/ && match($1,/[0-9].*$/) {sum+=substr($1,RSTART,RLENGTH)} END {print sum}'
  • response=
  • '[' -n '' ']'
  • echo 'sent: 0; skipped: 0; total: 0'
    sent: 0; skipped: 0; total: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants