MSV FM

[email protected]: ~ $
Path : /lib/fm-agent/library/__pycache__/
File Upload :
Current < : //lib/fm-agent/library/__pycache__/log_matcher.cpython-36.pyc

3

��f�@s<ddlZddlmZmZddlZddlZGdd�de�ZdS)�N)�datetime�	timedeltac@sTeZdZdZdd�Zddd�Zddd�Zd	d
�Zdd�Ze	d
d��Z
e	dd��ZdS)�
LogMatcherz5
    Handles the matching of filter in the logs.
    cCs
||_dS)zV
        @param file_creation: last known creation timestamp of the log file.
        N)�_inode)�self�inode�r�(/usr/lib/fm-agent/library/log_matcher.py�__init__szLogMatcher.__init__Nc	s�|sg}y|j�Wn4tk
rHddl}|j�\}}}tj|�gSX�fdd�}tt||��}|jt	j
�t|�f�|SdS)z�
        Match the ampount of times expression is present in lines,
        return the results with the new entry appended to it.

        @param expression: String,
        @param lines: Iterable
        @param results: List of past results
        rNcstj�|�}|r|pdS)NF)�re�search)�line�match)�
expressionrr	�
find_match%sz$LogMatcher.match.<locals>.find_match)�_valid_inode�
ValueError�sys�exc_info�logging�info�list�filter�appendr�now�len)	r�linesr�resultsr�_�errorr�
matched_linesr)rr	rs	
zLogMatcher.matchcs�|sg}y|j�Wn4tk
rHddl}|j�\}}}tj|�gSXdd�|D�}��fdd�}	tt|	|��}
|jt	j
�t|
�f�|S)a�
        Return the number of lines that the where the column is
        equal to the expression by splitting the lines.

        @param lines: Array of lines to split and search.
        @param expression: Regular expression to match agains the specified column
        @param column: Column number to separate from the regular line.
        @param results: List of past results
        rNcSsg|]}|j��qSr)�split)�.0r
rrr	�
<listcomp>@sz.LogMatcher.match_in_column.<locals>.<listcomp>cs |�}tj�|�}|r|pdS)NF)rr)r
Z
data_pointr)�columnrrr	rBsz.LogMatcher.match_in_column.<locals>.find_match)rrrrrrrrrrrr)rrrr$rrrrZsplitted_linesrr r)r$rr	�match_in_column-s

zLogMatcher.match_in_columncCs|jdkrtd��dS)z�
        Validate that we have an inode. If we dont
        that means we are running the check for the first time,
        and don't have enought information to calculate the matchs.
        NzInode is None. Returning None)rr)rrrr	rJs
zLogMatcher._valid_inodecCs`d}g}x@|D]8\}}tj�|}|t|d�kr||7}|j||f�qW|jsXdgfS||fS)a�
        Check the results and the timescale to determine if a metric
        should be given. The delta between now and the last results time
        must be greater than the timescale to properly calculate the metric.

        @param results: List of past results.
        @param timescale: Integer of the buffer size to take into
        consideration.
        @param last_results_time: Datetime
        r)�minutesN)rrrrr)rr�	timescaleZ	total_sumZ
valid_results�	timestamp�result�deltarrr	�calculate_metricSszLogMatcher.calculate_metricc	Csvg}d}d}t|d�}|dkr:xt|�D]\}}q(W|}n,x&t|�D]\}}||krD|j|�qDW|}|j�||fS)z`
        Grab the lines from the last known line number to the
        end of the file.
        r�rN)�open�	enumerater�close)	Zlast_known_line_number�sourceZ
current_inode�stored_inodeZexpected_lines�index�total_linesZopened_filer
rrr	�get_file_linesis
zLogMatcher.get_file_linescCstj|�jS)z1
        Grab the file created timstamp.
        )�os�stat�st_ino)r0rrr	�get_file_inode�szLogMatcher.get_file_inode)N)N)�__name__�
__module__�__qualname__�__doc__r
rr%rr+�staticmethodr4r8rrrr	rs

	r)rrrrr5�objectrrrrr	�<module>s
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 *