def testSendCpuInfo(self): if platform.system() == 'Windows': return import zmq import json ctx = zmq.Context() sock = ctx.socket(zmq.PULL) sock.bind('tcp://*:5555') zm = ZMeter() zm.send('cpu') header = sock.recv(0) body = sock.recv(0) header = json.loads(header) info = json.loads(body) self.assertTrue(info.has_key('cpu')) data = info['cpu'] self.assertTrue(data.has_key('all.usr')) self.assertEquals(data.get('all.idle'), 100.0 - data.get('all.used')) sock.close() ctx.term()
def testSendCpuInfo(self): if platform.system() == 'Windows': return import zmq import json ctx = zmq.Context() sock = ctx.socket(zmq.PULL) sock.bind('tcp://*:5555') zm = ZMeter() zm.send('cpu') header = sock.recv(0) body = sock.recv(0) header = json.loads(header) info = json.loads(body) self.assertTrue(info.has_key('cpu')) data = info['cpu'] self.assertTrue(data.has_key('all.usr')) self.assertEquals(data.get('all.idle') , 100.0 - data.get('all.used')) sock.close() ctx.term()
def testFetchMemInfo(self): zm = ZMeter() info = zm.fetch('mem') self.assertTrue(info.has_key('total')) self.assertTrue( info.get('used') <= info.get('total') - info.get('free'))
def testFetchIoStat(self): zm = ZMeter() info = zm.fetch('iostat') print info self.assertTrue(info.has_key('meta.devs'))
def testFetchLoadInfo(self): zm = ZMeter() info = zm.fetch('load') print info self.assertTrue(info.has_key('avg15'))
def testFetchProcessinfo(self): zm = ZMeter() info = zm.fetch('process') time.sleep(5) info = zm.fetch('process') print info self.assertTrue(info.has_key('snapshot.top'))
def testFetchMysql(self): if platform.system() == 'Windows': return zm = ZMeter(config={'mysql': {'port': 3306}}) info = zm.fetch('mysql') self.assertTrue(info.has_key('slow_queries'))
def testFetchMssql(self): if platform.system() == 'Linux': return zm = ZMeter(config = {'mssql': {'name' : 'SQLEXPRESS'}}) info = zm.fetch('mssql') self.assertTrue(info.has_key('lock_waited'))
def testFetchCpuInfo(self): zm = ZMeter() info = zm.fetch('cpu') print info self.assertTrue(info.has_key('all.usr')) self.assertEquals(info.get('all.idle') , 100.0 - info.get('all.used'))
def testFetchCpuInfo(self): zm = ZMeter() info = zm.fetch('cpu') print info self.assertTrue(info.has_key('all.usr')) self.assertEquals(info.get('all.idle'), 100.0 - info.get('all.used'))
def testFetchMssql(self): if platform.system() == 'Linux': return zm = ZMeter(config={'mssql': {'name': 'SQLEXPRESS'}}) info = zm.fetch('mssql') self.assertTrue(info.has_key('lock_waited'))
def testFetchMysql(self): if platform.system() == 'Windows': return zm = ZMeter(config = {'mysql': {'port' : 3306}}) info = zm.fetch('mysql') self.assertTrue(info.has_key('slow_queries'))
def testWatchProcessinfo(self): zm = ZMeter(config = {'watch': {'x': 'python', 'y':'xyz'}}) info = zm.fetch('process') self.assertEquals(info['meta.watches'], 'y:xyz,x:python') time.sleep(5) info = zm.fetch('process') self.assertTrue(info['watch.x.count']> 0) self.assertEquals(info['watch.y.count'], 0)
def testFetchSysinfo(self): zm = ZMeter() info = zm.fetch('system') print info self.assertTrue(info.has_key('meta.host')) self.assertTrue(info.has_key('meta.dist')) self.assertTrue(info.has_key('meta.ip'))
def testFetchDiskInfo(self): zm = ZMeter() info = zm.fetch('disk') print info self.assertTrue(info.has_key('meta.mounts')) self.assertTrue(info.has_key('0.total')) self.assertEquals(info.get('0.pfree'), 100 - info.get('0.pused'))
def testFetchNetInfo(self): zm = ZMeter() info = zm.fetch('net') self.assertTrue(info.has_key('meta.ifs')) time.sleep(5) info = zm.fetch('net') self.assertTrue(info.has_key('0.in.bps')) self.assertTrue(info.has_key('0.out.bps'))