zephir.monitor.agents.sso

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

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

     1  # -*- coding: UTF-8 -*-
     2  ###########################################################################
     3  # Eole NG - 2011
     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 pour la page d'authentification d'EoleSSO (service local)
    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 status_to_img
    17  from os import system
    18
    19 -class SSO(Agent):
    20
    21 -    def __init__(self, name, sso_port, **params):
    22          self.sso_port = sso_port
    23          Agent.__init__(self, name, **params)
    24          self.table = TableData([
    25              ('status', "État", {'align':'center'}, status_to_img),
    26              ('service', "Service", {'align':'left'}, None),
    27              ])
    28          self.data = [self.table]
    29
    30 -    def measure(self):
    31          mesures = []
    32          # test de récupération des métadata
    33          meta_url = "https://localhost:%s/saml/metadata" % self.sso_port
    34          stat = "On"
    35          cmd_test = "/usr/bin/wget -q -t2 --no-check-certificate --timeout=10 --delete-after %s" % meta_url
    36          code = system(cmd_test)
    37          if code != 0:
    38              stat = "Off"
    39          mesures.append({'status':stat, 'service':'Application web EoleSSO'})
    40          return mesures
    41
    42 -    def write_data(self):
    43          Agent.write_data(self)
    44          if self.last_measure is not None:
    45              self.table.table_data = self.last_measure.value
    46
    47 -    def check_status(self):
    48          """remonte une erreur si un des services est tombé"""
    49          if self.last_measure is not None:
    50              for service in self.last_measure.value:
    51                  self.measure_data[service['service']] = service['status']
    52                  if service['status'] != 'On':
    53                      return status.Error()
    54          else:
    55              # pas de mesure connue
    56              return status.Unknown()
    57          return status.OK()
    58