def test_plugin_object_props(self): log.info("Testing NagiosPlugin object properties.") plugin = NagiosPlugin() self.assertIsInstance(plugin, NagiosPlugin) log.debug("Setting shortname explicitly to 'PAGESIZE'.") plugin.shortname = "PAGESIZE" self.assertEqual(plugin.shortname, "PAGESIZE") log.debug("Resetting plugin to default.") plugin = NagiosPlugin() self.assertEqual(plugin.shortname, "TEST_PLUGIN_01") log.debug("Creating plugin with a shortname 'SIZE' on init.") plugin = NagiosPlugin(shortname = 'SIZE') self.assertEqual(plugin.shortname, "SIZE") log.debug("Creating plugin with a plugin name 'check_stuff'") plugin = NagiosPlugin(plugin = 'check_stuff') self.assertEqual(plugin.shortname, "STUFF") log.debug("Creating plugin with a shortname 'SIZE' and a plugin " + "name 'check_stuff' on init.") plugin = NagiosPlugin(shortname = 'SIZE', plugin = 'check_stuff') self.assertEqual(plugin.shortname, "SIZE") log.debug("Setting thresholds to warn if < 10, critical if > 25.") t = plugin.set_thresholds(warning = "10:25", critical = "~:25") self.assertIsInstance(t, NagiosThreshold) log.debug("Adding performance data size ...") plugin.add_perfdata( label = "size", value = 1, uom = "kB", threshold = t ) pdata = plugin.all_perfoutput() log.debug("Got performance data: %r", pdata) self.assertEqual(pdata, 'size=1kB;10:25;~:25') log.debug("Adding performance data time ...") plugin.add_perfdata(label = "time", value = 3.52, threshold = t) pdata = plugin.all_perfoutput() log.debug("Got performance data: %r", pdata) self.assertEqual(pdata, 'size=1kB;10:25;~:25 time=3.52;10:25;~:25')
def test_plugin_object_props(self): log.info("Testing NagiosPlugin object properties.") plugin = NagiosPlugin() self.assertIsInstance(plugin, NagiosPlugin) log.debug("Setting shortname explicitly to 'PAGESIZE'.") plugin.shortname = "PAGESIZE" self.assertEqual(plugin.shortname, "PAGESIZE") log.debug("Resetting plugin to default.") plugin = NagiosPlugin() self.assertEqual(plugin.shortname, "TEST_PLUGIN_01") log.debug("Creating plugin with a shortname 'SIZE' on init.") plugin = NagiosPlugin(shortname='SIZE') self.assertEqual(plugin.shortname, "SIZE") log.debug("Creating plugin with a plugin name 'check_stuff'") plugin = NagiosPlugin(plugin='check_stuff') self.assertEqual(plugin.shortname, "STUFF") log.debug("Creating plugin with a shortname 'SIZE' and a plugin " + "name 'check_stuff' on init.") plugin = NagiosPlugin(shortname='SIZE', plugin='check_stuff') self.assertEqual(plugin.shortname, "SIZE") log.debug("Setting thresholds to warn if < 10, critical if > 25.") t = plugin.set_thresholds(warning="10:25", critical="~:25") self.assertIsInstance(t, NagiosThreshold) log.debug("Adding performance data size ...") plugin.add_perfdata(label="size", value=1, uom="kB", threshold=t) pdata = plugin.all_perfoutput() log.debug("Got performance data: %r", pdata) self.assertEqual(pdata, 'size=1kB;10:25;~:25') log.debug("Adding performance data time ...") plugin.add_perfdata(label="time", value=3.52, threshold=t) pdata = plugin.all_perfoutput() log.debug("Got performance data: %r", pdata) self.assertEqual(pdata, 'size=1kB;10:25;~:25 time=3.52;10:25;~:25')