2

I need to register for monitoring purposes Linux servers running on real hardware as well as on virtual machines, AWS, Azure,.. by sending their unique id. I figured out that id given by

sudo dmidecode | grep UUID

is the best choice because its result is different even if you have cloned virtual machine without reinitialization of MAC address.

But dmidecode is not installed everywhere. So I'm trying to understand does file /sys/devices/virtual/dmi/id/product_uuid always contains the same UUID as given by dmidecode?

Syb3rian
  • 171
  • 2
  • 14
  • 1
    It looks like `/sys/class/dmi/id/product_uuid` also contains UUID (the same on my machine), I don't know how it differs from `/sys/devices/virtual/dmi/id/product_uuid`... – Emilien Jun 15 '16 at 08:35
  • `/sys/class/dmi/id` is a symbolic link to `../../devices/virtual/dmi/id` At least in my system. – Syb3rian Jun 16 '16 at 21:35

1 Answers1

1

dmidecode | grep UUID and /sys/devices/virtual/dmi/id/product_uuidshould be equal but depending on your system the output can be different.

From dmidecode source code:

/*
 * As of version 2.6 of the SMBIOS specification, the first 3
 * fields of the UUID are supposed to be encoded on little-endian.
 * The specification says that this is the defacto standard,
 * however I've seen systems following RFC 4122 instead and use
 * network byte order, so I am reluctant to apply the byte-swapping
 * for older versions.
 */

See also: [PATCH] dmi, Use little-endian for sysfs PRODUCT UUID

I notice that Ansible also try /sys first and fall back to dmidecode executable to collect dmi related facts.

molivier
  • 2,146
  • 1
  • 18
  • 20