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

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

     1  ###########################################################################
     2  #
     3  # This program is part of Zenoss Core, an open source monitoring platform.
     4  # Copyright (C) 2008, Zenoss Inc.
     5  #
     6  # This program is free software; you can redistribute it and/or modify it
     7  # under the terms of the GNU General Public License version 2 or (at your
     8  # option) any later version as published by the Free Software Foundation.
     9  #
    10  # For complete information please visit: http://www.zenoss.com/oss/
    11  #
    12  ###########################################################################
    13
    14  from Products.ZenRRD.parsers.Cacti import Cacti
    15  from Products.ZenRRD.parsers.Nagios import Nagios
    16  from Products.ZenRRD.CommandParser import CommandParser, ParsedResults
    17
    18 -class Auto(CommandParser):
    19
    20
    21 -    def processResults(self, cmd, result):
    22
    23          # best effort.  Try Nagios first, if that doesn't return data values
    24          # try Cacti. If cacti doesn't return value use results from nagios
    25          # since it is more likely to have been an error parsing nagios data
    26          # and the nagios parser puts more data in the event.  Both parsers
    27          # have the same logic for event severity based on exit code
    28
    29          cactiResult= None
    30          nagiosResult = ParsedResults()
    31
    32          nagiosParser = Nagios()
    33          nagiosParser.processResults(cmd, nagiosResult)
    34
    35          if not nagiosResult.values:
    36              cactiParser = Cacti()
    37              cactiResult= ParsedResults()
    38              cactiParser.processResults(cmd, cactiResult)
    39
    40          if cactiResult and cactiResult.values:
    41             #use cacti results
    42              parserResult = cactiResult
    43          else:
    44              parserResult = nagiosResult
    45
    46          result.events.extend(parserResult.events)
    47          result.values.extend(parserResult.values)
    48