summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: da920bb)
raw | patch | inline | side by side (parent: da920bb)
author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 25 Dec 2015 10:10:16 +0000 (11:10 +0100) | ||
committer | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Thu, 4 Aug 2016 09:22:40 +0000 (11:22 +0200) |
src/uuid.c | patch | blob | history |
diff --git a/src/uuid.c b/src/uuid.c
index e837ca725db74274d4b12868f102a8c4ade6a1d5..9e9a7a33ba6491f4b574d418eaeb9415909f3912 100644 (file)
--- a/src/uuid.c
+++ b/src/uuid.c
/**
* collectd - src/uuid.c
* Copyright (C) 2007 Red Hat Inc.
+ * Copyright (C) 2015 Ruben Kerkhof
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
#include "configfile.h"
#include "plugin.h"
+#if HAVE_SYS_SYSCTL_H
+#include <sys/sysctl.h>
+#endif
+
#if HAVE_LIBHAL_H
#include <libhal.h>
#endif
return (uuid);
}
+#if defined(__APPLE__)
+static char *
+uuid_get_from_sysctlbyname(const char *name)
+{
+ char uuid[UUID_PRINTABLE_NORMAL_LENGTH + 1];
+ size_t len = sizeof (uuid);
+ if (sysctlbyname(name, &uuid, &len, NULL, 0) == -1)
+ return NULL;
+ return (strdup (uuid));
+}
+#endif
+
#if HAVE_LIBHAL_H
#define UUID_PATH "/org/freedesktop/Hal/devices/computer"
if ((uuid = uuid_get_from_file(uuidfile ? uuidfile : "/etc/uuid")) != NULL)
return (uuid);
+#if defined(__APPLE__)
+ if ((uuid = uuid_get_from_sysctlbyname("kern.uuid")) != NULL)
+ return (uuid);
+#endif
#if defined(__linux__)
if ((uuid = uuid_get_from_file("/sys/class/dmi/id/product_uuid")) != NULL)
return (uuid);