zephir.monitor.agents.squid

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

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

     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 pour la charge squid
    11  """
    12
    13  from zephir.monitor.agentmanager.agent import RRDAgent
    14  from zephir.monitor.agentmanager import status
    15  from zephir.monitor.agentmanager.util import log
    16  from twisted.internet.utils import getProcessOutput
    17
    18 -class Squid(RRDAgent):
    19      """Mesure de la charge squid
    20      """
    21
    22 -    def measure(self):
    23          """Récupération des infos sur l'agent snmp de squid"""
    24
    25          res = getProcessOutput("./bin/squid_snmp.sh",
    26                                      env = {'LC_ALL': 'C'})
    27          res.addCallbacks(self.measure_process, self.error_process)
    28          return res
    29
    30 -    def error_process(self, *args):
    31          log.msg("erreur retournée par bin/squid_snmp.sh")
    32          return None
    33
    34 -    def measure_process(self, data):
    35          resultat={}
    36          try:
    37              lines = data.split('\n')
    38              resultat['inko'] = int(float(lines[0].strip()) * 1000)
    39              resultat['outko'] = int(float(lines[1].strip()) * 1000)
    40              resultat['hitsratio'] = lines[2].strip()
    41              resultat['bytesratio'] = lines[3].strip()
    42              resultat['server'] = lines[4].strip()
    43              resultat['client'] = lines[5].strip()
    44          except Exception, e:
    45              log.msg(str(e))
    46          return resultat
    47
    48 -    def check_status(self):
    49          if self.last_measure is None:
    50              # erreur de récupération des stats snmp
    51              return status.Unknown()
    52          # pas d'alerte sur les statistiques ?
    53          return status.OK()
    54