예제 #1
0
 def test_perfoutput_01(self):
     log.info("Testing init NagiosPerformance output lap 1.")
     perf = NagiosPerformance(label = 'bla', value = 80, warning = '~:30',
             critical = '~:60', min_data = 0, max_data = 1000)
     log.debug("NagiosPerformance object: %r", perf)
     log.debug("perfoutput: %r", perf.perfoutput())
     self.assertEqual(perf.perfoutput(), 'bla=80;~:30;~:60;0;1000',
             "Error testing perf.perfoutput()")
예제 #2
0
 def test_perfoutput_00(self):
     log.info("Testing init NagiosPerformance output lap 0.")
     perf = NagiosPerformance(label = 'bla', value = 80, warning = '~:30',
             critical = '~:60', uom = 'MByte')
     log.debug("NagiosPerformance object: %r", perf)
     log.debug("perfoutput: %r", perf.perfoutput())
     self.assertEqual(perf.perfoutput(), 'bla=80MByte;~:30;~:60',
             "Error testing perf.perfoutput()")
예제 #3
0
 def test_performance_object_03(self):
     log.info("Testing init NagiosPerformance object lap 3.")
     perf = NagiosPerformance(label = 'bla', value = -10, uom = 'msec')
     log.debug("NagiosPerformance object: %r", perf)
     self.assertEqual(perf.label, 'bla', 'Error testing perf.label')
     self.assertEqual(perf.value, -10, 'Error testing perf.value')
     self.assertEqual(perf.uom, 'msec', 'Error testing perf.uom')
     self.assertFalse(perf.warning.is_set, 'Error testing perf.warning')
     self.assertFalse(perf.critical.is_set, 'Error testing perf.critical')
     self.assertEqual(perf.min_data, None, 'Error testing perf.min_data')
     self.assertEqual(perf.max_data, None, 'Error testing perf.max_data')
     self.assertEqual(perf.status(), nagios.state.ok, 'Error testing perf.status()')
예제 #4
0
 def test_performance_object_02(self):
     log.info("Testing init NagiosPerformance object lap 2.")
     perf = NagiosPerformance(label = 'bla', value = 80, warning = '~:30',
             critical = '~:60', uom = 'MByte')
     log.debug("NagiosPerformance object: %r", perf)
     self.assertEqual(perf.label, 'bla', 'Error testing perf.label')
     self.assertEqual(perf.value, 80, 'Error testing perf.value')
     self.assertEqual(perf.uom, 'MByte', 'Error testing perf.uom')
     self.assertEqual(perf.warning.start, None, 'Error testing perf.warning.start')
     self.assertEqual(perf.warning.end, 30, 'Error testing perf.warning.end')
     self.assertEqual(perf.critical.start, None, 'Error testing perf.critical.start')
     self.assertEqual(perf.critical.end, 60, 'Error testing perf.critical.end')
     self.assertEqual(perf.min_data, None, 'Error testing perf.min_data')
     self.assertEqual(perf.max_data, None, 'Error testing perf.max_data')
     self.assertEqual(perf.status(), nagios.state.critical, 'Error testing perf.status()')
예제 #5
0
    def test_parse_perfoutput_01(self):
        log.info("Testingparsing performance data output output lap 1.")

        perfoutput = "/=382MB;15264;15269;0;32768 /var=218MB;9443;9448"

        plist = NagiosPerformance.parse_perfstring(perfoutput)
        log.debug("perfoutput: %r", plist)
예제 #6
0
    def test_parse_perfoutput_01(self):
        log.info("Testingparsing performance data output output lap 1.")

        perfoutput = "/=382MB;15264;15269;0;32768 /var=218MB;9443;9448"

        plist = NagiosPerformance.parse_perfstring(perfoutput)
        log.debug("perfoutput: %r", plist)
예제 #7
0
 def test_performance_root_label(self):
     log.info("Testing init NagiosPerformance root label.")
     perf = NagiosPerformance(label = '/', value = 1, uom = 'MiByte')
     log.debug("NagiosPerformance object: %r", perf)
     log.debug("clean_label: %r", perf.clean_label)
     self.assertEqual(perf.clean_label,
             'root', 'Error testing perf.clean_label')
