Search code examples
pythonmongodbmonitoringmunin

Mongo's stats not showing on munin


I'm trying to add a MongoDB's plugin to munin. I followed this to install the plugin:

sudo apt-get install git munin-node
git clone git://github.com/erh/mongo-munin.git /home/ubuntu/mongo-munin
sudo ln -sf /home/ubuntu/mongo-munin/mongo_btree /etc/munin/plugins/mongo_btree
sudo ln -sf /home/ubuntu/mongo-munin/mongo_conn /etc/munin/plugins/mongo_conn
sudo ln -sf /home/ubuntu/mongo-munin/mongo_lock /etc/munin/plugins/mongo_lock
sudo ln -sf /home/ubuntu/mongo-munin/mongo_mem /etc/munin/plugins/mongo_mem
sudo ln -sf /home/ubuntu/mongo-munin/mongo_ops /etc/munin/plugins/mongo_ops
sudo service munin-node restart

(from https://ivan-site.com/2013/06/monitoring-mongodb-in-munin-on-ubuntu-1304)

But nothing was sent to munin's server (for Mongo only, all other date from the server are ok on Munin).

Then I found there is an error when runing the plugin:

# sudo -u munin python /usr/share/munin/plugins/mongo_ops
Traceback (most recent call last):
  File "/usr/share/munin/plugins/mongo_ops", line 56, in <module>
    doData()
  File "/usr/share/munin/plugins/mongo_ops", line 33, in doData
    ss = getServerStatus()
  File "/usr/share/munin/plugins/mongo_ops", line 28, in getServerStatus
    raw = urllib2.urlopen(req).read()
  File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 400, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 418, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1207, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1177, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno 111] Connection refused>

I've checked this question: Munin Mongodb Plugin Not Showing. . .? but the problem is not the same, I'm running pyhton 2, as seen in the output above:

File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen

And so, plugins are active:

# munin-node-configure | grep "mongo"
mongo_btree                | yes   |
mongo_conn                 | yes   |
mongo_lock                 | yes   |
mongo_mem                  | yes   |
mongo_ops                  | yes   |

Is it a permission from Mongo? Maybe I need to setup a user for Munin? Do you have any idea how to fix that?


Solution

  • OK, so first off - those plugins were written a LONG time ago and have not been updated in several years, so they may or may not work at this point. Second, they use the HTTP console of MongoDB to gather data. Since that now defaults to disabled it may not be running at all for your instance (and is generally not recommended for production systems - if you do run it, you should firewall it off).

    EDIT: After a bit more checking, the plugins require more than the console, they require the REST interface to be enabled, and that is definitely off by default, and again is not generally recommended for production.

    Finally, the plugins are hard coded to connect to port 28017 (default port for MongoDB +1000), so if you have customized the port MongoDB is running on, you will need to manually adjust each plugin to connect to the right port.

    The easiest way to check all this is to point your browser at the host on port 28017 (http://hostame/28017) or whatever the appropriate port is and see if you can access the console.

    Update

    I forked Eliot's plugins to see how hard it would be to port to pymongo, removing the dependency on the REST API, and I managed to do it fairly easily (no auth support yet). You can find that version here, same installation and test commands per the page you linked worked for me:

    https://github.com/comerford/mongo-munin

    As it turns out, the changes to the serverStatus() command since the plugins were written means that several of them no longer work as-is with a current version of MongoDB, so I had to go back and fix them up for 2.4 and later (this along with the new pymongo dependency is listed in the README).