示例#1
0
 def test_str_has_performance_data(self):
     """
     Tests that with performance data, the status output
     will output the value along with the performance data.
     """
     instance = Response(pynagios.OK, message="yo")
     instance.set_perf_data("users", 20)
     instance.set_perf_data("foos", 80)
     expected = '%s: %s|users=20;;;; foos=80;;;;' % (pynagios.OK.name, "yo")
     assert expected == str(instance)
示例#2
0
 def test_str_has_performance_data(self):
     """
     Tests that with performance data, the status output
     will output the value along with the performance data.
     """
     instance = Response(pynagios.OK, message="yo")
     instance.set_perf_data("users", 20)
     instance.set_perf_data("foos", 80)
     expected = '%s: %s|users=20;;;; foos=80;;;;' % (pynagios.OK.name, "yo")
     assert expected == str(instance)
        }
        for proc in procs:
            processes[proc['statename']].append(proc['name'])

        ret = OK
        for state in ('STOPPING', 'STARTING'):
            if len(processes[state]):
                ret = WARNING

        if len(processes['UNKNOWN']):
            ret = UNKNOWN

        for state in ('EXITED', 'BACKOFF', 'FATAL'):
            if len(processes[state]):
                ret = CRITICAL

        result = Response(ret, processes)

        msg = []
        for k, v in processes.items():
            if v:
                msg.append('%s: %s' % (k, ', '.join(v)))
            result.set_perf_data(k, len(v))

        result.message = ' '.join(msg)
        return result


if __name__ == '__main__':
    SupervisordXmlRpcCheck().check().exit()
                     'BACKOFF': [], 'STOPPING': [], 'EXITED': [],
                     'FATAL': [], 'UNKNOWN': []}
        for proc in procs:
            processes[proc['statename']].append(proc['name'])

        ret = OK
        for state in ('STOPPING', 'STARTING'):
            if len(processes[state]):
                ret = WARNING

        if len(processes['UNKNOWN']):
            ret = UNKNOWN

        for state in ('EXITED', 'BACKOFF', 'FATAL'):
            if len(processes[state]):
                ret = CRITICAL

        result = Response(ret, processes)

        msg = []
        for k, v in processes.items():
            if v:
                msg.append('%s: %s' % (k, ', '.join(v)))
            result.set_perf_data(k, len(v))

        result.message = ' '.join(msg)
        return result

if __name__ == '__main__':
    SupervisordXmlRpcCheck().check().exit()