Index: html/images/apps/mongodb.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: html/images/apps/mongodb.png
===================================================================
--- html/images/apps/mongodb.png        (revision 0)
+++ html/images/apps/mongodb.png        (working copy)

Property changes on: html/images/apps/mongodb.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: html/images/apps/mongodb_2x.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: html/images/apps/mongodb_2x.png
===================================================================
--- html/images/apps/mongodb_2x.png     (revision 0)
+++ html/images/apps/mongodb_2x.png     (working copy)

Property changes on: html/images/apps/mongodb_2x.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: html/includes/graphs/application/mongodb_commands.inc.php
===================================================================
--- html/includes/graphs/application/mongodb_commands.inc.php   (revision 0)
+++ html/includes/graphs/application/mongodb_commands.inc.php   (working copy)
@@ -0,0 +1,44 @@
+<?php
+
+/**
+ * Observium
+ *
+ *   This file is part of Observium.
+ *
+ * @package    observium
+ * @subpackage graphs
+ * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
+ *
+ */
+
+include_once($config['html_dir']."/includes/graphs/common.inc.php");
+
+$rrd_filename = get_rrd_path($device, 'app-mongodb-'.$app["app_id"].'.rrd');
+
+$array = array('delete'  => array('descr' => 'Delete', 'colour' => 'FF0000'),
+               'insert'  => array('descr' => 'Insert', 'colour' => '00AAAA'),
+               'query' => array('descr' => 'Query', 'colour' => '0022FF'),
+               'getmore'  => array('descr' => 'Getmore', 'colour' => '22FF22'),
+               'update'  => array('descr' => 'Update', 'colour' => '0000CC'),
+);
+
+$i = 0;
+if (is_file($rrd_filename))
+{
+  foreach ($array as $ds => $data)
+  {
+    $rrd_list[$i]['filename'] = $rrd_filename;
+    $rrd_list[$i]['descr'] = $data['descr'];
+    $rrd_list[$i]['ds'] = $ds;
+    $rrd_list[$i]['colour'] = $data['colour'];
+    $i++;
+  }
+} else { echo("file missing: $file");  }
+
+$colours   = "mixed";
+$nototal   = 1;
+$unit_text = "Commands";
+
+include($config['html_dir']."/includes/graphs/generic_multi_simplex_separated.inc.php");
+
+// EOF
Index: html/includes/graphs/application/mongodb_connections.inc.php
===================================================================
--- html/includes/graphs/application/mongodb_connections.inc.php        (revision 0)
+++ html/includes/graphs/application/mongodb_connections.inc.php        (working copy)
@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * Observium
+ *
+ *   This file is part of Observium.
+ *
+ * @package    observium
+ * @subpackage graphs
+ * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
+ *
+ */
+
+include_once($config['html_dir']."/includes/graphs/common.inc.php");
+
+$rrd_filename = get_rrd_path($device, 'app-mongodb-'.$app["app_id"].'.rrd');
+
+$array = array('conn'  => array('descr' => 'Connections', 'colour' => '22FF22'),
+);
+
+$i = 0;
+if (is_file($rrd_filename))
+{
+  foreach ($array as $ds => $data)
+  {
+    $rrd_list[$i]['filename'] = $rrd_filename;
+    $rrd_list[$i]['descr'] = $data['descr'];
+    $rrd_list[$i]['ds'] = $ds;
+    $rrd_list[$i]['colour'] = $data['colour'];
+    $i++;
+  }
+} else { echo("file missing: $file");  }
+
+$colours   = "mixed";
+$nototal   = 1;
+$unit_text = "Connections";
+
+include($config['html_dir']."/includes/graphs/generic_multi_simplex_separated.inc.php");
+
+// EOF
Index: html/includes/graphs/application/mongodb_mem.inc.php
===================================================================
--- html/includes/graphs/application/mongodb_mem.inc.php        (revision 0)
+++ html/includes/graphs/application/mongodb_mem.inc.php        (working copy)
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * Observium
+ *
+ *   This file is part of Observium.
+ *
+ * @package    observium
+ * @subpackage graphs
+ * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
+ *
+ */
+
+include_once($config['html_dir']."/includes/graphs/common.inc.php");
+
+$rrd_filename = get_rrd_path($device, 'app-mongodb-'.$app["app_id"].'.rrd');
+
+$array = array( 'vsize' => 'Virtual memory',
+                'res' => 'Resident memory',
+);
+
+$i = 0;
+if (is_file($rrd_filename))
+{
+  foreach ($array as $ds => $data)
+  {
+    $rrd_list[$i]['filename'] = $rrd_filename;
+    if (is_array($data))
+    {
+      $rrd_list[$i]['descr'] = $data['descr'];
+    } else {
+      $rrd_list[$i]['descr'] = $data;
+    }
+    $rrd_list[$i]['ds'] = $ds;
+    $i++;
+  }
+} else { echo("file missing: $file");  }
+
+$colours   = "mixed";
+$unit_text = "Bytes";
+$scale_min = 0;
+
+include($config['html_dir']."/includes/graphs/generic_multi_line.inc.php");
+
+// EOF
Index: html/includes/graphs/application/mongodb_network.inc.php
===================================================================
--- html/includes/graphs/application/mongodb_network.inc.php    (revision 0)
+++ html/includes/graphs/application/mongodb_network.inc.php    (working copy)
@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * Observium
+ *
+ *   This file is part of Observium.
+ *
+ * @package    observium
+ * @subpackage graphs
+ * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
+ *
+ */
+
+include_once($config['html_dir']."/includes/graphs/common.inc.php");
+
+$mongo_rrd = get_rrd_path($device, "app-mongodb-".$app['app_id'].".rrd");
+
+if (is_file($mongo_rrd))
+{
+  $rrd_filename = $mongo_rrd;
+}
+
+$ds_in = "net_in";
+$ds_out = "net_out";
+
+include($config['html_dir']."/includes/graphs/generic_data.inc.php");
+
+// EOF
Index: html/includes/graphs/application/mongodb_queue.inc.php
===================================================================
--- html/includes/graphs/application/mongodb_queue.inc.php      (revision 0)
+++ html/includes/graphs/application/mongodb_queue.inc.php      (working copy)
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * Observium
+ *
+ *   This file is part of Observium.
+ *
+ * @package    observium
+ * @subpackage graphs
+ * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
+ *
+ */
+
+include_once($config['html_dir']."/includes/graphs/common.inc.php");
+
+$rrd_filename = get_rrd_path($device, 'app-mongodb-'.$app["app_id"].'.rrd');
+
+$array = array('queue_read'  => array('descr' => 'Queue read', 'colour' => '22FF22'),
+               'queue_write'  => array('descr' => 'Queue write', 'colour' => '0022FF'),
+               'clients_read' => array('descr' => 'Client read', 'colour' => 'FF0000'),
+               'clients_write'  => array('descr' => 'Client write', 'colour' => '00AAAA'),
+);
+
+$i = 0;
+if (is_file($rrd_filename))
+{
+  foreach ($array as $ds => $data)
+  {
+    $rrd_list[$i]['filename'] = $rrd_filename;
+    $rrd_list[$i]['descr'] = $data['descr'];
+    $rrd_list[$i]['ds'] = $ds;
+    $rrd_list[$i]['colour'] = $data['colour'];
+    $i++;
+  }
+} else { echo("file missing: $file");  }
+
+$colours   = "mixed";
+$nototal   = 1;
+$unit_text = "Queues";
+
+include($config['html_dir']."/includes/graphs/generic_multi_simplex_separated.inc.php");
+
+// EOF
Index: html/includes/graphs/application/mongodb_replication.inc.php
===================================================================
--- html/includes/graphs/application/mongodb_replication.inc.php        (revision 0)
+++ html/includes/graphs/application/mongodb_replication.inc.php        (working copy)
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * Observium
+ *
+ *   This file is part of Observium.
+ *
+ * @package    observium
+ * @subpackage graphs
+ * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
+ *
+ */
+
+include_once($config['html_dir']."/includes/graphs/common.inc.php");
+
+$rrd_filename = get_rrd_path($device, 'app-mongodb-'.$app["app_id"].'.rrd');
+
+$array = array('command_local'  => array('descr' => 'Commands local', 'colour' => '22FF22'),
+               'command_replic'  => array('descr' => 'Commands replica', 'colour' => '0022FF'),
+);
+
+$i = 0;
+if (is_file($rrd_filename))
+{
+  foreach ($array as $ds => $data)
+  {
+    $rrd_list[$i]['filename'] = $rrd_filename;
+    $rrd_list[$i]['descr'] = $data['descr'];
+    $rrd_list[$i]['ds'] = $ds;
+    $rrd_list[$i]['colour'] = $data['colour'];
+    $i++;
+  }
+} else { echo("file missing: $file");  }
+
+$colours   = "mixed";
+$nototal   = 1;
+$unit_text = "Replication";
+
+include($config['html_dir']."/includes/graphs/generic_multi_simplex_separated.inc.php");
+
+// EOF
Index: html/includes/graphs/application/mongodb_wired.inc.php
===================================================================
--- html/includes/graphs/application/mongodb_wired.inc.php      (revision 0)
+++ html/includes/graphs/application/mongodb_wired.inc.php      (working copy)
@@ -0,0 +1,42 @@
+<?php
+
+/**
+ * Observium
+ *
+ *   This file is part of Observium.
+ *
+ * @package    observium
+ * @subpackage graphs
+ * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
+ *
+ */
+
+include_once($config['html_dir']."/includes/graphs/common.inc.php");
+
+$rrd_filename = get_rrd_path($device, 'app-mongodb-'.$app["app_id"].'.rrd');
+
+$array = array('flushes'  => array('descr' => 'Flushes', 'colour' => '22FF22'),
+               'dirty'  => array('descr' => 'Dirty', 'colour' => 'FF0000'),
+               'used' => array('descr' => 'Used', 'colour' => '0022FF'),
+);
+
+$i = 0;
+if (is_file($rrd_filename))
+{
+  foreach ($array as $ds => $data)
+  {
+    $rrd_list[$i]['filename'] = $rrd_filename;
+    $rrd_list[$i]['descr'] = $data['descr'];
+    $rrd_list[$i]['ds'] = $ds;
+    $rrd_list[$i]['colour'] = $data['colour'];
+    $i++;
+  }
+} else { echo("file missing: $file");  }
+
+$colours   = "mixed";
+$nototal   = 1;
+$unit_text = "WiredTiger";
+
+include($config['html_dir']."/includes/graphs/generic_multi_simplex_separated.inc.php");
+
+// EOF
Index: html/pages/device/apps/mongodb.inc.php
===================================================================
--- html/pages/device/apps/mongodb.inc.php      (revision 0)
+++ html/pages/device/apps/mongodb.inc.php      (working copy)
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * Observium Network Management and Monitoring System
+ * Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
+ *
+ * @package    observium
+ * @subpackage applications
+ * @author     Adam Armstrong <adama@observium.org>
+ * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
+ *
+ */
+
+$app_graphs['default'] = array('mongodb_commands' => 'Commands',
+                               'mongodb_queue' => 'Queues',
+                               'mongodb_mem' => 'Memory',
+                               'mongodb_replication' => 'Replication',
+                               'mongodb_wired' => 'Wired Storage Engine',
+                               'mongodb_connections' => 'Connections',
+                               'mongodb_network' => 'Network',
+);
+
+// EOF
+
Index: includes/definitions/apps.inc.php
===================================================================
--- includes/definitions/apps.inc.php   (revision 8857)
+++ includes/definitions/apps.inc.php   (working copy)
@@ -47,4 +47,6 @@
 $config['app']['vmwaretools']['top']       = array('mem', 'cpu');
 $config['app']['dovecot']['top']           = array('connected');
 $config['app']['exim']['top']              = array('sent', 'spam','reject');
