def run_health_check():
    global CONFIG, binaryDownload
    logging.info("Health check requested by server!")
    logging.info("Retrieving health check settings...")
    query = copy_and_set_token(dict_getHealthCheck, CONFIG.get_value('token'))
    req = JsonRequest(query)
    ans = req.execute()
    if ans is None:
        logging.error("Failed to get health check!")
        sleep(5)
        return
    elif ans['response'] != 'SUCCESS':
        logging.error("Error on getting health check: " + str(ans))
        sleep(5)
        return
    binaryDownload.check_version(ans['crackerBinaryId'])
    check_id = ans['checkId']
    logging.info("Starting check ID " + str(check_id))

    # write hashes to file
    hash_file = open("hashlists/health_check.txt", "w")
    hash_file.write("\n".join(ans['hashes']))
    hash_file.close()

    # delete old file if necessary
    if os.path.exists("hashlists/health_check.out"):
        os.unlink("hashlists/health_check.out")

    # run task
    cracker = HashcatCracker(ans['crackerBinaryId'], binaryDownload)
    start = int(time.time())
    [states, errors] = cracker.run_health_check(ans['attack'],
                                                ans['hashlistAlias'])
    end = int(time.time())

    # read results
    if os.path.exists("hashlists/health_check.out"):
        founds = file_get_contents("hashlists/health_check.out").replace(
            "\r\n", "\n").split("\n")
    else:
        founds = []
    num_gpus = len(states[0].get_temps())
    query = copy_and_set_token(dict_sendHealthCheck, CONFIG.get_value('token'))
    query['checkId'] = check_id
    query['start'] = start
    query['end'] = end
    query['numGpus'] = num_gpus
    query['numCracked'] = len(founds) - 1
    query['errors'] = errors
    req = JsonRequest(query)
    ans = req.execute()
    if ans is None:
        logging.error("Failed to send health check results!")
        sleep(5)
        return
    elif ans['response'] != 'OK':
        logging.error("Error on sending health check results: " + str(ans))
        sleep(5)
        return
    logging.info("Health check completed successfully!")
            print(Initialize.get_version())
        sys.exit(0)

    if args.de_register:
        init_logging(args)
        session = Session(requests.Session()).s
        session.headers.update({'User-Agent': Initialize.get_version()})
        de_register()
        sys.exit(0)

    try:
        init_logging(args)

        # check if there is a lock file and check if this pid is still running hashtopolis
        if os.path.exists("lock.pid") and os.path.isfile("lock.pid"):
            pid = file_get_contents("lock.pid")
            logging.info(
                "Found existing lock.pid, checking if python process is running..."
            )
            if psutil.pid_exists(int(pid)):
                try:
                    command = psutil.Process(int(pid)).cmdline()[0].replace(
                        '\\', '/').split('/')
                    print(command)
                    if str.startswith(command[-1], "python"):
                        logging.fatal(
                            "There is already a hashtopolis agent running in this directory!"
                        )
                        sys.exit(-1)
                except Exception:
                    # if we fail to determine the cmd line we assume that it's either not running anymore or another process (non-hashtopolis)