zephir.monitor.agents.sentinelle

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

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

     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 de récolte d'informations pour sentinelle
    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 os.path import isfile
    17
    18 -class Sentinelle(Agent):
    19
    20 -    def __init__(self, name, **params):
    21          Agent.__init__(self, name, **params)
    22          self.table = TableData([
    23              ('description', '', {'align':'center'}, None),
    24              ('valeur', 'valeur actuelle', {'align':'center'}, None)])
    25          self.data = [self.table]
    26
    27 -    def measure(self):
    28          """ Maj-Auto  (activation , date) """
    29          res = []
    30          cron_maj = '/usr/share/ead2/backend/tmp/cron.txt'
    31          if not isfile(cron_maj):
    32              self.measure_data['maj_auto'] = ''
    33              res.append({ 'description':'Mise à jour automatique',
    34                           'valeur':'désactivée' })
    35          else:
    36              f_cron = open(cron_maj)
    37              data = f_cron.read().strip()
    38              f_cron.close()
    39              self.measure_data['maj_auto'] = data
    40              res.append({ 'description':'Mise à jour automatique',
    41                           'valeur':data })
    42
    43          return { 'statistics' : res }
    44
    45 -    def write_data(self):
    46          """ enregistrement """
    47          Agent.write_data(self)
    48          if self.last_measure is not None:
    49              self.table.table_data = self.last_measure.value['statistics']
    50
    51 -    def check_status(self):
    52          """ envoi du statut (toujours OK) """
    53          return status.OK()
    54