def processResults(self, cmd, result): # best effort. Try Nagios first, if that doesn't return data values # try Cacti. If cacti doesn't return value use results from nagios # since it is more likely to have been an error parsing nagios data # and the nagios parser puts more data in the event. Both parsers # have the same logic for event severity based on exit code cactiResult= None nagiosResult = ParsedResults() nagiosParser = Nagios() nagiosParser.processResults(cmd, nagiosResult) if not nagiosResult.values: cactiParser = Cacti() cactiResult= ParsedResults() cactiParser.processResults(cmd, cactiResult) if cactiResult and cactiResult.values: #use cacti results parserResult = cactiResult else: parserResult = nagiosResult result.events.extend(parserResult.events) result.values.extend(parserResult.values)
def setUp(self): self.cmd = Object() deviceConfig = Object() deviceConfig.device = 'localhost' self.cmd.deviceConfig = deviceConfig self.cmd.name = "testDataSource" self.cmd.parser = "Nagios" self.cmd.result = Object() self.cmd.result.exitCode = 2 self.cmd.severity = 2 self.cmd.command = "testNagiosPlugin" self.cmd.eventKey = "nagiosKey" self.cmd.eventClass = "/Cmd" self.cmd.component = "zencommand" self.parser = Nagios() self.results = ParsedResults() self.dpdata = dict(processName='someJob a b c', ignoreParams=False, alertOnRestart=True, failSeverity=3)