Giter VIP home page Giter VIP logo

rabbitmq-nagios-plugins's People

Contributors

drazul avatar jasonmcintosh avatar joncotton avatar lsmithctct avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rabbitmq-nagios-plugins's Issues

overview script

Would be nice if the overview script would actually hit the overview api. Something like this would do well I believe:
#!/usr/bin/env python
from pynagios import make_option
from base_rabbit_check import BaseRabbitCheck

class RabbitQueueCheck(BaseRabbitCheck):
"""
performs a nagios compliant check on a single queue and
attempts to catch all errors. expected usage is with a critical threshold of 0
"""

#vhost = make_option("--vhost", dest="vhost", help="RabbitMQ vhost", type="string", default='%2F')
overview = ''
overview = make_option("--overview", dest="overview", help="messages, object", type="string")

def makeUrl(self):
    """
    forms self.url, a correct url to polling a rabbit queue
    """
    try:
        if self.options.use_ssl is True:
            self.url = "https://%s:%s/api/overview" % (self.options.hostname, self.options.port)
        else:
            self.url = "http://%s:%s/api/overview" % (self.options.hostname, self.options.port)
        return True
    except Exception, e:
        self.rabbit_error = 3
        self.rabbit_note = "problem forming api url:", e
    return False

def testOptions(self):
    """
    returns false if necessary options aren't present
    """
    if not self.options.hostname or not self.options.port:
        return False
    return True

def setPerformanceData(self, data, result):
    if self.options.overview == "messages":
            result.set_perf_data("messages", data['queue_totals']['messages'])
            result.set_perf_data("rate", data['queue_totals']['messages_details']['rate'])
            result.set_perf_data("messages_ready", data['queue_totals']['messages_ready'])
            result.set_perf_data("messages_unacknowledged", data['queue_totals']['messages_unacknowledged'])
    else:
            result.set_perf_data("channels", data['object_totals']['channels'])
            result.set_perf_data("connections", data['object_totals']['connections'])
            result.set_perf_data("consumers", data['object_totals']['consumers'])
            result.set_perf_data("exchanges", data['object_totals']['exchanges'])
            result.set_perf_data("queues", data['object_totals']['queues'])
    #result.set_perf_data("rabbit_error", self.rabbit_error)
    return result

def parseResult(self, data):
    if self.options.overview == "messages":
            result = self.response_for_value(data['queue_totals'])
            result.message = data['queue_totals']
    else:
            result = self.response_for_value(data['object_totals'])
            result.message = data['object_totals']

    return result

if name == "main":
obj = RabbitQueueCheck()
obj.check().exit()

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.