[CACTI] MongoDB performance monitoring combat

Source: Internet
Author: User
Tags mongodb commands mongodb monitoring mongodb performance monitoring mongodb server parse error ssh port



Preface:

to better use MongoDB, you need to monitor some of the underlying usage of mongodb, such as flush number, number of connections, memory usage, index operation, slave delay, and so on, which can be done by configuring cacti to monitor MongoDB.

1, Import Template in cacti interface

On the computer locally, download this tgz package: http://mysql-cacti-templates.googlecode.com/files/better-cacti-templates-1.1.8.tar.gz

Unzip to any directory, then open the Cacti Web interface, select "Import/export"-"Improt Templates", click "Select File" and Cacti_host_template_x_mongodb_server_ht_ 0.8.6i-sver1.1.8.xml, import into the cacti, so that cacti graphics template can choose to use MongoDB Graphics project.


2, configure the monitoring script on the cacti server side

[Email protected] soft]# wget http://mysql-cacti-templates.googlecode.com/files/better-cacti-templates-1.1.8.tar.gz

[Email protected] soft]# tar zxvf better-cacti-templates-1.1.8.tar.gz

[Email protected] soft]# CD better-cacti-templates-1.1.8

[email protected] better-cacti-templates-1.1.8]# CP scripts/ss_get_by_ssh.php/var/www/html/cacti/scripts/ss_get_ by_ssh.php

[Email protected] better-cacti-templates-1.1.8]# chown–r apache/var/www/html/cacti/scripts/ss_get_by_ssh.php

Modify the Monitoring script ss_get_by_ssh.php

[Email protected] better-cacti-templates-1.1.8]# vim/var/www/html/cacti/scripts/ss_get_by_ssh.php

$ssh _user = ' root '; # SSH Username

$ssh _port = 22; # SSH Port

$ssh _iden = '-i/var/www/html/cacti/id_rsa '; # SSH Identity

here MongoDB because of the use of 30000 port is not the default port 27018 , you also need to modify the port configuration

function Mongodb_cmdline ($options) {

Return "echo \" Db._admincommand ({serverstatus:1, repl:2}) \ "| /usr/local/mongo/mongodb/bin/mongo--port 30000″;

}

after that, restart Cacti Service

[Email protected] templates]# service httpd restart

Stop httpd: [OK]

Starting httpd: [OK]

[Email protected] templates]#

3. Login to monitor using SSH

( 1 ): Create SSH log in as far as your account

Use Ssh-keygen command generate secret key, enter after carriage return Key the path /var/www/html/cacti/id_rsa , and then 2 a return, the password is empty, as follows:

[Email protected] squid-2 soft]# Ssh-keygen

Generating public/private RSA key pair.

Enter file in which to save the key (/ROOT/.SSH/ID_RSA):/var/www/html/cacti/id_rsa

Enter passphrase (empty for no passphrase):

Enter same Passphrase again:

Your identification has been saved In/var/www/html/cacti/id_rsa.

Your public key has been saved in/var/www/html/cacti/id_rsa.pub.

The key fingerprint is:

73:8e:77:45:a0:54:ef:c8:a4:2d:62:50:8d:da:d8:e4 [email protected]

The key ' s Randomart image is:

+--[RSA 2048]----+

| .. O.. o |

| . O ... o |

| . B. . o |

| O.E = + |

| S + + O |

| . * .   . |

| .    O. |

| .     . |

| |

+-----------------+

put Key file permissions are changed to Cacti permissions that users can access by using:

[Email protected] squid-2 soft]# chown-r cacti_user/var/www/html/cacti/id_rsa*

[Email protected] squid-2 soft]#

will be Key Join to remote MongoDB server, you can also set up a remote server on the Cacti_user users, will Key Plus to Cactiuser directory under

[Email protected] squid-2 soft]# ssh-copy-id-i/var/www/html/cacti/id_rsa [email protected]

(2): Configure various parameters

Modify ss_get_by_ssh.php , set the path of the private key file:

$ssh _user = ' root '; # SSH Username

