zephir.monitor.agents.sauvegarde

Package zephir :: Package monitor :: Package agents :: Module sauvegarde |
[frames] | no frames]

# Source Code for Module zephir.monitor.agents.sauvegarde

     1  # -*- coding: UTF-8 -*-
     2  ###########################################################################
     3  # Eole NG - 2007
     4  # Copyright Pole de Competence Eole  (Ministere Education - Academie Dijon)
     5  # Licence CeCill  cf /root/LicenceEole.txt
     6  # eole@ac-dijon.fr
     7  ###########################################################################
     8
     9  """
    10  Agent zephir testant le résultat de la dernière sauvegarde
    11  """
    12
    13  from zephir.monitor.agentmanager.agent import Agent
    14  from zephir.monitor.agentmanager.data import TableData
    15  from zephir.monitor.agentmanager import status
    16  from zephir.monitor.agentmanager.util import boolean_to_onoff, status_to_img
    17  from pyeole.bacula import bacula_rapport_load, BACULA_RAPPORT_UNKNOWN, \
    18          BACULA_RAPPORT_OK, BACULA_RAPPORT_ERR
    19
    20 -class Sauvegarde(Agent):
    21
    22 -    def __init__(self, name, **params):
    23          Agent.__init__(self, name, **params)
    24          self.table = TableData([
    25              ('status', 'Statut', {'align':'center'}, status_to_img),
    26              ('type', 'Type de sauvegarde', {'align':'center'}, None),
    27              ('comment', 'Dernière sauvegarde', {'align':'center'}, None)])
    28          self.data = [self.table]
    29          self.status = status.OK()
    30
    31 -    def measure(self):
    32          ret_svg = bacula_rapport_load('sauvegarde')
    33          ret_ctlg = bacula_rapport_load('catalogue')
    34          status_svg = {BACULA_RAPPORT_UNKNOWN: status.Unknown(),
    35                  BACULA_RAPPORT_OK: status.OK(),
    36                  BACULA_RAPPORT_ERR: status.Error()}.get(ret_svg[0])
    37          status_ctlg = {BACULA_RAPPORT_UNKNOWN: status.Unknown(),
    38                  BACULA_RAPPORT_OK: status.OK(),
    39                  BACULA_RAPPORT_ERR: status.Error()}.get(ret_ctlg[0])
    40          res = [{ 'status': status_svg,
    41                   'type': 'sauvegarde',
    42                   'comment': ret_svg[1]},
    43                 { 'status': status_ctlg,
    44                   'type': 'catalogue',
    45                   'comment': ret_ctlg[1]}]
    46          self.status = max(status_svg, status_ctlg)
    47          return {'statistics': res }
    48
    49 -    def write_data(self):
    50          Agent.write_data(self)
    51          if self.last_measure is not None:
    52              self.table.table_data = self.last_measure.value['statistics']
    53
    54 -    def check_status(self):
    55          return self.status
    56