Skip to main content

MongoDB monitoring by zabbix

What should we monitor?

There are many things you can monitor in a MongoDB environment, but a few key areas will tip you off quickly if something is amiss. You should be analyzing the following metrics:

  • Replication lag. Replication lag refers to delays in copying data from the primary node to a secondary node.
  • Replica state. The replica state is a method of tracking if secondary nodes have died, and if there was an election of a new primary node.
  • Locking state. The locking state shows what data locks are set, and the length of time they have been in place.
  • Disk utilization. Disk utilization refers to disk access.
  • Memory usage. Memory usages refers to how much memory is being used, and how it is being used.
  • Number of connections. The number of connections the database has open in order to serve requests as quickly as possible.

serverStatus

The serverStatus command, or db.serverStatus() from the shell, returns a general overview of the status of the database, detailing disk usage, memory use, connection, journaling, and index access. The command returns quickly and does not impact MongoDB performance.

mongostat

mongostat captures and returns the counts of database operations by type (e.g. insert, query, update, delete, etc.). These counts report on the load distribution on the server.
Use mongostat to understand the distribution of operation types and to inform capacity planning. See the mongostat manual for details.

mongotop

mongotop tracks and reports the current read and write activity of a MongoDB instance, and reports these statistics on a per collection basis.
Use mongotop to check if your database activity and use match your expectations. See the mongotop manual for details.

replSetGetStatus


The replSetGetStatus command (rs.status() from the shell) returns an overview of your replica set’s status. The replSetGetStatus document details the state and configuration of the replica set and statistics about its members.


In Server side add below User parameter in zabbix_agentd.conf

UserParameter=MongoDB.Status[*],/bin/echo "db.serverStatus().$1" | /usr/bin/mongo | grep "$2"|awk -F: '{print $$2}'|awk -F, '{print $$1}'

Only above one entry.

then restart Agent.

Items screenshot



In zabbix-Server side Import below template MongoDB template

https://drive.google.com/open?id=13RaeVEpO_yxjW2wdIZKBrT8i8cmu0wFY

If want more parameters just run commands and grep using AWK and project it in zabbix.

Some Userparameters from mongostat command
------------------------------------------------------------------


UserParameter=MongoDB.Status[*],/bin/echo "db.serverStatus().$1" | /usr/bin/mongo | grep "$2"|awk -F: '{print $$2}'|awk -F, '{print $$1}'
UserParameter=mongouptime,echo "db.serverStatus()" | mongo | grep uptime | cut -f2 -d ":" | head -1 | cut -d ',' -f 1
UserParameter=networkbytesIn,echo "db.serverStatus()" | mongo | grep bytesIn | tr -dc '0-9'
UserParameter=networkbytesOut,echo "db.serverStatus()" | mongo | grep bytesOut | tr -dc '0-9'
UserParameter=repStatus,echo "rs.status()" | mongo | grep { | awk '{print $4}' | tr -dc '0-1'
UserParameter=insert,mongostat --rowcount 1 |awk  {'print $1'} | tr -dc '0-9'
UserParameter=query,mongostat --rowcount 1 |awk  {'print $2'} | tr -dc '0-9'
UserParameter=update,mongostat --rowcount 1 |awk  {'print $3'} | tr -dc '0-9'
UserParameter=delete,mongostat --rowcount 1 |awk  {'print $4'} | tr -dc '0-9'
UserParameter=mapped,mongostat --rowcount 1 | awk '{print $8}' | tail -1 | sed 's/M/ /'
UserParameter=vsize,mongostat --rowcount 1 | awk '{print $9}' | tail -1 | sed 's/M/ /'
UserParameter=conn,mongostat --rowcount 1 | awk '{print $16}' | tail -1


For concerns Please comment below.

Comments

  1. it is not connectinfg
    MongoDB shell version v3.6.2
    connecting to: mongodb://127.0.0.1:27017


    bye
    showig me this

    ReplyDelete
  2. Getting unsupported item after importing template and adding that line in server side let me know if i am missing anything.

    ReplyDelete
  3. Please Link template not working

    ReplyDelete
  4. Can you send the link again, please?

    ReplyDelete

Post a Comment

Popular posts from this blog

How to remove zabbix-agent from Ubuntu 16.04 (Xenial Xerus)

Uninstall zabbix-agent To remove just zabbix-agent package itself from Ubuntu 16.04 (Xenial Xerus) execute on terminal: sudo apt-get remove zabbix-agent Uninstall zabbix-agent and it's dependent packages To remove the zabbix-agent package and any other dependant package which are no longer needed from Ubuntu Xenial. sudo apt-get remove --auto-remove zabbix-agent Purging zabbix-agent If you also want to delete configuration and/or data files of zabbix-agent from Ubuntu Xenial then this will work: sudo apt-get purge zabbix-agent To delete configuration and/or data files of zabbix-agent and it's dependencies from Ubuntu Xenial then execute: sudo apt-get purge --auto-remove zabbix-agent

Install Zabbix Agent on Suse Linux and Configure

Install taken from Suse –  http://software.opensuse.org/download/package?project=server:monitoring&package=zabbix-agent For SLE 12 SP1 run the following as root : zypper addrepo http://download.opensuse.org/repositories/server:monitoring/SLE_12_SP1/server:monitoring.repo zypper refresh zypper install zabbix-agent For SLE 12 run the following as root : zypper addrepo http://download.opensuse.org/repositories/server:monitoring/SLE_12/server:monitoring.repo zypper refresh zypper install zabbix-agent For SLE 11 SP4 run the following as root : zypper addrepo http://download.opensuse.org/repositories/server:monitoring/SLE_11_SP4/server:monitoring.repo zypper refresh zypper install zabbix-agent For SLE 11 SP3 run the following as root : zypper addrepo http://download.opensuse.org/repositories/server:monitoring/SLE_11_SP3/server:monitoring.repo zypper refresh zypper install zabbix-agent To configure the agent – Instructions t...

Zabbix alert Notification with Telegram

Zabbix Notifications with graphs in Telegram. Features  Graphs based on latest data are sent directly to your messenger  You can send messages both in private and group chats  Channels support  Saves chatid as a temporary file  Simple markdown and HTML are supported  Emoji in messages First of all : Nedd to install python (>3) on Cent os  # yum -y install python-pip # yum install -y https://centos7.iuscommunity.org/ius-release.rpm #  yum install -y python34u python34u-libs python34u-devel python34u-pi # yum -y install python-pip You need to install the  requests  module for python, this is required for operation! # pip install requests Put  zbxtg.py  in your  AlertScriptsPath  directory, the path is set inside your zabbix_server.conf (once confirm by zabbix server conf file ) Link to download ZBXTG.PY file  https://drive.google.com/open?i...