nagios monitor mongodb resolves Nagios interface display null issue

Source: Internet
Author: User

There are many online The introduction of Nagios monitoring MongoDB , but without exception, manual execution python can get the value of the client,the Nagios monitoring interface shown above NULL, for this issue, I have re-encapsulated some of the monitoring options with shell scripts, allowing Nagios to monitor the MongoDB server properly

If you would like to know about the deployment process for Nagios monitoring MongoDB, please click:

Http://www.2cto.com/database/201410/341855.html

Https://github.com/mzupan/nagios-plugin-mongodb/blob/master/README.md


Implementation principle:

Use a shell script to get the value of check_mongodb.py and then pass it to Nagios to implement Nagios warnings

System Environment Variables:

centos5.8 64bit

python2.4.3

Pymongo 1.9

Installing Pymongo

Tar-xvzfpymongo-1.9.tar.gz

CD pymongo-1.9

pythonsetup.py Install

Check if Pymongo is installed

[[Email protected]]# python]

Python2.4.3 (#1, Feb 22 2012, 16:05:45)

[GCC4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2

Type "Help", "copyright", "credits" or "license" for more information.

>>>import Pymongo

>>>pymongo.version

' 1.9 '

>>>import SYS

>>>sys.exit ()

MV nagios-plugin-mongodb-bycsc.zip/usr/local/nagios/libexec/

Unzip Nagios-plugin-mongodb-bycsc.zip

Chown-rnagios:nagios/usr/local/nagios/libexec/nagios-plugin-mongodb

Chmod-r755/usr/local/nagios/libexec/nagios-plugin-mongodb

perform check_mongodb.py to see if it works, as shown below for normal operation

[Email protected]]#./check_mongodb.py-h

。。。 Omitted

-C COLLECTION,--collection=collection

Specify the Collectionto check

-T Sample_time,--time=sample_time

Time used to samplenumber of pages faults

NagiosService configuration:1.nagiosServer root Account Timing task configuration:

For specific parameters please refer to:/usr/local/nagios/libexec/nagios-plugin-mongodb/check_mongodb.sh Script

*/10 * * * */usr/local/nagios/libexec/nagios-plugin-mongodb/check_mongodb.sh 10.0.8.17 all 30000

*/10 * * * */usr/local/nagios/libexec/nagios-plugin-mongodb/check_mongodb.sh 10.0.8.18 all 30000

*/10 * * * */usr/local/nagios/libexec/nagios-plugin-mongodb/check_mongodb.sh 10.0.8.19 all 30000

REDIRECT status check results from above server to /tmp folder using timed tasks

2.nagiosserver-side configuration file configurationcommandsconfiguration file:

Vi/usr/local/nagios/etc/objects/commands.cfg Add:

Definecommand {

Command_name Check_mongodb

command_line/usr/local/nagios/libexec/nagios-plugin-mongodb/check_mongodb.sh ' $HOSTADDRESS $ ' $ARG 1$ ' $ arg2$ '

}

Command commentary:

/usr/local/nagios/libexec/nagios-plugin-mongodb/check_mongodb.sh IP Address monitoring options Ports

check_mongodb.py The monitoring options can be as follows:

usage:check_mongodb.py [Options]

CHECK_MONGODB.PY:ERROR:OPTION-A: Invalid choice: ' MEMORDFD ' (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 ' ', ' 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 ')

currently check_mongodb.sh just configure the ' Connect ' ' Connections ' replset_state ' memory ' option

can refer to README.MD the configuration!

Test Configuration:

Run a command under the Nagios account to check the mongodb server: ( executed under Nagios account)

Su-nagios

# Su-nagios

$/usr/local/nagios/libexec/nagios-plugin-mongodb/check_mongodb.sh 10.0.8.19memory 30000

Ok-memory USAGE:0.04GB resident, 0.78GB virtual, 0.08GB mapped, 0.16GBmappedWithJournal

If the above results are shown, the

WriteNagiosServer-SideMongoDBconfiguration file for the server:

[[Email protected]]# cat/usr/local/nagios/etc/objects/server-8-17.cfg

definehost{

Use Linux-server

HOST_NAME SERVER-8-17

Alias SERVER-8-17

Address 10.0.8.17

}

defineservice{

Use Generic-service

HOST_NAME SERVER-8-17

Service_description SSH

Check_command Check_ssh

}

...... omit other configuration files

# Detection MongoDB connection time of the service

defineservice{

Use Generic-service

HOST_NAME SERVER-8-17

Service_description Check MongoDB Connect 30000

Check_command check_mongodb!connect!30000

}

# Check MongoDB the number of connections

defineservice{

Use Generic-service

HOST_NAME SERVER-8-17

Service_description Check MongoDB connections 30000

Check_command check_mongodb!connections!30000

}

# Check MongoDB Memory Utilization

defineservice{

Use Generic-service

HOST_NAME SERVER-8-17

Service_description Check MongoDB memory 30000

Check_command check_mongodb!memory!30000

}

#mongo Status of Replication

defineservice{

Use Generic-service

HOST_NAME SERVER-8-17

Service_description Check MongoDB Replset State 30000

Check_command check_mongodb!replset_state!30000

}

# Check MongoDB percent Rate of replication complete确保primary和standby的time是一致的

defineservice{

Use Generic-service

HOST_NAME SERVER-8-17

Service_description Check MongoDB replication lag 30000

Check_command check_mongodb!replication_lag!30000

}

Note:

Check raft values Please check the /usr/local/nagios/libexec/nagios-plugin-mongodb/check_mongodb.sh Inside Configuration -w-c Parameters


Upload your own script /usr/local/nagios/libexec/nagios-plugin-mongodb/check_mongodb.sh


nagios monitor mongodb resolves Nagios interface display null issue

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.