def main():
    arguments = docopt(__doc__)
    config_file = '/etc/anycast-healthchecker.conf'
    config_dir = '/etc/anycast-healthchecker.d'
    config = configparser.ConfigParser()
    config_files = [config_file]
    config_files.extend(glob.glob(os.path.join(config_dir, '*.conf')))
    config.read(config_files)
    try:
        pid = get_processid(config)
    except ValueError as exc:
        print("UNKNOWN: {e}".format(e=exc))
        sys.exit(3)
    else:
        process_up = running(pid)
    if not process_up:
        print("CRITICAL: anycast-healthchecker with pid ({p}) isn't running"
              .format(p=pid))
        sys.exit(3)
    services = config.sections()
    services.remove('daemon')
    if not services:
        print("UNKNOWN: No service checks are configured")
        sys.exit(3)
    enabled_service_checks = parse_services(config, services)
    if enabled_service_checks == 0:
        print("OK: Number of service checks is zero, no threads are running")
        sys.exit(0)
    else:
        configured_threads = enabled_service_checks + 1
    cmd = ['/bin/ps', 'h', '-T', '-p', '{n}'.format(n=pid)]
    try:
        if arguments['-v']:
            print("running {}".format(' '.join(cmd)))
        out = subprocess.check_output(cmd, timeout=1)
    except subprocess.CalledProcessError as exc:
        print("UNKNOWN: running '{c}' failed with return code: {r}"
              .format(c=' '.join(cmd), r=exc.returncode))
        sys.exit(3)
    except subprocess.TimeoutExpired:
        print("UNKNOWN: running '{}' timed out".format(' '.join(cmd)))
        sys.exit(3)
    else:
        output_lines = out.splitlines()
        if arguments['-v']:
            for line in output_lines:
                print(line)
        running_threads = len(output_lines)
        if running_threads == configured_threads:
            print("OK: UP (pid={p}) and all threads ({t}) are running"
                  .format(p=pid, t=configured_threads - 1))
            sys.exit(0)
        elif running_threads - 1 == 0:
            print("CRITICAL: No threads are running OpDocs ANYCAST-03")
            sys.exit(2)
        else:
            print("CRITICAL: Found {n} running threads while configured "
                  "number of threads is {c} OpDocs ANYCAST-03"
                  .format(n=running_threads - 1, c=configured_threads - 1))
            sys.exit(2)