MSV FM

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

import logging
import agent_util
import glob
import os
import datetime
import re
import time
import sys
from agent_util import float


class FilePresencePlugin(agent_util.Plugin):
    textkey = "files"
    label = "Filesystem"
    # this is here because it's used in 2 different places
    newer_than_regex = re.compile(r"(?P<op>(a|c|m)time)<(?P<delta>\d+)(?P<metric>d|h|m|s)")

    @classmethod
    def get_metadata(self, config):
        data = {
            "file.exists": {
                "label": "File exists",
                "options": None,
                "status": agent_util.SUPPORTED,
                "error_message": None,
                "unit": "boolean",
                "option_string": True
            },
            "file.count": {
                "label": "File count",
                "options": None,
                "status": agent_util.SUPPORTED,
                "error_message": None,
                "unit": "files",
                "option_string": True
            },
            "file.created": {
                "label": "Creation age",
                "options": None,
                "status": agent_util.SUPPORTED,
                "error_message": None,
                "unit": "minutes",
                "option_string": True
            },
            "file.modified": {
                "label": "Modification age",
                "options": None,
                "status": agent_util.SUPPORTED,
                "error_message": None,
                "unit": "minutes",
                "option_string": True
            },
            "directory.size": {
                "label": "Directory size (KB)",
                "options": None,
                "status": agent_util.SUPPORTED,
                "error_message": None,
                "unit": "kilobytes",
                "option_string": True
            },
            "file.size": {
                "label": "File size (KB)",
                "options": None,
                "status": agent_util.SUPPORTED,
                "error_message": None,
                "unit": "kilobytes",
                "option_string": True
            }
        }
        return data


    def check(self, textkey, path, config):
        path = path.strip()

        for date in re.findall(r"\$.[^$]+", path):
            date_format = date \
                            .replace("YYYY", "%Y") \
                            .replace("YY", "%y") \
                            .replace("MM", "%m") \
                            .replace("DD", "%d") \
                            .replace("D", "%w") \
                            .replace("ww", "%W") \
                            .replace("hh", "%H") \
                            .replace("mm", "%M") \
                            .replace("ss", "%S") \
                            .replace("Z", "%z") \
                            .replace("$", "") \
                            .strip()
            date_string = datetime.datetime.now().strftime(date_format)
            path = path.replace(date, date_string)

        self.log.debug("File path for file_presence plugin: %s" % path)

        if textkey == "file.exists":
            glob_results = glob.glob(path)
            has_results = len(glob_results) > 0
            return_val = has_results
            self.log.debug("Return value for file.exists textkey: %s" % str(return_val))
            return return_val
        elif textkey == "file.count":
            if os.path.isdir(path):
                glob_results = glob.glob(path+"/*")
                return_val = len(glob_results) 
                self.log.debug("Return value for file.count textkey: %s" % str(return_val))
            else:
                glob_results = glob.glob(path)
                return_val = len(glob_results) 
                self.log.debug("Return value for file.count textkey: %s" % str(return_val))
            return return_val
        elif textkey == "file.created":
            if not os.path.exists(path): return 0.0
            age = time.time() - os.path.getctime(path)
            return_val = float(age) / 60.0
            self.log.debug("Return value for file.created textkey: %s" % str(return_val))
            return return_val
        elif textkey == "file.modified":
            if not os.path.exists(path): return 0.0
            age = time.time() - os.path.getmtime(path)
            return_val = float(age) / 60.0
            self.log.debug("Return value for file.modified textkey: %s" % str(return_val))
            return return_val
        elif textkey == "file.size":
            if not os.path.exists(path): return 0.0
            return_val = float(os.path.getsize(path)) / 1024.0
            self.log.debug("Return value for file.size textkey: %s" % str(return_val))
            return return_val
        elif textkey == "directory.size":
            if not os.path.exists(path): return 0.0
            ret, output = agent_util.execute_command('du -sk ' + path)
            return_val =float(output.split()[0])
            self.log.debug("Return value for file.size textkey: %s" % str(return_val))
            return return_val
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 *