$ssh _port = 22; # SSH Port

$ssh _iden = '-i/var/www/html/cacti/id_rsa '; # SSH Identity

if MongoDB do not use the default port, you need to modify the following paragraph , Add the port:

function Mongodb_cmdline ($options) {

Return "echo \" Db._admincommand ({serverstatus:1, repl:2}) \ "| /usr/local/mongo/mongodb/bin/mongo--port 30000″;

}


( 3 ) Detection Monitoring script

[Email protected] templates]# php/var/www/html/cacti/scripts/ss_get_by_ssh.php--type mongodb--host 10.254.3.62-- Items Dc,de,df,dg,dh,di,dj,dk,dl,dm,dn,do,dp,dq,dr,ds,dt,du

dc:57 de:0 df:401604608 dg:-1 dh:-1 di:-1 dj:-1 dk:-1 dl:-1 dm:-1 dn:-1 do:46268320 dp:5245 dq:0 dr:6 ds:52 dt:46697435 du : -1[[email protected] templates]#

[Email protected] templates]#

See the data, detection OK.


4, using the Mongodb remote connection way to monitor

4.1. Modify the Mongodb_cmdline function to log in by authorizing the account password and specifying the port.

function Mongodb_cmdline ($options) {

Return "echo \" Db._admincommand ({serverstatus:1, repl:2}) \ "| Mongo ";

Return "echo \" Db._admincommand ({serverstatus:1, repl:2}) \ "| /usr/local/mongodb/bin/mongo admin--port $options [port2]--username pluser--password!378zm13yt ";

}

4.2. Modify the get_command_result function, using remote login instead of the default SSH mode. (The database could have been remotely connected), probably in 558 .

$final _cmd = $use _ssh? "$ssh ' $cmd '": $cmd;

$final _cmd = "$cmd--host $options [host]";


4.3 Modify Data Input Methods

Select "Console", select "Data Input methonds" in the left menu bar, and then select the MONGODB monitoring item Connection "X Get Mongodb Stats ...", in the input box after the middle "input String", with the parameter matching, As shown below:

<path_php_binary>-Q <path_cacti>/scripts/ss_get_by_ssh.php--host


4.4. Execute the script to test the results as follows:

[[email protected] ~]# php ss_get_by_ssh.php--type mongodb--host 10.254.3.62--port2 30000--items JC,JD

PHP Parse error:syntax error, unexpected t_string in/var/www/html/cacti/scripts/ss_get_by_ssh.php on line 1265

[Email protected] ~]#

The script has full-width garbled, removed, and then executed the script to test, the result is as follows:

[@cacti scripts]# php ss_get_by_ssh.php--type mongodb--host 10.254.3.62--port2 30000--items JC,JD

Jc:4 jd:5497683968

5, generate the monitor diagram

In the interface, select "Device", select the MongoDB server Connection "3.x2_mongodb", then select "Create Graphs for this Host" in the upper right corner, select the MongoDB service item in the dropdown box after "Graph Types", You will see the MONGODB monitoring service in the list, then tick the "Create" button in the bottom right corner to add the monitor diagram to the host, as shown here:


PS: When adding device devices, if you tick the MongoDB template, you need to specify the PORT2 parameter.



6. View MongoDB Monitor Image
Once added, there will be a series of monitoring diagrams as follows:


(1) MongoDB Background flushes GT


(2) MongoDB Commands GT

(3) MongoDB Connections GT

(4) MongoDB Index Ops GT

(5) MongoDB Memory GT

(6) MongoDB Slave Lag GT

?


--------------------------------------------------------------------------------------------------------------- -

< copyright, the article allows reprint, but must be linked to the source address, otherwise investigate legal liability!>
? This article address original address: http://blog.csdn.net/mchdba/article/details/39805039

----------------------------------------------------------------------------------------------------------- -----

Reference article Address:
Http://blog.chinaunix.net/uid-21505614-id-3186756.html

http://c20031776.blog.163.com/blog/static/68471625201341424117630/


[CACTI] MongoDB performance monitoring combat

Related Article

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.