MSV FM

[email protected]: ~ $
Path : /lib/fm-agent/plugins/
File Upload :
Current < : //lib/fm-agent/plugins/couch.py

import agent_util
try:
    # Python 2.x
    import httplib
except:
    import http.client as httplib

class CouchPlugin(agent_util.Plugin):
    textkey = 'couch'
    label = 'CouchDB'
    description = 'Monitoring agent for CouchDB'

    @classmethod
    def get_metadata(self, config):
        status = agent_util.SUPPORTED
        msg = None
        response = None
        self.base_url = "/_stats"

        if not config:
            self.log.info("The [couch] config block is not found in the config file")
            return {}

        if "host" not in config or "port" not in config:
            msg = "The host and port settings were not found in the [couch] block of the agent config file."
            self.log.info(msg)
            status = agent_util.MISCONFIGURED

        if "base_url" in config:
            self.base_url = config["base_url"]

        if status == agent_util.SUPPORTED:

            try:
                couch_client = httplib.HTTPConnection(config['host'], config['port'])
                couch_client.request('GET', '/')
                response = couch_client.getresponse()
            except Exception:
                import sys
                _, exception, _ = sys.exc_info()
                status = agent_util.MISCONFIGURED
                msg = "Unable to connect to CouchDB server to request metrics"
                self.log.info('%s' % exception)

            if response and response.status != 200:
                status = agent_util.MISCONFIGURED
                mgs = 'CouchDB Stats not found at %s:%s' % (config['host'], config['port'])
                self.log.info(msg)

        return {
            'couchdb.database_writes': {
                'label': 'Number of times a database was changed',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'times',
            },
            'couchdb.database_reads': {
                'label': 'Number of times a document was read from a database',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'times',
            },
            'couchdb.open_databases': {
                'label': 'Number of open databases',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'databases',
            },
            'couchdb.open_os_files': {
                'label': 'Number of file descriptors CouchDB has open',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'files',
            },
            'couchdb.request_time': {
                'label': 'Length of a request inside CouchDB without MochiWeb',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'ms',
            },
            'httpd.bulk_requests': {
                'label': 'Number of bulk requests',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'requests',
            },
            'httpd.requests': {
                'label': 'Number of HTTP requests',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'requests',
            },
            'httpd.temporary_view_reads': {
                'label': 'Number of temporary view reads',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'reads',
            },
            'httpd.view_reads': {
                'label': 'Number of view reads',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'reads',
            },
            'httpd_request_methods.COPY': {
                'label': 'Number of HTTP COPY requests',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'requests',
            },
            'httpd_request_methods.DELETE': {
                'label': 'Number of HTTP DELETE requests',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'requests',
            },
            'httpd_request_methods.GET': {
                'label': 'Number of HTTP GET requests',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'requests',
            },
            'httpd_request_methods.HEAD': {
                'label': 'Number of HTTP HEAD requests',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'requests',
            },
            'httpd_request_methods.MOVE': {
                'label': 'Number of HTTP MOVE requests',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'requests',
            },
            'httpd_request_methods.POST': {
                'label': 'Number of HTTP POST requests',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'requests',
            },
            'httpd_request_methods.PUT': {
                'label': 'Number of HTTP PUT requests',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'requests',
            },
            'httpd_status_codes.200': {
                'label': 'Number of HTTP 200 OK responses',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'responses',
            },
            'httpd_status_codes.201': {
                'label': 'Number of HTTP 201 Created responses',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'responses',
            },
            'httpd_status_codes.202': {
                'label': 'Number of HTTP 202 Accepted responses',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'responses',
            },
            'httpd_status_codes.301': {
                'label': 'Number of HTTP 301 Moved Permanently responses',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'responses',
            },
            'httpd_status_codes.304': {
                'label': 'Number of HTTP 304 Not Modified responses',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'responses',
            },
            'httpd_status_codes.400': {
                'label': 'Number of HTTP 400 Bad Request responses',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'responses',
            },
            'httpd_status_codes.401': {
                'label': 'Number of HTTP 401 Unauthorized responses',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'responses',
            },
            'httpd_status_codes.403': {
                'label': 'Number of HTTP 403 Forbidden responses',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'responses',
            },
            'httpd_status_codes.404': {
                'label': 'Number of HTTP 404 Not Found responses',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'responses',
            },
            'httpd_status_codes.405': {
                'label': 'Number of HTTP 405 Method Not Allowed responses',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'responses',
            },
            'httpd_status_codes.409': {
                'label': 'Number of HTTP 409 Conflict responses',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'responses',
            },
            'httpd_status_codes.412': {
                'label': 'Number of HTTP 412 Precondition Failed responses',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'responses',
            },
            'httpd_status_codes.500': {
                'label': 'Number of HTTP 500 Internal Server Error responses',
                'options': None,
                'status': status,
                'error_message': msg,
                'unit': 'responses',
            },
        }

    def check(self, textkey, data, config):
        stat_area, stat_name = textkey.split('.')
        url = '/'.join([self.base_url, stat_area, stat_name]) + '?range=60'
        try:
            couch_client = httplib.HTTPConnection(config["host"], config["port"])
            couch_client.request('GET', url)
        except Exception:
            return None
        response = couch_client.getresponse()
        stat = agent_util.json_loads(response.read())

        return stat[stat_area][stat_name]['current']
Bethany
Bethany
0%

THE FINEST HOTEL NEAR LAKE KIVU

The Perfect Base For You

Required fields are followed by *





EC1A68011

About Us

Delicious Interior With The Pinch Of Everything

Bethany Investment group is Presbyterian church in Rwanda(EPR) company that manage Hotel and Guest house in Karongi (Bethany Hotel), ISANO branch in GIKONDO(Kigali), Kiyovu branch(Kigali), AMIZERO branch(Nyagatare-East) and Gisenyi Branch(Rubavu).

Accomodation

Get a Comfortable Room
Feel The Comfort

Get a comfortable room and feel our hotel’s comfort. Bethany Hotel features a variety of fully furnished rooms with extra space, Executive rooms, Deluxe rooms with a beautiful lake view and garden space, Deluxe rooms, comfort rooms, family rooms and standard rooms at your service.

Standard Single

Services

We Provide Top Class Facility
Especially For You

Beach BBQ Party

Kick back on the beach& and enjoy our berbecue from our masterchef

Breakfast

Kick back at our hotels& enjoy our breakfast from our masterchef

Conference Hall

Kick back at our hotels& enjoy our conference halls from all bethany branches

Enjoy with your partner

Honeymoon Package

80%

Get In Touch

Don’t Miss Any Update

    +

    Search your Room

    Required fields are followed by *