check_mongodb.py errors
-
monitoreo1
- Posts: 124
- Joined: Wed Feb 18, 2015 10:41 am
check_mongodb.py errors
I need to monitor resources MongoDB .
I may indicate how to resolve the following errors in nagios:
File "/usr/local/nagios/libexec/check_mongodb.py", line 1372, in <module>
sys.exit(main(sys.argv[1:]))
File "/usr/local/nagios/libexec/check_mongodb.py", line 196, in main
err, con = mongo_connect(host, port, ssl, user, passwd, replicaset)
File "/usr/local/nagios/libexec/check_mongodb.py", line 294, in mongo_connect
return exit_with_general_critical(e), None
File "/usr/local/nagios/libexec/check_mongodb.py", line 310, in exit_with_general_critical
if e.strip() == "not master":
AttributeError: 'ConnectionFailure' object has no attribute 'strip'
We are using:
Nagios XI Version : 2014R2.6
x86_64
Red Hat Enterprise Linux Server release 7.0 (Maipo)
Gnome is not installed
I may indicate how to resolve the following errors in nagios:
File "/usr/local/nagios/libexec/check_mongodb.py", line 1372, in <module>
sys.exit(main(sys.argv[1:]))
File "/usr/local/nagios/libexec/check_mongodb.py", line 196, in main
err, con = mongo_connect(host, port, ssl, user, passwd, replicaset)
File "/usr/local/nagios/libexec/check_mongodb.py", line 294, in mongo_connect
return exit_with_general_critical(e), None
File "/usr/local/nagios/libexec/check_mongodb.py", line 310, in exit_with_general_critical
if e.strip() == "not master":
AttributeError: 'ConnectionFailure' object has no attribute 'strip'
We are using:
Nagios XI Version : 2014R2.6
x86_64
Red Hat Enterprise Linux Server release 7.0 (Maipo)
Gnome is not installed
-
jdalrymple
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: check_mongodb.py errors
Instead of me trying to chase your python script around the Internet please post a copy here.
Just as a precurser, it's likely that e is supposed to be set as a string earlier in the script but that's not happening for one reason or another. I can help debug if I can see the script.
Just as a precurser, it's likely that e is supposed to be set as a string earlier in the script but that's not happening for one reason or another. I can help debug if I can see the script.
Re: check_mongodb.py errors
What happens if you run the plugin from the CLI with the 'help' option?
Is there any problem there? What if you pass it some variables to monitor your mongodb server? Use the help page to setup your check properly, below is just an example.
Code: Select all
cd /usr/local/nagios/libexec
./check_mongodb.py -hCode: Select all
./check_mongodb.py -H x.x.x.x -P port -u USER -p PASSWD-
monitoreo1
- Posts: 124
- Joined: Wed Feb 18, 2015 10:41 am
Re: check_mongodb.py errors
I am running the command as follows:
# /usr/local/nagios/libexec/check_mongodb.py -H 150.100.38.228
# /usr/local/nagios/libexec/check_mongodb.py -H 150.100.38.228
Traceback (most recent call last):
File "/usr/local/nagios/libexec/check_mongodb.py", line 1372, in <module>
sys.exit(main(sys.argv[1:]))
File "/usr/local/nagios/libexec/check_mongodb.py", line 196, in main
err, con = mongo_connect(host, port, ssl, user, passwd, replicaset)
File "/usr/local/nagios/libexec/check_mongodb.py", line 294, in mongo_connect
return exit_with_general_critical(e), None
File "/usr/local/nagios/libexec/check_mongodb.py", line 310, in exit_with_general_critical
if e.strip() == "not master":
AttributeError: 'ConnectionFailure' object has no attribute 'strip'
I share the script in this link:
https://www.dropbox.com/s/e6msnz41n4stm ... db.py?dl=0
# /usr/local/nagios/libexec/check_mongodb.py -H 150.100.38.228
# /usr/local/nagios/libexec/check_mongodb.py -H 150.100.38.228
Traceback (most recent call last):
File "/usr/local/nagios/libexec/check_mongodb.py", line 1372, in <module>
sys.exit(main(sys.argv[1:]))
File "/usr/local/nagios/libexec/check_mongodb.py", line 196, in main
err, con = mongo_connect(host, port, ssl, user, passwd, replicaset)
File "/usr/local/nagios/libexec/check_mongodb.py", line 294, in mongo_connect
return exit_with_general_critical(e), None
File "/usr/local/nagios/libexec/check_mongodb.py", line 310, in exit_with_general_critical
if e.strip() == "not master":
AttributeError: 'ConnectionFailure' object has no attribute 'strip'
I share the script in this link:
https://www.dropbox.com/s/e6msnz41n4stm ... db.py?dl=0
-
monitoreo1
- Posts: 124
- Joined: Wed Feb 18, 2015 10:41 am
Re: check_mongodb.py errors
I am relying on the following documentation
Monitoring-MongoDB-Server-With-Nagios-XI
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Monitoring-MongoDB-Server-With-Nagios-XI
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Re: check_mongodb.py errors
Your script matches mine, except the beginning of your script includes:
I am hoping that this was a simple pasting error.
It looks like check_mongodb will fail with syntax errors if it doesn't complete properly. Can you try specifying a username/password along with a database?
If you run the help command, do you get proper output?
Code: Select all
> # /usr/local/nagios/libexec/check_mongodb.py -H 150.100.38.228
> Traceback (most recent call last):
> File "/usr/local/nagios/libexec/check_mongodb.py", line 1372, in <module>
> sys.exit(main(sys.argv[1:]))
> File "/usr/local/nagios/libexec/check_mongodb.py", line 196, in main
> err, con = mongo_connect(host, port, ssl, user, passwd, replicaset)
> File "/usr/local/nagios/libexec/check_mongodb.py", line 294, in mongo_connect
> return exit_with_general_critical(e), None
> File "/usr/local/nagios/libexec/check_mongodb.py", line 310, in exit_with_general_critical
> if e.strip() == "not master":
> AttributeError: 'ConnectionFailure' object has no attribute 'strip'It looks like check_mongodb will fail with syntax errors if it doesn't complete properly. Can you try specifying a username/password along with a database?
Code: Select all
/usr/local/nagios/libexec/check_mongodb.py -H x.x.x.x -u USER -p PASSWD -d DATABASECode: Select all
/usr/local/nagios/libexec/check_mongodb.py -h-
monitoreo1
- Posts: 124
- Joined: Wed Feb 18, 2015 10:41 am
Re: check_mongodb.py errors
The statement is executed successfully:
/usr/local/nagios/libexec/check_mongodb.py -h
The lines are added to the script only as supplementary information
(No output on stdout) stderr: Traceback (most recent call last):
File "/usr/local/nagios/libexec/check_mongodb.py", line 1372, in <module>
sys.exit(main(sys.argv[1:]))
File "/usr/local/nagios/libexec/check_mongodb.py", line 196, in main
err, con = mongo_connect(host, port, ssl, user, passwd, replicaset)
File "/usr/local/nagios/libexec/check_mongodb.py", line 294, in mongo_connect
return exit_with_general_critical(e), None
File "/usr/local/nagios/libexec/check_mongodb.py", line 310, in exit_with_general_critical
if e.strip() == "not master":
AttributeError: 'ConnectionFailure' object has no attribute 'strip'
/usr/local/nagios/libexec/check_mongodb.py -h
The lines are added to the script only as supplementary information
(No output on stdout) stderr: Traceback (most recent call last):
File "/usr/local/nagios/libexec/check_mongodb.py", line 1372, in <module>
sys.exit(main(sys.argv[1:]))
File "/usr/local/nagios/libexec/check_mongodb.py", line 196, in main
err, con = mongo_connect(host, port, ssl, user, passwd, replicaset)
File "/usr/local/nagios/libexec/check_mongodb.py", line 294, in mongo_connect
return exit_with_general_critical(e), None
File "/usr/local/nagios/libexec/check_mongodb.py", line 310, in exit_with_general_critical
if e.strip() == "not master":
AttributeError: 'ConnectionFailure' object has no attribute 'strip'
-
monitoreo1
- Posts: 124
- Joined: Wed Feb 18, 2015 10:41 am
Re: check_mongodb.py errors
I have a question , you must install the agent nrpe my nagios server, the plugin only able to monitor MongoDB resources
Re: check_mongodb.py errors
The check_mongodb.py plugin is used for checking on the status of the service mongodb only - it can be used to check on mongodb-specific things like replication lag and queries. If you don't need to monitor mongodb in that granular of a sense, you can certainly use NRPE to monitor the server in question instead. You can also use a combination of the two plugins (check_nrpe and check_mongodb.py).
Your mongodb plugin is not broken - mine will throw the same errors if the mongodb service is not running on the remote machine, or if Nagios doesn't have access to it:
However if I start the service:
Everything looks good.
Does that all make sense?
Your mongodb plugin is not broken - mine will throw the same errors if the mongodb service is not running on the remote machine, or if Nagios doesn't have access to it:
Code: Select all
[root@localhost libexec]# ./check_mongodb.py -H 192.168.1.1 -u "" -p "" -d admin
Traceback (most recent call last):
File "./check_mongodb.py", line 1372, in <module>
sys.exit(main(sys.argv[1:]))
File "./check_mongodb.py", line 196, in main
err, con = mongo_connect(host, port, ssl, user, passwd, replicaset)
File "./check_mongodb.py", line 294, in mongo_connect
return exit_with_general_critical(e), None
File "./check_mongodb.py", line 310, in exit_with_general_critical
if e.strip() == "not master":
AttributeError: 'ConnectionFailure' object has no attribute 'strip'Code: Select all
[root@localhost libexec]# ./check_mongodb.py -H 192.168.4.109 -u "" -p ""
OK - Connection took 0 secondsDoes that all make sense?
-
monitoreo1
- Posts: 124
- Joined: Wed Feb 18, 2015 10:41 am
Re: check_mongodb.py errors
I share the image on the nagios screen :
https://www.dropbox.com/s/m5j4p9q6s2exz ... B.PNG?dl=0
and
https://www.dropbox.com/s/5lls6ogstf2sa ... 2.PNG?dl=0
When executing the instruction
./check_mongodb.py -H HOSTIP -u "" -p ""
The output is:
(No output on stdout) stderr: Traceback (most recent call last):
File "/usr/local/nagios/libexec/check_mongodb.py", line 1372, in <module>
sys.exit(main(sys.argv[1:]))
File "/usr/local/nagios/libexec/check_mongodb.py", line 196, in main
err, con = mongo_connect(host, port, ssl, user, passwd, replicaset)
File "/usr/local/nagios/libexec/check_mongodb.py", line 294, in mongo_connect
return exit_with_general_critical(e), None
File "/usr/local/nagios/libexec/check_mongodb.py", line 310, in exit_with_general_critical
if e.strip() == "not master":
AttributeError: 'ConnectionFailure' object has no attribute 'strip'
https://www.dropbox.com/s/m5j4p9q6s2exz ... B.PNG?dl=0
and
https://www.dropbox.com/s/5lls6ogstf2sa ... 2.PNG?dl=0
When executing the instruction
./check_mongodb.py -H HOSTIP -u "" -p ""
The output is:
(No output on stdout) stderr: Traceback (most recent call last):
File "/usr/local/nagios/libexec/check_mongodb.py", line 1372, in <module>
sys.exit(main(sys.argv[1:]))
File "/usr/local/nagios/libexec/check_mongodb.py", line 196, in main
err, con = mongo_connect(host, port, ssl, user, passwd, replicaset)
File "/usr/local/nagios/libexec/check_mongodb.py", line 294, in mongo_connect
return exit_with_general_critical(e), None
File "/usr/local/nagios/libexec/check_mongodb.py", line 310, in exit_with_general_critical
if e.strip() == "not master":
AttributeError: 'ConnectionFailure' object has no attribute 'strip'