예제 #8
0
 def test_performance_object_01(self):
     log.info("Testing init NagiosPerformance object lap 1.")
     warn_range = NagiosRange('30')
     crit_range = NagiosRange('~:60')
     perf = NagiosPerformance(label = 'bla', value = 40, warning = warn_range,
             critical = crit_range, uom = 'MByte')
     log.debug("NagiosPerformance object: %r", perf)
     self.assertEqual(perf.label, 'bla', 'Error testing perf.label')
     self.assertEqual(perf.value, 40, 'Error testing perf.value')
     self.assertEqual(perf.uom, 'MByte', 'Error testing perf.uom')
     self.assertEqual(perf.warning.start, 0, 'Error testing perf.warning.start')
     self.assertEqual(perf.warning.end, 30, 'Error testing perf.warning.end')
     self.assertEqual(perf.critical.start, None, 'Error testing perf.critical.start')
     self.assertEqual(perf.critical.end, 60, 'Error testing perf.critical.end')
     self.assertEqual(perf.min_data, None, 'Error testing perf.min_data')
     self.assertEqual(perf.max_data, None, 'Error testing perf.max_data')
     self.assertEqual(perf.status(), nagios.state.warning, 'Error testing perf.status()')
예제 #9
0
 def test_performance_object_00(self):
     log.info("Testing init NagiosPerformance object lap 0.")
     warn_range = NagiosRange('30')
     crit_range = NagiosRange('60')
     th = NagiosThreshold(warning = warn_range, critical = crit_range)
     perf = NagiosPerformance(label = 'bla', value = 10, threshold = th,
             uom = 'MByte', min_data = 0, max_data = 1000)
     log.debug("NagiosPerformance object: %r", perf)
     self.assertEqual(perf.label, 'bla', 'Error testing perf.label')
     self.assertEqual(perf.value, 10, 'Error testing perf.value')
     self.assertEqual(perf.uom, 'MByte', 'Error testing perf.uom')
     self.assertEqual(perf.warning.start, 0, 'Error testing perf.warning.start')
     self.assertEqual(perf.warning.end, 30, 'Error testing perf.warning.end')
     self.assertEqual(perf.critical.start, 0, 'Error testing perf.critical.start')
     self.assertEqual(perf.critical.end, 60, 'Error testing perf.critical.end')
     self.assertEqual(perf.min_data, 0, 'Error testing perf.min_data')
     self.assertEqual(perf.max_data, 1000, 'Error testing perf.max_data')
     self.assertEqual(perf.status(), nagios.state.ok, 'Error testing perf.status()')
예제 #10
0
 def test_performance_labels(self):
     log.info("Testing init NagiosPerformance labels.")
     perf = NagiosPerformance(
             label = '/var/long@:-/filesystem/name/and/bad/chars',
             value = 218, uom = 'MB')
     log.debug("NagiosPerformance object: %r", perf)
     self.assertEqual(perf.label,
             '/var/long@:-/filesystem/name/and/bad/chars',
             'Error testing perf.label')
     log.debug("clean_label: %r", perf.clean_label)
     self.assertEqual(perf.clean_label,
             'var_long____filesystem_name_and_bad_chars',
             'Error testing perf.clean_label')
     log.debug("rrdlabel: %r", perf.rrdlabel)
     self.assertEqual(perf.rrdlabel,
             'var_long____filesys', 'Error testing perf.rrdlabel')
예제 #11
0
    def add_perfdata(
        self, label, value, uom=None, threshold=None, warning=None, critical=None,
            min_data=None, max_data=None):
        """
        Adding a NagiosPerformance object to self.perfdata.

        @param label: the label of the performance data, mandantory
        @type label: str
        @param value: the value of the performance data, mandantory
        @type value: Number
        @param uom: the unit of measure
        @type uom: str or None
        @param threshold: an object for the warning and critical thresholds
                          if set, it overrides the warning and critical parameters
        @type threshold: NagiosThreshold or None
        @param warning: a range for the warning threshold,
                        ignored, if threshold is given
        @type warning: NagiosRange, str, Number or None
        @param critical: a range for the critical threshold,
                        ignored, if threshold is given
        @type critical: NagiosRange, str, Number or None
        @param min_data: the minimum data for performance output
        @type min_data: Number or None
        @param max_data: the maximum data for performance output
        @type max_data: Number or None

        """

        pdata = NagiosPerformance(
            label=label,
            value=value,
            uom=uom,
            threshold=threshold,
            warning=warning,
            critical=critical,
            min_data=min_data,
            max_data=max_data
        )

        self.perfdata.append(pdata)