Ejemplo n.º 1
0
def print_node_info(node_name, sleep_s=2):
    roleattr_rawdata = cyber.NodeUtils.get_node_attr(node_name, sleep_s)
    from cyber.proto.role_attributes_pb2 import RoleAttributes
    try:
        msg = RoleAttributes()
        msg.ParseFromString(roleattr_rawdata)
        assert (node_name == msg.node_name)
    except:
        print("RoleAttributes ParseFromString failed. size is ",
              len(roleattr_rawdata))
        return
    print("nodename\t%s" % msg.node_name)
    print("processid\t%d" % msg.process_id)
    print("hostname\t%s" % msg.host_name)

    print("[Reading Channels]:")
    reader_channels = sorted(cyber.NodeUtils.get_readersofnode(node_name, 0))
    for channel in reader_channels:
        print(channel)
    print("")

    print("[Writing Channels]:")
    writer_channels = sorted(cyber.NodeUtils.get_writersofnode(node_name, 0))
    for channel in writer_channels:
        print(channel)
    print("")
Ejemplo n.º 2
0
def print_role(rolsattr_rawdata):
    from google.protobuf.message import DecodeError
    from cyber.proto.role_attributes_pb2 import RoleAttributes
    try:
        msg = RoleAttributes()
        msg.ParseFromString(rolsattr_rawdata)
    except DecodeError:
        print("RoleAttributes ParseFromString failed. size is ", len(rolsattr_rawdata))
        return
    print("\troleid\t\t", msg.id)
    print("\thostname\t", msg.host_name)
    print("\tprocessid\t", msg.process_id)
    print("\tnodename\t", msg.node_name)
    print("\tmsgtype\t\t", msg.message_type)
Ejemplo n.º 3
0
def print_service_info(service_name, sleep_s=2):
    roleattr_rawdata = cyber.ServiceUtils.get_service_attr(
        service_name, sleep_s)
    from cyber.proto.role_attributes_pb2 import RoleAttributes
    try:
        msg = RoleAttributes()
        msg.ParseFromString(roleattr_rawdata)
        assert (service_name == msg.service_name)
    except:
        print("RoleAttributes ParseFromString failed. size is ",
              len(roleattr_rawdata), ", service name: ", service_name)
        return
    print(msg.service_name)
    print("\tprocessid\t", msg.process_id)
    print("\tnodename\t", msg.node_name)
    print("\thostname\t", msg.host_name)
    print("")
Ejemplo n.º 4
0
def print_node_info(node_name, sleep_s=2):
    raw_data = cyber.NodeUtils.get_node_attr(node_name, sleep_s)
    try:
        msg = RoleAttributes()
        msg.ParseFromString(raw_data)
        assert (node_name == msg.node_name)
    except:
        print("RoleAttributes ParseFromString failed. size is ", len(raw_data))
        return
    print("Node:    \t%s" % msg.node_name)
    print("ProcessId: \t%d" % msg.process_id)
    print("Hostname:\t%s" % msg.host_name)

    print("[Reading Channels]:")
    reading_channels = sorted(cyber.NodeUtils.get_readersofnode(node_name, 0))
    for channel in reading_channels:
        print(channel)
    print("")

    print("[Writing Channels]:")
    writing_channels = sorted(cyber.NodeUtils.get_writersofnode(node_name, 0))
    for channel in writing_channels:
        print(channel)
    print("")