Code Monkey home page Code Monkey logo

mongozbx's Introduction

#mongozbx Zabbix agent (3.X) external script for Mongodb monitoring.

The work is based on m-barthelemy`s native plugun.

It can connect to a Mongo server, run basic queries and return a simple value usable by Zabbix server.

An XML template with a few useful example queries and databases discovery is provided.

Published under MIT license.

##Zabbix Configuration

###Agent configuration

  • Install pymongo
    pip install --upgrade pymongo
  • Put mongozbx.py into your agent's scripts directory.
  • Add UserParameter=mongo.run[*],<path to your agent's scripts directory>/mongozbx.py "$1" "$2" "$3" "$4" to the zabix_agentd.conf or as a separate .conf file into zabbix_agentd.d folder.

###Server configuration

  • Import zabbix template.
  • Link it to target host.
  • Set {$MGO_URL} macro (see mongo_uri) and don`t specify the exact database so LLD can run.

##Usage

The module is called by defining a regular Zabbix agent item:

mongo.run[<mongo_uri>,<path>,<command>,<query>]

with:

####mongo_uri :

The Mongo URI to connect, authenticate, select the database:

Format:

[mongodb://][user:pass@]host1[:port1][,host2[:port2],...][/database][?options]

Example:

mongodb://127.0.0.1/mydb

####path:

The path to the wanted value. If empty, the complete result will be returned as a JSON string. if the path points to something not being a simple value, the content is returned as a JSON string.

Format:

/property/subproperty

Examples:

If we query "dbStats=1", we get the following JSON object:

{"avgObjSize":0,"collections":0,"dataSize":0,"db":"test","fileSize":0,"indexSize":0,"indexes":0,"numExtents":0,"objects":0,"ok":1,"storageSize":0}

If we want to get the value of the dataSize property, then wanted_value will be /dataSize.

If we want a single value from an array, we can fetch it by its index : /path/to/array[0].

More examples in the zbx_mongodb_template.xml file.

####command:

command is the command name such as serverStatus, dbStats, find, count and etc.

####query:

query is the complete query (including command). Its format closely follows the format of db.RunCommand().

See MongoDB documentation.

#####Examples:

find() on the "colltest" collection:

find=colltest

find() on the "colltest" collection, only retrieve 1 document:

find=colltest limit=1

get dbStats:

dbStats=1

##Complete examples

mongo.run[mongodb://127.0.0.1/myDb, /, dbStats, dbStats=1]

mongo.run[mongodb://127.0.0.1/myDb, /connections/totalCreated, serverStatus, serverStatus=1 repl=0 metrics=0]

mongozbx's People

Contributors

gebteus avatar red55 avatar

Watchers

James Cloos avatar wumingyang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.