mongo Data Base Data Monitoring
-
bashar.abed
- Posts: 153
- Joined: Tue Oct 11, 2016 1:34 am
- Location: Ramallah West Bank Palestine
- Contact:
mongo Data Base Data Monitoring
Hi,
please we need your kind help and advice regarding the mongo db data monitoring, we need to read the data and monitor from mongo db and check the stats, reads and the output and monitor it using Nagios for alarming and notifications, so do we have the possibility of doing such things using the current nagios we have, if not, please advise if w need to have specific plugin, extra features or something for doing such monitoring.
kindly note that the Nagios have mongo wizard but it is unhelpful for us
Thanks
please we need your kind help and advice regarding the mongo db data monitoring, we need to read the data and monitor from mongo db and check the stats, reads and the output and monitor it using Nagios for alarming and notifications, so do we have the possibility of doing such things using the current nagios we have, if not, please advise if w need to have specific plugin, extra features or something for doing such monitoring.
kindly note that the Nagios have mongo wizard but it is unhelpful for us
Thanks
Re: mongo Data Base Data Monitoring
Can you be a bit more specific? What kind of stats you would like to be monitoring?
Our MongoDB wizard adds a few checks - MongoDB Database Collections, MongoDB Database Indexes Size, and MongoDB Database Size, however you could add more checks later in the CCM (if needed).
Here's the plugin's usage (help menu):
1. You test your command from the command line, and make sure it works.
2. You add a new command in the Nagios XI.
3. You add a new service.
For more details on how to manage plugins in Nagios XI, please review our documentation on the topic here:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Our MongoDB wizard adds a few checks - MongoDB Database Collections, MongoDB Database Indexes Size, and MongoDB Database Size, however you could add more checks later in the CCM (if needed).
Here's the plugin's usage (help menu):
The way this works is:# ./check_mongodb.py -h
Usage: check_mongodb.py [options]
This Nagios plugin checks the health of mongodb.
Options:
-h, --help show this help message and exit
-H HOST, --host=HOST The hostname you want to connect to
-P PORT, --port=PORT The port mongodb is running on
-u USER, --user=USER The username you want to login as
-p PASSWD, --pass=PASSWD
The password you want to use for that user
-W WARNING, --warning=WARNING
The warning threshold you want to set
-C CRITICAL, --critical=CRITICAL
The critical threshold you want to set
-A ACTION, --action=ACTION
The action you want to take
--max-lag Get max replication lag (for replication_lag action
only)
--mapped-memory Get mapped memory instead of resident (if resident
memory can not be read)
-D, --perf-data Enable output of Nagios performance data
-d DATABASE, --database=DATABASE
Specify the database to check
--all-databases Check all databases (action database_size)
-s, --ssl Connect using SSL
-r, --replicaset Connect to replicaset
-q QUERY_TYPE, --querytype=QUERY_TYPE
The query type to check
[query|insert|update|delete|getmore|command] from
queries_per_second
-c COLLECTION, --collection=COLLECTION
Specify the collection to check
-T SAMPLE_TIME, --time=SAMPLE_TIME
Time used to sample number of pages faults
-M MONGO_VERSION, --mongoversion=MONGO_VERSION
The MongoDB version you are talking with, either 2 or
3
-a AUTHDB, --authdb=AUTHDB
The database you want to authenticate against
--insecure Don't verify SSL/TLS certificates
-f CERT_FILE, --ssl-cert-file=CERT_FILE
Path to PEM encoded key and cert for client
authentication
1. You test your command from the command line, and make sure it works.
2. You add a new command in the Nagios XI.
3. You add a new service.
For more details on how to manage plugins in Nagios XI, please review our documentation on the topic here:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
bashar.abed
- Posts: 153
- Joined: Tue Oct 11, 2016 1:34 am
- Location: Ramallah West Bank Palestine
- Contact:
Re: mongo Data Base Data Monitoring
Hi,
thanks for your response
Let me clarify with more specification regarding what we need, we need to check the mongodb tables entries, for example the number of calls per specific time, number of messages per specific time,…etc
So we need the Nagios to access the mongodb as a DB not as a server and do some queries on the DB and take the needed and configured actions based on the results and output we will have.
So please check it and let us know if its valid or if its applicable in updated Nagios versions.
Thanks
thanks for your response
Let me clarify with more specification regarding what we need, we need to check the mongodb tables entries, for example the number of calls per specific time, number of messages per specific time,…etc
So we need the Nagios to access the mongodb as a DB not as a server and do some queries on the DB and take the needed and configured actions based on the results and output we will have.
So please check it and let us know if its valid or if its applicable in updated Nagios versions.
Thanks
Re: mongo Data Base Data Monitoring
You could pass various options to the "-A" (ACTION) flag - here's a list of possible options:
Here's a couple of examples of checking the number of calls (queries) per second, and number of messages (inserts) per second
You can find more information on the plugin, and some examples of how to set up nagios services here:
https://github.com/mzupan/nagios-plugin-mongodb
Hope this helps. Thank you!
You could also pass various options to the "-q" (QUERY_TYPE) flag:# /usr/local/nagios/libexec/check_mongodb.py -A -h
Usage: check_mongodb.py [options]
check_mongodb.py: error: option -A: invalid choice: '-h' (choose from 'connect', 'connections', 'replication_lag', 'replication_lag_percent', 'replset_state', 'memory', 'memory_mapped', 'lock', 'flushing', 'last_flush_time', 'index_miss_ratio', 'databases', 'collections', 'database_size', 'database_indexes', 'collection_indexes', 'collection_size', 'collection_storageSize', 'queues', 'oplog', 'journal_commits_in_wl', 'write_data_files', 'journaled', 'opcounters', 'current_lock', 'replica_primary', 'page_faults', 'asserts', 'queries_per_second', 'page_faults', 'chunks_balance', 'connect_primary', 'collection_state', 'row_count', 'replset_quorum')
This should give you many different options you can choose from.-q QUERY_TYPE, --querytype=QUERY_TYPE
The query type to check
[query|insert|update|delete|getmore|command] from
queries_per_second
Here's a couple of examples of checking the number of calls (queries) per second, and number of messages (inserts) per second
Code: Select all
/usr/local/nagios/libexec/check_mongodb.py -H <ip address> -A queries_per_second -q insert -u <username> -p <password> --all-databases -D
/usr/local/nagios/libexec/check_mongodb.py -H <ip address> -A queries_per_second -q insert -u <username> -p <password> --all-databases -Dhttps://github.com/mzupan/nagios-plugin-mongodb
Hope this helps. Thank you!
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
bashar.abed
- Posts: 153
- Joined: Tue Oct 11, 2016 1:34 am
- Location: Ramallah West Bank Palestine
- Contact:
Re: mongo Data Base Data Monitoring
Hi,
we need to do select queries (Mongo Database) as below example for oracal DB wizard already exist in our system .
[[email protected] ~]$ /usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib ORACLE_HOME=/usr/lib/oracle/12.2/client64/ /usr/local/nagios/libexec/check_oracle_health --connect '******:1521/*****' --username '********' --password '*******' --mode sql --name="SELECT count(*) FROM ******* a where ****** ='Done' and TRUNC (a.itime) = Trunc (sysdate)" --warning 5800 --critical 6000
OK - select count(*) from ******** ='done' and trunc (a.itime) = trunc (sysdate): 28 | 'select'=28;5800;6000
Thanks
we need to do select queries (Mongo Database) as below example for oracal DB wizard already exist in our system .
[[email protected] ~]$ /usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib ORACLE_HOME=/usr/lib/oracle/12.2/client64/ /usr/local/nagios/libexec/check_oracle_health --connect '******:1521/*****' --username '********' --password '*******' --mode sql --name="SELECT count(*) FROM ******* a where ****** ='Done' and TRUNC (a.itime) = Trunc (sysdate)" --warning 5800 --critical 6000
OK - select count(*) from ******** ='done' and trunc (a.itime) = trunc (sysdate): 28 | 'select'=28;5800;6000
Thanks
Re: mongo Data Base Data Monitoring
I see. Running a query like this doesn't seem possible with this particular plugin. We found a different one on the Nagios Exchange that may do the job for you:
https://exchange.nagios.org/directory/P ... DB/details
We haven't tested it, but looking at the usage:
https://nagios-plugins.org/doc/guidelines.html
https://exchange.nagios.org/directory/P ... DB/details
We haven't tested it, but looking at the usage:
you should be able to run a query. If this doesn't work, then most probably, you would need to write your own plugin. You can refer to the official nagios plugins development guidelines below:]# /usr/local/nagios/libexec/check_mongodb -h
check_mongodb usage:
-u username Example: root
-p password Example: 1234
-h host Example: localhost
-d database Example: local
--collection Example: test
-q query Example: db.test.findOne()
https://nagios-plugins.org/doc/guidelines.html
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
bashar.abed
- Posts: 153
- Joined: Tue Oct 11, 2016 1:34 am
- Location: Ramallah West Bank Palestine
- Contact:
Re: mongo Data Base Data Monitoring
Hi,
thanks for your response
we want to make query on the mongo DB and raise alerts based on query result.
For example, query result will be number represent the count of field in specific period
Thanks
thanks for your response
we want to make query on the mongo DB and raise alerts based on query result.
For example, query result will be number represent the count of field in specific period
Thanks
Re: mongo Data Base Data Monitoring
This should get you up and running, feel free to modify it as you need.
Please unzip the attached file and replace this file on your XI server:
I added the -w and -c options:
Please test an report any issues.
Thank you
Please unzip the attached file and replace this file on your XI server:
Code: Select all
/usr/local/nagios/libexec/check_mongodbCode: Select all
check_mongodb usage:
-u username Example: root
-p password Example: 1234
-h host Example: localhost
-d database Example: local
-q query Example: db.test.count()
-w warning Example: 10
-c critical Example: 10:20
For threshold format see: https://nagios-plugins.org/doc/guidelines.html#THRESHOLDFORMATThank you
You do not have the required permissions to view the files attached to this post.
-
bashar.abed
- Posts: 153
- Joined: Tue Oct 11, 2016 1:34 am
- Location: Ramallah West Bank Palestine
- Contact:
Re: mongo Data Base Data Monitoring
Hi,
thanks for your response i applied the below command as below and we faced the problem
[root@nms libexec]# ./check_mongodb2 -u a**** -p t**** -h 10.*.*.* -d local -q db.statistics.find() -w 40 -c 60
-bash: syntax error near unexpected token `('
You have new mail in /var/spool/mail/root
[root@nms libexec]#
--------------------------------------------------------------------
[root@nms libexec]# ./check_mongodb2
check_mongodb2 usage:
-u username Example: root
-p password Example: 1234
-h host Example: localhost
-d database Example: local
-q query Example: db.test.count()
-w warning Example: 10
-c critical Example: 10:20
For threshold format see: https://nagios-plugins.org/doc/guidelin ... HOLDFORMAT
[root@nms libexec]#
Thanks
thanks for your response i applied the below command as below and we faced the problem
[root@nms libexec]# ./check_mongodb2 -u a**** -p t**** -h 10.*.*.* -d local -q db.statistics.find() -w 40 -c 60
-bash: syntax error near unexpected token `('
You have new mail in /var/spool/mail/root
[root@nms libexec]#
--------------------------------------------------------------------
[root@nms libexec]# ./check_mongodb2
check_mongodb2 usage:
-u username Example: root
-p password Example: 1234
-h host Example: localhost
-d database Example: local
-q query Example: db.test.count()
-w warning Example: 10
-c critical Example: 10:20
For threshold format see: https://nagios-plugins.org/doc/guidelin ... HOLDFORMAT
[root@nms libexec]#
Thanks
Re: mongo Data Base Data Monitoring
Try wrapping the db.statistics.find() section in single quotes:
Did this help?
Code: Select all
./check_mongodb2 -u a**** -p t**** -h 10.*.*.* -d local -q 'db.statistics.find()' -w 40 -c 60Be sure to check out our Knowledgebase for helpful articles and solutions!