Ejemplo n.º 1
0
    def __init__(self):
        auklet_config = settings.AUKLET_CONFIG
        self.apikey = auklet_config.get("api_key", None)
        self.app_id = auklet_config.get("application", None)
        self.release = auklet_config.get("release", None)
        self.version = auklet_config.get("version", None)
        self.org_id = auklet_config.get("organization", None)
        self.broker_url = auklet_config.get("broker", "mq.feeds.auklet.io")
        self.port = auklet_config.get("port", 8883)
        self.base_url = auklet_config.get("base_url", "https://api.auklet.io/")

        if self.apikey is None:
            raise AukletConfigurationError(
                "Please set api_key in AUKLET_CONFIG settings")
        if self.app_id is None:
            raise AukletConfigurationError(
                "Please set application in AUKLET_CONFIG settings")
        if self.org_id is None:
            raise AukletConfigurationError(
                "Please set organization in AUKLET_CONFIG settings")
        self.auklet_dir = create_dir()
        self.mac_hash = get_mac()
        self.device_ip = get_device_ip()
        self.agent_version = get_agent_version()
        self.broker = MQTTClient(self.broker_url, self.port, self.app_id,
                                 self.org_id, self.apikey, self.base_url,
                                 self.auklet_dir)
        self.broker._get_certs()
        self.file_cache = FilenameCaches()
Ejemplo n.º 2
0
 def build_event_data(self, type, traceback):
     event = Event(type, traceback, self.file_cache)
     event_dict = dict(event)
     event_dict['application'] = self.app_id
     event_dict['publicIP'] = get_device_ip()
     event_dict['id'] = str(uuid4())
     event_dict['timestamp'] = int(round(time() * 1000))
     event_dict['systemMetrics'] = dict(SystemMetrics())
     event_dict['macAddressHash'] = self.mac_hash
     event_dict['release'] = self.release
     event_dict['version'] = self.version
     event_dict['agentVersion'] = get_agent_version()
     event_dict['device'] = None
     return event_dict
Ejemplo n.º 3
0
 def build_event_data(self, type, traceback, tree):
     event = Event(type, traceback, tree, self.abs_path)
     event_dict = dict(event)
     event_dict['application'] = self.app_id
     event_dict['publicIP'] = get_device_ip()
     event_dict['id'] = str(uuid4())
     event_dict['timestamp'] = int(round(time() * 1000))
     event_dict['systemMetrics'] = dict(self.system_metrics)
     event_dict['macAddressHash'] = self.mac_hash
     event_dict['commitHash'] = self.commit_hash
     event_dict['agentVersion'] = get_agent_version()
     event_dict['device'] = self.broker_username
     event_dict['absPath'] = self.abs_path
     return event_dict
Ejemplo n.º 4
0
 def build_stack_data(self, stack, total_time, total_calls):
     return {
         "application": client.app_id,
         "publicIP": get_device_ip(),
         "id": str(uuid4()),
         "timestamp": int(round(time() * 1000)),
         "macAddressHash": self.mac_hash,
         "release": self.release,
         "agentVersion": get_agent_version(),
         "tree": stack.__dict__(),
         "totalTime": total_time,
         "totalCalls": total_calls,
         "device": None,
         "version": client.version
     }
Ejemplo n.º 5
0
 def build_tree(self, client):
     if self.root_func is not None:
         return {
             "application": client.app_id,
             "publicIP": self.public_ip,
             "id": str(uuid4()),
             "timestamp": int(round(time() * 1000)),
             "macAddressHash": self.mac_hash,
             "commitHash": self.commit_hash,
             "agentVersion": get_agent_version(),
             "tree": dict(self.root_func),
             "device": client.broker_username,
             "absPath": client.abs_path
         }
     return {}
Ejemplo n.º 6
0
def build_event_data(client, type, tb, tree):
    event = Event(type, tb, tree, client.abs_path)
    event_dict = dict(event)
    event_dict['application'] = client.app_id
    event_dict['publicIP'] = get_device_ip()
    event_dict['id'] = str(uuid4())
    event_dict['timestamp'] = int(round(time() * 1000))
    event_dict['systemMetrics'] = dict(client.system_metrics)
    event_dict['macAddressHash'] = client.mac_hash
    event_dict['release'] = client.commit_hash
    event_dict['agentVersion'] = get_agent_version()
    event_dict['device'] = client.broker_username
    event_dict['absPath'] = client.abs_path
    event_dict['version'] = client.version
    return event_dict
Ejemplo n.º 7
0
 def build_log_data(self, msg, data_type, level):
     log_dict = {
         "message": msg,
         "type": data_type,
         "level": level,
         "application": self.app_id,
         "publicIP": get_device_ip(),
         "id": str(uuid4()),
         "timestamp": int(round(time() * 1000)),
         "systemMetrics": dict(self.system_metrics),
         "macAddressHash": self.mac_hash,
         "commitHash": self.commit_hash,
         "agentVersion": get_agent_version(),
         "device": self.broker_username
     }
     return log_dict
Ejemplo n.º 8
0
def build_send_data(client, msg, data_type):
    send_dict = {
        "payload": {
            "value": msg
        },
        "application": client.app_id,
        "publicIP": get_device_ip(),
        "id": str(uuid4()),
        "timestamp": int(round(time() * 1000)),
        "macAddressHash": client.mac_hash,
        "release": client.commit_hash,
        "agentVersion": get_agent_version(),
        "device": client.broker_username,
        "version": client.version,
        "type": data_type
    }
    return send_dict