Closed minhajakhterkhan199 closed 6 years ago
What kind of HardwareID or Serial Number? CPU, disk, and so on. Or https://stackoverflow.com/ might be more useful site.
which function I could use to get below UUID... In addition, how to get Serial / Mac address of device?? minhaj@minhaj-VirtualBox:~$ sudo dmidecode | grep -i uuid [sudo] password for minhaj: UUID: 075447D9-25EA-4B07-BFDB-4EBC42C7CB7C
Waiting for your response
@shirou Waiting for your response
@shirou Still waiting for your response
just search this repo for uuid which will lead you to
https://github.com/shirou/gopsutil/search?utf8=%E2%9C%93&q=uuid&type=
which points you to HostID ... below makes that call and shows you the UUID
package main
import (
"fmt"
"github.com/shirou/gopsutil/host"
)
func show_uuid() {
hostStat, err := host.Info()
if err != nil {
panic(err)
}
fmt.Println("uuid ", hostStat.HostID)
}
func main() {
show_uuid()
}
Dear,
hostStat.HostID is not returning UUID... hostStat.HostID is returning below
uuid 001c12ff-e764-4367-be87-c186dcb080b9
But we requires, UUID: 075447D9-25EA-4B07-BFDB-4EBC42C7CB7C
sudo dmidecode | grep -i uuid
Manufacturer: innotek GmbH
Product Name: VirtualBox
Version: 1.2
Serial Number: 0
UUID: 075447D9-25EA-4B07-BFDB-4EBC42C7CB7C
Wake-up Type: Power Switch
SKU Number: Not Specified
Family: Virtual Machine
Please advise
The original python psutil lib does not seem to include information from the BIOS. @shirou may find it outside of this lib scope to implement new functions for that.
Why don't you just call dmidecode -s system-uuid
from Go with os/exec if you want this exact information?
Regarding https://github.com/shirou/gopsutil/issues/425#issuecomment-331441872 and how to get MAC addresses, this is as simple as the following (via golang-nuts):
package main
import (
"fmt"
"net"
)
func main() {
interfaces, _ := net.Interfaces()
for _, inter := range interfaces {
fmt.Println(inter.Name, inter.HardwareAddr)
}
}
Closing: outside of gopsutil scope, no feedback from issue opener in months.
Please advise which method I can use to get HardwareID or Serial Number in linux (Ubuntu & RaspberryPi)