How to check 
We assume here that you have a replica set in place. First download the python script for our nagios plugin:
 
Now the
 
Create a new file
 
Create a new file in
 
This service gets enabled where it finds
 
#sysadmin #icinga2 #mongodb #replication #replication_lag #nagios_plugin
  MongoDB replication lag in Icinga2 and get notified when it is over 15 seconds?We assume here that you have a replica set in place. First download the python script for our nagios plugin:
cd /usr/lib/nagios/plugins
git clone git://github.com/mzupan/nagios-plugin-mongodb.git
Now the
Icinga2 part. You first need to create a command for replication lag check:cd /etc/icinga2/conf.d/commands
Create a new file
replication_lag.conf:object CheckCommand "check_replication_lag" {
     import "plugin-check-command"
     command = [ PluginDir + "/nagios-plugin-mongodb/check_mongodb.py", "-A", "replication_lag" ]
     arguments = {
         "-H" = "$mongo_host$"
         "-P" = "$mongo_port$"
     }
 }Create a new file in
services folder called replication_lag.conf:apply Service for (display_name => config in host.vars.replication) {
     import "generic-service"
     check_command = "check_replication_lag"
     vars += config
     assign where host.vars.replication
 }This service gets enabled where it finds
replication in host config. Now in secondary mongoDB hosts configuration add the below part:vars.replication["Secondary DB"] = {
     mongo_host = "slave.example.com"
     mongo_port = 27017
 }#sysadmin #icinga2 #mongodb #replication #replication_lag #nagios_plugin
