def __runTest(self, expected, f, args): try: checkstat.runCheck(f, args, StringIO.StringIO()) except SystemExit, e: self.assertEquals(expected, e[0])
#!/usr/bin/env python """ Check that the value of a particular stat is within an acceptable range. Copyright (c) 2005 Dustin Sallings <*****@*****.**> """ import cmsstat import checkstat if __name__ == '__main__': def getVal(host, service, default): url="http://%s:8080/admin/monitor/stat" % (host,) return cmsstat.StatFetcher(url).getValue(service, default) checkstat.runCheck(getVal)
""" Check that the value of a particular stat is within an acceptable range. Copyright (c) 2005 Dustin Sallings <*****@*****.**> """ import cmsstat import checkstat def getVal(host, service, default): url = "http://%s:8080/admin/monitor/stat" % (host, ) val = cmsstat.StatFetcher(url).getValue(service, default) storedVal = cmsstat.ArchivedStat(host, service) # make sure we store a value for this storedVal.store(val) oldval, adjust = storedVal.getValue(), 1.0 if oldval is None: oldval = 0 else: adjust = storedVal.getAge() / 60.0 rate = float(val - oldval) / adjust return rate if __name__ == '__main__': checkstat.runCheck(getVal)