def send_statistics(): req = mq.Request('speedd') while not self._exit: msg = {'cmd': 'statistics', 'params':{'time': 'last'}} try: stat = req.request(msg, 1000) self.emit('statistics', stat['sample']) except: pass gevent.sleep(config.statd.interval)
def query_zero_progress(): req = mq.Request('zerod') try: rsp = req.request({'cmd': 'query_zero_progress'}, 10000) if 'success' in rsp['status']: return rsp['detail'] else: raise Exception() finally: req.close()
def temp_alert(self): try: req = mq.Request('speedd') msg = {'cmd': 'statistics', 'params':{'time': 'last'}} stat = req.request(msg, 1000) temp = stat['sample']['temp'] if temp >= config.alert.temp_threshold: return 'warning', temp else: return 'normal', temp except: return 'warning', 'NA'
def query_sync_progress(name): req = mq.Request('syncd') try: #import pdb #pdb.set_trace() rsp = req.request({'cmd': 'query_sync_progress', 'name': name}, 10000) if rsp and rsp['status'] == 'success': if rsp.has_key('detail'): return rsp['detail'] else: return None else: raise Exception() finally: req.close()
def stop_beep(mod): req = mq.Request('beepd') try: req.request({'cmd': 'stop_beep', 'mod': mod}, 10000) finally: req.close()
def delete_sync_volume_task(name): req = mq.Request('syncd') try: req.request({'cmd': 'delete_sync_volume_task', 'name': name}, 10000) finally: req.close()
def stop_sync_volume(name): req = mq.Request('syncd') try: req.request({'cmd': 'stop_sync_volume', 'name': name}, 10000) finally: req.close()
def zero_disks(): req = mq.Request('zerod') try: req.request({'cmd': 'zero_disks'}, 10000) finally: req.close()