Reader small image

You're reading from  MongoDB High Availability

Product typeBook
Published inJul 2014
Publisher
ISBN-139781783986729
Edition1st Edition
Tools
Right arrow
Author (1)
Afshin Mehrabani
Afshin Mehrabani
author image
Afshin Mehrabani

Afshin Mehrabani is an open source programmer. He is studying to be a computer software engineer. He started programming and web development when he was 12 years old, as well as starting with PHP. Later, he joined the Iran Technical and Vocational Training Organization. He secured the first place and received a gold medal in a competition which was conducted across the entire country in the area of web development. He became a member of the Iran National Foundation of Elite after producing a variety of new programming ideas. He was a software engineer at the Tehran Stock Exchange and is now the head of the web development team in the Yara Company. He cofounded the Usablica team in early 2012 to develop and produce usable applications. He is the author of IntroJs, WideArea, flood.js and some other open source projects. He has contributed to Socket.IO, Engine.IO, and some other open source projects. He is also interested in creating and contributing to open source applications, writing programming articles, and challenging himself with new programming technologies. He has written different articles about JavaScript, Node.js, HTML5, and MongoDB that have been published on different academic websites. Afshin has 5 years of experience in PHP, Python, C#, JavaScript, HTML5, and Node.js in many financial and stock trading projects.
Read more about Afshin Mehrabani

Right arrow

Diagnostic tools


One of the important tools of a database system is diagnostic tools. Fortunately, MongoDB has built-in diagnostic tools that enable developers to diagnose the server or get a brief report from the system.

We have the following utilities placed in this group:

  • mongostat

  • mongotop

  • mongosniff

  • mongoperf

In the next sections, you can read a brief description of each utility.

Learning about mongostat

This tool produces a brief summary of relevant statistics of the currently running MongoDB instances, either the mongod or mongos instance.

The following screenshot illustrates the output of this tool:

The preceding screenshot shows you the number of queries, update, insert, and delete operations from the database every second.

The following bullet list gives you a brief description for each column:

  • insert: This refers to the number of insert operations per second.

  • query: This refers to the number of queries per second.

  • update: This refers to the number of update operations per second.

  • delete: This refers to the number of delete operations per second.

  • getmore: This refers to the number of getmore operations (that is, the it command in mongo shell) per second.

  • command: This refers to the number of executed commands since the last mongostat call.

  • flushes: This refers to the number of fsync operations at the time of the last mongostat execution. The fsync operation is a system call that flushes all dirty in-memory pages to the disk.

  • mapped: This refers to the total amount of data mapped in megabytes.

  • vsize: This refers to the amount of virtual memory in megabytes used by the process at the time of the last mongostat execution.

  • res: This refers to the amount of resident memory in megabytes used by the process at the time of the last mongostat execution.

  • locked: This refers to the percentage of time in a global write lock.

  • idx miss: This refers to the percentage of index access attempts that required a page fault.

  • qr: This refers to the number of clients in the queue that are waiting for read operations.

  • qw: This refers to the number of clients in the queue that are waiting for write operations.

  • ar: This refers to the number of clients that execute read operations.

  • aw: This refers to the number of clients that execute write operations.

  • netIn: This refers to the traffic received by the MongoDB instance in bytes.

  • netOut: This refers to the traffic sent by the MongoDB instance in bytes.

  • conn: This refers to the current total option connections.

The refresh interval can be changed using the following command:

mongostat [options] [sleep time] 

Utilizing mongotop

The mongotop utility provides you with a mechanism to get information about time spent on read/write operations. This command is similar to Unix's top command.

The following screenshot shows you a simple usage of mongotop:

Understanding mongosniff

The mongosniff is a tool that is used to fetch live MongoDB collection statistics. While inserting or querying data from the MongoDB instances, you can run the mongosniff command and connect it to your MongoDB instance to see what the database does.

Note

Please note that in order to use this utility, you should install the libpcap library first. To install the libpcap library, please visit its official website at http://www.tcpdump.org/#documentation.

A simple usage of the mongosniff tool is as follows:

sudo mongosniff  --source NET lo0

The preceding command line will listen to the loopback interface (localhost). This interface is lo0 in Mac OS systems and lo for other operating systems, usually. You can get the list for your network interfaces using the ifconfig command. If you're using Windows as the operating system, you can get the list of network interfaces using the following command:

ipconfig /all

Utilizing mongoperf

The mongoperf tool represents the disk I/O performance. It checks the I/O in a specified interval and illustrates it. This utility can be used independent of MongoDB.

File storage (GridFS) tools

With the help of GridFS, MongoDB can be used as a filesystem. The processes in this section are used to manage and control the GridFS feature.

There is one process in this category, which is as follows:

  • mongofiles

Understanding mongofiles

This utility enables developers to retrieve files that are stored in the database in the GridFS collection. The mongofiles utility come in handy when developers need to interact with files stored in the database from the command-line environment.

The usage of this command looks like the following:

mongofiles <options> <commands> <filename>

The following example is a simple usage of this utility:

mongofiles -d mydb list

The preceding command line will retrieve all files in the GridFS collection from the mydb database.

Note

For more information on mongofiles, please visit the MongoDB documentation page at http://docs.mongodb.org/manual/reference/program/mongofiles/.

Previous PageNext Page
You have been reading a chapter from
MongoDB High Availability
Published in: Jul 2014Publisher: ISBN-13: 9781783986729
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Afshin Mehrabani

Afshin Mehrabani is an open source programmer. He is studying to be a computer software engineer. He started programming and web development when he was 12 years old, as well as starting with PHP. Later, he joined the Iran Technical and Vocational Training Organization. He secured the first place and received a gold medal in a competition which was conducted across the entire country in the area of web development. He became a member of the Iran National Foundation of Elite after producing a variety of new programming ideas. He was a software engineer at the Tehran Stock Exchange and is now the head of the web development team in the Yara Company. He cofounded the Usablica team in early 2012 to develop and produce usable applications. He is the author of IntroJs, WideArea, flood.js and some other open source projects. He has contributed to Socket.IO, Engine.IO, and some other open source projects. He is also interested in creating and contributing to open source applications, writing programming articles, and challenging himself with new programming technologies. He has written different articles about JavaScript, Node.js, HTML5, and MongoDB that have been published on different academic websites. Afshin has 5 years of experience in PHP, Python, C#, JavaScript, HTML5, and Node.js in many financial and stock trading projects.
Read more about Afshin Mehrabani