Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigiboard / vigiboard / controllers / plugins / occurrences.py @ 011743be

History | View | Annotate | Download (1.06 KB)

1 15b98053 Francois POIROTTE
# -*- coding: utf-8 -*-
2 4febadf0 Francois POIROTTE
# vim:set expandtab tabstop=4 shiftwidth=4:
3 011743be Francois POIROTTE
# Copyright (C) 2007-2020 CS GROUP - France
4 9b8d9497 Francois POIROTTE
# License: GNU GPL v2 <http://www.gnu.org/licenses/gpl-2.0.html>
5 a77de887 Francois POIROTTE
6 15b98053 Francois POIROTTE
"""
7 4febadf0 Francois POIROTTE
Un plugin pour VigiBoard qui ajoute une colonne avec le nombre
8
d'occurrences d'un événement corrélé donné.
9 15b98053 Francois POIROTTE
"""
10 5a845c93 Vincent QUEMENER
from vigilo.models.tables import StateName, CorrEvent
11 94f31908 Francois POIROTTE
from vigiboard.controllers.plugins import VigiboardRequestPlugin
12 15b98053 Francois POIROTTE
13
class PluginOccurrences(VigiboardRequestPlugin):
14 4febadf0 Francois POIROTTE
    """
15
    Ce plugin affiche le nombre d'occurrences d'un événement corrélé.
16
    Ce compteur d'occurrences est mis à jour automatiquement par le
17
    corrélateur chaque fois qu'un événement brut survient sur la cause
18
    de l'événement corrélé.
19
    """
20 a2fa6a5b Francois POIROTTE
    def get_data(self, event):
21
        state = StateName.value_to_statename(event[0].cause.current_state)
22
        return {
23
            'state': state,
24
            'occurrences': event[0].occurrence,
25
        }
26 5a845c93 Vincent QUEMENER
27
    def get_sort_criterion(self, query, column):
28
        if column == 'occurrences':
29
            return CorrEvent.occurrence
30
        return None