diff --git a/plugins/mongodb/mongo_collection_ b/plugins/mongodb/mongo_collection_ index baea31ae..a0b73653 100644 --- a/plugins/mongodb/mongo_collection_ +++ b/plugins/mongodb/mongo_collection_ @@ -1,4 +1,4 @@ -#!/usr/bin/env /usr/local/bin/python2 +#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: set sts=4 sw=4 encoding=utf-8 @@ -33,7 +33,7 @@ #%# capabilities=suggest autoconf -from pymongo import Connection +import pymongo from operator import itemgetter settings_host = '127.0.0.1' @@ -50,6 +50,7 @@ typeIndex['collcount']['title'] = 'per collection document count' typeIndex['collcount']['yaxis'] = 'documents' typeIndex['collcount']['base'] = '1000' typeIndex['collcount']['scale'] = '--logarithmic -l1' +typeIndex['collcount']['category'] = 'MongoDB' typeIndex['collsize'] = {} typeIndex['collsize']['index'] = 'size' @@ -57,6 +58,7 @@ typeIndex['collsize']['title'] = 'per collection data size' typeIndex['collsize']['yaxis'] = 'Byte' typeIndex['collsize']['base'] = '1024' typeIndex['collsize']['scale'] = '--logarithmic -l1 --units=si' +typeIndex['collsize']['category'] = 'MongoDB' typeIndex['avgsize'] = {} typeIndex['avgsize']['index'] = 'avgObjSize' @@ -64,6 +66,7 @@ typeIndex['avgsize']['title'] = 'average object size' typeIndex['avgsize']['yaxis'] = 'Byte' typeIndex['avgsize']['base'] = '1024' typeIndex['avgsize']['scale'] = '--logarithmic --units=si' +typeIndex['avgsize']['category'] = 'MongoDB' typeIndex['storage'] = {} typeIndex['storage']['index'] = 'storageSize' @@ -71,6 +74,7 @@ typeIndex['storage']['title'] = 'per collection storage size' typeIndex['storage']['yaxis'] = 'Byte' typeIndex['storage']['base'] = '1024' typeIndex['storage']['scale'] = '--logarithmic -l1 --units=si' +typeIndex['storage']['category'] = 'MongoDB' typeIndex['indexsize'] = {} typeIndex['indexsize']['index'] = 'totalIndexSize' @@ -78,11 +82,11 @@ typeIndex['indexsize']['title'] = 'per collection index size' typeIndex['indexsize']['yaxis'] = 'Byte' typeIndex['indexsize']['base'] = '1024' typeIndex['indexsize']['scale'] = '--logarithmic -l 1 --units=si' - +typeIndex['indexsize']['category'] = 'MongoDB' def getCollstats(graphtype): - con = Connection(settings_host, int(settings_port), slave_okay=True) + con = pymongo.MongoClient(settings_host, int(settings_port)) if settings_user: db = con['admin'] @@ -106,7 +110,7 @@ def getCollstats(graphtype): stats_tmp[collname]['value'] += long(stats[typeIndex[graphtype]['index']]) - con.disconnect() + con.close() for collname, item in sorted(stats_tmp.items()): yield ("%s" % collname, item['value'], item['dbname'])