mongodb監(jiān)控工具mongosniff

MongoDB監(jiān)控工具mongosniff

成都創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括侯馬網(wǎng)站建設(shè)、侯馬網(wǎng)站制作、侯馬網(wǎng)頁制作以及侯馬網(wǎng)絡(luò)營(yíng)銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,侯馬網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到侯馬省份的部分城市,未來相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!

 

介紹

 

mongosniff提供了對(duì)數(shù)據(jù)庫實(shí)時(shí)活動(dòng)的低級(jí)別操作跟蹤和嗅探視圖??梢詫ongosniff認(rèn)為是專為MongoDB定制的,類似于tcpdump用于TCP/IP網(wǎng)絡(luò)流量分析。mongosniff常用于驅(qū)動(dòng)開發(fā)。

注意:mongosniff需要libpcap,并且只對(duì)類Unix系統(tǒng)可用。

相對(duì)于mongosniff,Wireshark,一個(gè)流行的網(wǎng)絡(luò)嗅探工具,可用于偵測(cè)和解析MongoDB線協(xié)議。

 

用法

 

下面的命令連接到運(yùn)行在localhost的27017和27018上的mongod或mongos:  

mongosniff --source NET lo 27017 27018

 

下面的命令只記錄運(yùn)行在localhost的27018上的mongod或mongos的無效的BSON對(duì)象,用于驅(qū)動(dòng)開發(fā)和問題跟蹤:  

mongosniff --objcheck --source NET lo 27018

 

實(shí)踐

[root@test ~]# mongosniff --help    
mongosniff: error while loading shared libraries: libpcap.so.0.9: cannot open shared object file: No such file or directory

 

[root@test ~]# which mongosniff   
/usr/bin/mongosniff

 

[root@test ~]# ldd /usr/bin/mongosniff   
        linux-vdso.so.1 =>  (0x00007fffe2d7a000)    
        libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003558e00000)    
        librt.so.1 => /lib64/librt.so.1 (0x0000003559200000)    
        libpcap.so.0.9 => not found    
        libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x0000003559e00000)    
        libm.so.6 => /lib64/libm.so.6 (0x0000003559600000)    
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x000000355a600000)    
        libc.so.6 => /lib64/libc.so.6 (0x0000003558a00000)    
        /lib64/ld-linux-x86-64.so.2 (0x0000003558200000)

 

可以看出libpcap.so.0.9 => not found并沒有找到。

 

[root@test ~]# cd /usr/lib64   
[root@test lib64]# ls -al | grep libpcap    
lrwxrwxrwx.  1 root root      16 Feb 26 17:28 libpcap.so.1 -> libpcap.so.1.4.0    
-rwxr-xr-x   1 root root  260880 Nov 22  2013 libpcap.so.1.4.0

 

添加軟連接。

[root@test lib64]# ln -s /usr/lib64/libpcap.so.1.4.0 /usr/lib64/libpcap.so.0.9

 

再次查看幫助。

[root@test lib64]# mongosniff --help   
Usage: mongosniff [--help] [--forward host:port] [--source (NET <interface> | (FILE | DIAGLOG) <filename>)] [<port0> <port1> ... ]    
--forward       Forward all parsed request messages to mongod instance at     
                specified host:port    
--source        Source of traffic to sniff, either a network interface or a    
                file containing previously captured packets in pcap format,    
                or a file containing output from mongod's --diaglog option.    
                If no source is specified, mongosniff will attempt to sniff    
                from one of the machine's network interfaces.    
--objcheck      Log hex representation of invalid BSON objects and nothing    
                else.  Spurious messages about invalid objects may result    
                when there are dropped tcp packets.    
<port0>...      These parameters are used to filter sniffing.  By default,     
                only port 27017 is sniffed.    
--help          Print this help message.

抓包:

[root@test lib64]# /usr/bin/mongosniff --source NET bond0 > /var/log/currentOp/sniff.log

下面是sniff.log中的部分內(nèi)容:

10.10.0.1:55553  -->> 10.10.0.2:27017 MyTest.Pro  1042 bytes  id:41d99     269721    
        query: { $query: { id: { $in: [ 380, 383 ] }, Availability.Status: { $lt: 5 }, $or: [ { id: { $lt: 331 } }, { id: { $gt: 200, $lt: 400 } }, { id: { $gt: 600, $lt: 800 } } ] }, $orderby: { Availability.Status: 1 } }  ntoreturn: 0 ntoskip: 0 hasfields SlaveOk

網(wǎng)頁名稱:mongodb監(jiān)控工具mongosniff
網(wǎng)頁路徑:http://muchs.cn/article46/isjoeg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、網(wǎng)站建設(shè)、網(wǎng)站導(dǎo)航、全網(wǎng)營(yíng)銷推廣、Google、網(wǎng)站設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)