MSV FM

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

import os
try: import json
except ImportError: import simplejson as json
import agent_util
import datetime

def get_unbound_stats():
    unbound_stats = {}
    unbound_binary = agent_util.which("unbound-control")
    ret, out = agent_util.execute_command("%s stats" % unbound_binary)
    if ret != 0:
        print("ERROR RUNNING UNBOUND: %s" % out)
        return {"error": str(out)}, False
    tmp = out.strip().split('\n')
    for line in tmp:
        k, v = line.split('=')
        unbound_stats[k] = float(v)
    return unbound_stats, True


def get_unbound_options(unbound_stats):
    options = []
    for opt in unbound_stats.keys():
        name = opt.split('.')[0]
        if name == 'time': continue
        options.append(name)
    return list(set(options))


class UnboundDNS(agent_util.Plugin):
    """ 
    WARNING:
        You MUST SET AT LEAST 755 ON '/etc/unbound/unbound_control.*' 
        AND '/etc/unbound/unbound_server.*' FOR THIS PLUGIN TO WORK PROPERLY
    """
    
    textkey = "unbound_dns"
    label = "Unbound DNS Resolver"

    @classmethod
    def get_metadata(self, config):

        status = agent_util.SUPPORTED
        msg = None
        unbound_options = ["total"]

        # check to confirm unbound is installed
        unbound_installed = agent_util.which("unbound-control")
        if not unbound_installed:
            status = agent_util.UNSUPPORTED
            msg = "Command unbound-control not installed"
            return {}
        else:
            unbound_stats, passed = get_unbound_stats()
            if passed is False:
                self.log.error("ERROR with Unbound:\n%s" % unbound_stats['error'])
                stats = agent_util.MISCONFIGURED
                msg = unbound_stats['error']
            else:
                self.log.debug("Found unbound stats!\n%s" % unbound_stats)
                unbound_options = get_unbound_options(unbound_stats)
                self.log.error("Found %s unbound DNS keys: %s" % (len(unbound_options), unbound_options))

        metadata = {
            "num.queries": {
                "label": "Number of queries",
                "options": unbound_options,
                "status": status,
                "error_message": msg,
                "unit": ""
            },
            "num.cachehits": {
                "label": "Number of cache hits",
                "options": unbound_options,
                "status": status,
                "error_message": msg,
                "unit": ""
            },
            "num.cachemiss": {
                "label": "Cache misses",
                "options": unbound_options,
                "status": status,
                "error_message": msg,
                "unit": ""
            },
            "num.recursivereplies": {
                "label": "Recursive replies",
                "options": unbound_options,
                "status": status,
                "error_message": msg,
                "unit": ""
            },
            "requestlist.avg": {
                "label": "Average queued queries",
                "options": unbound_options,
                "status": status,
                "error_message": msg,
                "unit": ""
            },
            "requestlist.max": {
                "label": "Max queued queries",
                "options": unbound_options,
                "status": status,
                "error_message": msg,
                "unit": ""
            },
            "recursion.time.avg": {
                "label": "Average recursion time",
                "options": unbound_options,
                "status": status,
                "error_message": msg,
                "unit": "seconds"
            },
            "recursion.time.median": {
                "label": "Median recursion time",
                "options": unbound_options,
                "status": status,
                "error_message": msg,
                "unit": "seconds"
            },
            "time.up": {
                "label": "Service uptime",
                "options": None,
                "status": status,
                "error_message": msg,
                "unit": "seconds"
            },
        }
        return metadata

    def check(self, textkey, data, config):
        unbound_stats, passed = get_unbound_stats()
        self.log.debug(unbound_stats)
        if data is None:
            key = textkey
        else:
            key = "%s.%s" % (str(data),str(textkey))
        self.log.debug(str(agent_util.which("unbound-control")))
        self.log.debug("Checking for Unbound key %s" % key)
        return unbound_stats.get(key, None)
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 *