MSV FM

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

from anomaly import Anomaly
from datetime import datetime
from threshold import Threshold
import logging
import traceback
import sys
import time
try:
    import json
except ImportError:
    try:
        import simplejson as json
    # it's possible that we may not need json for the action that we're taking.
    # for example, for the rpm post install script, on a python version that
    # doesn't have json, we'll get this far in the code.  but the post
    # install doesn't use json, so we're fine
    except ImportError:
        json = None


# This represents a check that needs to be run, and all the associated
# processes on the check result that need to occur.
class Schedule(object):
    def __init__(self, schedule_data):
        self.log = logging.getLogger(self.__class__.__name__)
        self.update(schedule_data)

        self.last_check_value = None
        self.next_check_time = datetime.now()
        self.number_of_checks = 0

        self.cached_results = {}

    # TODO: These two methods are also in Threshold and Anomaly; we should make
    # these three classes inherit from an Entity class that implements these.
    # The logging library interferes with cPickle, so we must remove the logger
    # instance then reset it when we serialize/unserialize.
    def __getstate__(self):
        state = dict(self.__dict__)
        del state['log']
        return state

    def __setstate__(self, state):
        self.__dict__.update(state)
        self.log = logging.getLogger(self.__class__.__name__)

    @classmethod
    def create_test_schedule(cls):
        # none of this stuff really matters for the individual plugin tests
        data = {
            "id": 1,
            "plugin_textkey": "",
            "resource_textkey": "",
            "option": "null",
            "frequency": 60,
            "thresholds": [{
                "id": 1,
                "delay": 0,
                "operator": "gt",
                "value": 0,
            }]
        }
        return cls(data)

    def update(self, schedule_data):
        self.id = schedule_data["id"]
        self.plugin_textkey = schedule_data["plugin_textkey"]
        self.resource_textkey = schedule_data["resource_textkey"]
        if type(schedule_data["option"]) == dict:
            self.option = schedule_data["option"]
        else:
            self.option = json.loads(schedule_data["option"] or 'null')
        self.frequency = schedule_data["frequency"]
        self.thresholds = []
        self.server_key = schedule_data.get("server_key", None)

    def __repr__(self):
        return "<Schedule %d, %s.%s, %d>" % (self.id,
                                             self.plugin_textkey,
                                             self.resource_textkey,
                                             self.number_of_checks)

    def check(self, plugin_manager, anomalies):
        value = plugin_manager.check(self)
        self.last_check_value = value
        self.number_of_checks += 1
        if value is not None:
            self.log.debug('Schedule %s, check #%d: %d', self.id, self.number_of_checks, value)
        else:
            self.log.debug('Schedule %s, check #%d: <No value>', self.id, self.number_of_checks)

        return value, anomalies

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 *