X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fuuid.c;h=8bae376103f0328ec9fb20763ee70c668217e928;hb=fa82af13503a1195e1bfaef597ac33a3dc71a758;hp=816e624a0cb29ef1ace6e61925a513d0bbde9f3d;hpb=58c91485b9b28a866715fc013d23236470699940;p=collectd.git diff --git a/src/uuid.c b/src/uuid.c index 816e624a..8bae3761 100644 --- a/src/uuid.c +++ b/src/uuid.c @@ -27,7 +27,6 @@ #include "collectd.h" #include "common.h" -#include "configfile.h" #include "plugin.h" #if HAVE_SYS_SYSCTL_H @@ -114,7 +113,7 @@ uuid_get_from_dmidecode(void) return (uuid); } -#if defined(__APPLE__) || defined(__FreeBSD__) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) static char * uuid_get_from_sysctlbyname(const char *name) { @@ -124,6 +123,21 @@ uuid_get_from_sysctlbyname(const char *name) return NULL; return (strdup (uuid)); } +#elif defined(__OpenBSD__) +static char * +uuid_get_from_sysctl(void) +{ + char uuid[UUID_PRINTABLE_NORMAL_LENGTH + 1]; + size_t len = sizeof (uuid); + int mib[2]; + + mib[0] = CTL_HW; + mib[1] = HW_UUID; + + if (sysctl(mib, 2, uuid, &len, NULL, 0) == -1) + return NULL; + return (strdup (uuid)); +} #endif #if HAVE_LIBHAL_H @@ -215,6 +229,12 @@ uuid_get_local(void) #elif defined(__FreeBSD__) if ((uuid = uuid_get_from_sysctlbyname("kern.hostuuid")) != NULL) return (uuid); +#elif defined(__NetBSD__) + if ((uuid = uuid_get_from_sysctlbyname("machdep.dmi.system-uuid")) != NULL) + return (uuid); +#elif defined(__OpenBSD__) + if ((uuid = uuid_get_from_sysctl()) != NULL) + return (uuid); #elif defined(__linux__) if ((uuid = uuid_get_from_file("/sys/class/dmi/id/product_uuid")) != NULL) return (uuid);