def on_message(self, message):
     try:
         m = Monitor()
         data = dict()
         if message == "system":
             data = dict(mem=m.mem(),
                         swap=m.swap(),
                         cpu=m.cpu(),
                         disk=m.disk(),
                         net=m.net(),
                         dt=m.dt())
         RealTimeHandler.send_updates(json.dumps(data))
     except Exception as e:
         print(e)
Exemple #2
0
 def on_message(self, message):
     try:
         m = Monitor()
         data = dict()
         if message == "system":
             data = dict(mem=m.mem(),
                         swap=m.swap(),
                         cpu=m.cpu(),
                         disk=m.disk(),
                         net=m.net(),
                         dt=m.dt())
         # 对消息进行处理,把新的消息推送到所有连接的客户端
         self.broadcast(self.waiters, json.dumps(data))  # 广播
     except Exception as e:
         print(e)
Exemple #3
0
 def on_message(self, message):
     """接收消息"""
     try:
         m = Monitor()
         data = dict()
         if message == 'system':
             data = dict(
                 mem=m.mem(),
                 swap=m.swap(),
                 cpu=m.cpu(),
                 disk=m.disk(),
                 net=m.net(),
                 dt=m.dt()
             )
             # pprint(data)
             # 接收消息并处理,把新消息发给所有客户端
             self.broadcast(self.waiters, json.dumps(data))  # 广播
     except Exception as e:
         print(e)