def test(self): t = MinMaxThreshold("test_threshold") t.minval = self.min t.maxval = self.max ti = None d = self._getDevice() if d: ti = t.createThresholdInstance(d) if self.min: print "Using min of %s which evaluates to %s" % (self.min, ti.minimum) if self.max: print "Using max of %s which evaluates to %s" % (self.max, ti.maximum) print "The following event would be generated: %s" % ti.checkRange("test_threshold", self.value)
def replaceThreshold(self, template, old): if not isinstance(old, ThresholdClass): new = MinMaxThreshold(old.id) template.thresholds.removeRelation(old) for p in old._properties: name = p['id'] setattr(new, name, getattr(old, name)) old = new template.thresholds._setObject(old.id, old)
def cutover(self, dmd): templates = ICatalogTool(dmd).search( "Products.ZenModel.RRDTemplate.RRDTemplate", query=Eq("name", "OSProcess")) for t in templates: template = t.getObject() threshold = MinMaxThreshold('count') template.thresholds._setObject("count", threshold) t = template.thresholds._getOb("count") t.dsnames = ProcessCountThreshold.datapoints(template) print t.getPrimaryId(), t.dsnames, t t.minval = 'here.getMinProcessCount()' t.maxval = 'here.getMaxProcessCount()'
def afterSetUp(self): super(TestMinMaxThreshold, self).afterSetUp() device = self.dmd.Devices.createInstance('test-device') t = MinMaxThreshold('test') self.threshold = t.createThresholdInstance(device)