+$config['app']['mongodb']['top']           = array('commands', 'queue', 'mem', 'network');
+
 // EOF
Index: includes/definitions/rrdtypes.inc.php
===================================================================
--- includes/definitions/rrdtypes.inc.php       (revision 8857)
+++ includes/definitions/rrdtypes.inc.php       (working copy)
@@ -1437,6 +1437,33 @@
   ),
 );

+// MongoDB
+
+$config['rrd_types']['mongodb'] = array(
+  'file'  => 'app-mongodb-%index%.rrd',
+  'ds'    => array(
+    'insert'         => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'query'          => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'update'         => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'delete'         => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'getmore'        => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'command_local'  => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'command_replic' => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'dirty'          => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'used'           => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'flushes'        => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'vsize'          => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'res'            => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'queue_read'     => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'queue_write'    => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'clients_read'   => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'clients_write'  => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'net_in'         => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'net_out'        => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+    'conn'           => array('type' => 'GAUGE',  'min' => 0, 'max' => 125000000000),
+  ),
+);
+
 // Exim

 $config['rrd_types']['exim-mailqueue'] = array(
Index: includes/polling/applications/mongodb.inc.php
===================================================================
--- includes/polling/applications/mongodb.inc.php       (revision 0)
+++ includes/polling/applications/mongodb.inc.php       (working copy)
@@ -0,0 +1,72 @@
+<?php
+
+/**
+ * Observium
+ *
+ *   This file is part of Observium.
+ *
+ * @package    observium
+ * @subpackage poller
+ * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
+ *
+ */
+
+if (!empty($agent_data['app']['mongodb']))
+{
+  $app_id = discover_app($device, 'mongodb');
+
+  $mongodb_data = json_decode($agent_data['app']['mongodb'], true);
+  $keys = array_keys($mongodb_data);
+  //some values are reported in pair of 2 separated by a "|"
+  $command = explode("|", $mongodb_data[$keys[0]]['command']);
+  $queue = explode("|", $mongodb_data[$keys[0]]['qrw']);
+  $clients = explode("|", $mongodb_data[$keys[0]]['arw']);
+  //if the operation is replicated a * appears in the value
+  $insert = str_replace("*", "", $mongodb_data[$keys[0]]['insert']);
+
+  update_application($app_id, array(
+    'insert'          => $insert,
+    'query'           => $mongodb_data[$keys[0]]['query'],
+    'update'          => $mongodb_data[$keys[0]]['update'],
+    'delete'          => $mongodb_data[$keys[0]]['delete'],
+    'getmore'         => $mongodb_data[$keys[0]]['getmore'],
+    'command_local'   => $command[0],
+    'command_replic'  => $command[1],
+    'dirty'           => $mongodb_data[$keys[0]]['dirty'],
+    'used'            => $mongodb_data[$keys[0]]['used'],
+    'flushes'         => $mongodb_data[$keys[0]]['flushes'],
+    'vsize'           => $mongodb_data[$keys[0]]['vsize'],
+    'res'             => $mongodb_data[$keys[0]]['res'],
+    'queue_read'      => $queue[0],
+    'queue_write'     => $queue[1],
+    'clients_read'    => $clients[0],
+    'clients_write'   => $clients[1],
+    'net_in'          => $mongodb_data[$keys[0]]['net_in'],
+    'net_out'         => $mongodb_data[$keys[0]]['net_out'],
+    'conn'            => $mongodb_data[$keys[0]]['conn']
+  ));
+
+  rrdtool_update_ng($device, 'mongodb', array(
+    'insert'          => $mongodb_data[$keys[0]]['insert'],
+    'query'           => $mongodb_data[$keys[0]]['query'],
+    'update'          => $mongodb_data[$keys[0]]['update'],
+    'delete'          => $mongodb_data[$keys[0]]['delete'],
+    'getmore'         => $mongodb_data[$keys[0]]['getmore'],
+    'command_local'   => $command[0],
+    'command_replic'  => $command[1],
+    'dirty'           => $mongodb_data[$keys[0]]['dirty'],
+    'used'            => $mongodb_data[$keys[0]]['used'],
+    'flushes'         => $mongodb_data[$keys[0]]['flushes'],
+    'vsize'           => $mongodb_data[$keys[0]]['vsize'],
+    'res'             => $mongodb_data[$keys[0]]['res'],
+    'queue_read'      => $queue[0],
+    'queue_write'     => $queue[1],
+    'clients_read'    => $clients[0],
+    'clients_write'   => $clients[1],
+    'net_in'          => $mongodb_data[$keys[0]]['net_in'],
+    'net_out'         => $mongodb_data[$keys[0]]['net_out'],
+    'conn'            => $mongodb_data[$keys[0]]['conn']
+  ), $app_id);
+}
+
+// EOF
Index: scripts/agent-local/mongodb
===================================================================
--- scripts/agent-local/mongodb (revision 0)
+++ scripts/agent-local/mongodb (working copy)
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+mongostat=`which mongostat`
+
+# Change connection settings to match your mongodb
+user=''
+password=''
+port='27017'
+ad='admin'
+
+if [ $? -eq 0 ]
+then
+  echo '<<<app-mongodb>>>'
+  "${mongostat}" -u "$user" -p "$password" --port "$port" --authenticationDatabase "$ad" --humanReadable false --noheaders -n 1 1 --json
+fi
