Ejemplo n.º 1
0
 def _diagnostics_links_cb(data):
     node_key = lambda n: '/node/links%s' % n
     # nothing to do if the message is empty
     if len(data.links) <= 0:
         return
     # store info about links
     node = data.links[0].node
     links = [
         {
             'topic': link.topic,
             'remote': link.remote,
             'direction': TopicDirection(link.direction).name,
             'connected': link.connected,
             'transport': link.transport,
             'messages': link.messages,
             'dropped': link.dropped,
             'bytes': link.bytes,
             'frequency': link.frequency,
             'bandwidth': link.bandwidth
         }
         for link in data.links
         if not is_infra_topic(link.topic)
     ]
     # ---
     KnowledgeBase.set(node_key(node), links)
Ejemplo n.º 2
0
 def _diagnostics_node_cb(data):
     if is_infra_node(data.name):
         return
     # ---
     key = '/node/info%s' % data.name
     # store info about nodes
     info = {
         'help': data.help,
         'type': NodeType(data.type).name,
         'health': NodeHealth(data.health).name,
         'health_value': NodeHealth(data.health).value,
         'health_reason': data.health_reason,
         'health_stamp': data.health_stamp,
         'enabled': data.enabled,
         'machine': data.machine,
         'module_type': data.module_type,
         'module_instance': data.module_instance
     }
     KnowledgeBase.set(key, info)
Ejemplo n.º 3
0
 def _diagnostics_topics_cb(data):
     topic_key = lambda k, t: '/topic/%s%s' % (k, t)
     node_key = lambda n: '/node/topics%s' % n
     # nothing to do if the message is empty
     if len(data.topics) <= 0:
         return
     # store info about topics
     node = data.topics[0].node
     topics = KnowledgeBase.get(node_key(node), {})
     for topic in data.topics:
         if is_infra_topic(topic.name):
             continue
         # ---
         # store topic type
         topic_type_str = TopicType(topic.type).name
         KnowledgeBase.set(topic_key('type', topic.name), topic_type_str)
         # compile topic info
         info = {
             'help': topic.help,
             'message_type': None,
             'type': topic_type_str,
             # TODO: these should be averaged
             'bandwidth': topic.bandwidth,
             'frequency': topic.frequency,
             'effective_frequency': topic.effective_frequency
         }
         KnowledgeBase.set(topic_key('info', topic.name), info)
         # frequency
         KnowledgeBase.set(topic_key('hz', topic.name), topic.frequency)
         # bandwidth
         KnowledgeBase.set(topic_key('bw', topic.name), topic.bandwidth)
         # add topic to node topics
         topics[topic.name] = {
             'direction': TopicDirection(topic.direction).name,
             'healthy_frequency': topic.healthy_frequency,
             'processing_time': topic.processing_time,
             'enabled': topic.enabled
         }
         topics[topic.name].update(info)
         # store info about node topics
     KnowledgeBase.set(node_key(node), topics)
Ejemplo n.º 4
0
 def _diagnostics_params_cb(data):
     node_key = lambda n: '/node/params%s' % n
     param_key = lambda p: '/param/info%s' % p
     # nothing to do if the message is empty
     if len(data.params) <= 0:
         return
     # store info about params
     node = data.params[0].node
     params = KnowledgeBase.get(node_key(node), [])
     for param in data.params:
         info = {
             'help': param.help,
             'type': ParamType(param.type).name,
             'min_value': param.min_value,
             'max_value': param.max_value,
             'editable': param.editable
         }
         KnowledgeBase.set(param_key(param.name), info)
         # make list of params per node
         params.append(param.name)
     # ---
     KnowledgeBase.set(node_key(node), list(set(params)))