Package Products :: Package ZenRRD :: Package parsers :: Module Auto |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenRRD.parsers.Auto

     1  ##############################################################################
     2  #
     3  # Copyright (C) Zenoss, Inc. 2008, all rights reserved.
     4  #
     5  # This content is made available according to terms specified in
     6  # License.zenoss under the directory where your Zenoss product is installed.
     7  #
     8  ##############################################################################
     9
    10
    11  from Products.ZenRRD.parsers.Cacti import Cacti
    12  from Products.ZenRRD.parsers.Nagios import Nagios
    13  from Products.ZenRRD.CommandParser import CommandParser, ParsedResults
    14
    15 -class Auto(CommandParser):
    16
    17
    18 -    def processResults(self, cmd, result):
    19
    20          # best effort.  Try Nagios first, if that doesn't return data values
    21          # try Cacti. If cacti doesn't return value use results from nagios
    22          # since it is more likely to have been an error parsing nagios data
    23          # and the nagios parser puts more data in the event.  Both parsers
    24          # have the same logic for event severity based on exit code
    25
    26          cactiResult= None
    27          nagiosResult = ParsedResults()
    28
    29          nagiosParser = Nagios()
    30          nagiosParser.processResults(cmd, nagiosResult)
    31
    32          if not nagiosResult.values:
    33              cactiParser = Cacti()
    34              cactiResult= ParsedResults()
    35              cactiParser.processResults(cmd, cactiResult)
    36
    37          if cactiResult and cactiResult.values:
    38             #use cacti results
    39              parserResult = cactiResult
    40          else:
    41              parserResult = nagiosResult
    42
    43          result.events.extend(parserResult.events)
    44          result.values.extend(parserResult.values)
    45