Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FQDNLookup failure could provide more information for diagnosing #4209

Open
flyn-org opened this issue Dec 21, 2023 · 1 comment
Open

FQDNLookup failure could provide more information for diagnosing #4209

flyn-org opened this issue Dec 21, 2023 · 1 comment

Comments

@flyn-org
Copy link

  • Version of collectd: 5.12.0
  • Operating system / distribution: Alpine
  • Kernel version (if applicable): N/a

Under some circumstances, collectd fails with the following error:

Looking up "[HOSTNAME]" failed. You have set the "FQDNLookup" option, but I cannot resolve my hostname to a fully qualified domain name. Please fix the network configuration.

This error message could be improved by the user of gai_strerror or, if the return code is EAI_SYSTEM, perror. As it stands the error message provides only limited information about what caused the error. This makes it a little more difficult to diagnose.

The relevant code is in src/daemon/collectd.c:

  char hostname[hostname_len];

  if (gethostname(hostname, hostname_len) != 0) {
    fprintf(stderr, "`gethostname' failed and no "
                    "hostname was configured.\n");
    return -1;
  }

  hostname_set(hostname);

  str = global_option_get("FQDNLookup");
  if (IS_FALSE(str))
    return 0;

  struct addrinfo *ai_list;
  struct addrinfo ai_hints = {.ai_flags = AI_CANONNAME};

  int status = getaddrinfo(hostname, NULL, &ai_hints, &ai_list);
  if (status != 0) {
    ERROR("Looking up \"%s\" failed. You have set the "
          "\"FQDNLookup\" option, but I cannot resolve "
          "my hostname to a fully qualified domain "
          "name. Please fix the network "
          "configuration.",
          hostname);
    return -1;
  }
@flyn-org
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants