- OS
- OS Version
- OS Architecture
- Computer Name
- Device Type (server or workstation, probably based on OS)
- RAM
- CPU
- HD Sizes
- Model
- Manufacturer
- Public IPv4
- Private IPv4
- Gateway
- DNS
- Subnet Mask
- Last Seen
- Last Logged In User
- Last Reboot Time
- System Uptime
// go-psutil
host.Info()
// Mac
{
"hostname": "macbook-pro-2.lan", // Computer Name
"uptime": 342925, // System Uptime
"bootTime": 1585842869, // Last Reboot Time
"procs": 526,
"os": "darwin", // OS
"platform": "darwin",
"platformFamily": "Standalone Workstation", // Device Type
"platformVersion": "10.15.3", // OS Version
"kernelVersion": "19.3.0",
"kernelArch": "x86_64",
"virtualizationSystem": "",
"virtualizationRole": "",
"hostid": "a8dde75c-cd97-3c37-b35d-1070cc50d2ce"
}
// Windows
{
"hostname": "DESKTOP-KIKDP63", // Computer Name
"uptime": 2050723, // System Uptime
"bootTime": 1584135243, // Last Reboot Time
"procs": 168,
"os": "windows", // OS
"platform": "Microsoft Windows 10 Pro", // OS
"platformFamily": "Standalone Workstation", // Device Type
"platformVersion": "10.0.18362 Build 18362", // OS Version
"kernelVersion": "",
"kernelArch": "x86_64",
"virtualizationSystem": "",
"virtualizationRole": "",
"hostid": "e0507b2b-eb3e-47cd-82ca-91f317241216"
}
// Ubuntu
{
"hostname":"level-virtual-machine", // Computer Name
"uptime":10211, // System Uptime
"bootTime":1586194787, // Last Reboot Time
"procs":342,
"os":"linux", // OS
"platform":"ubuntu", // OS
"platformFamily":"debian",
"platformVersion":"18.04", // OS Version
"kernelVersion":"5.3.0-46-generic",
"kernelArch":"x86_64",
"virtualizationSystem":"",
"virtualizationRole":"",
"hostid":"f15a4a13-80a7-4540-a24e-0ad5a71ee5b4"
}
// stdlib
runtime.GOARCH
amd64
// go-psutil
mem.VirtualMemory()
{
"total": 34359738368, // RAM
"available": 18029178880,
"used": 16330559488,
"usedPercent": 47.528183460235596,
"free": 10042241024,
"active": 10496745472,
"inactive": 7986937856,
"wired": 3364196352,
}
// go-psutil
cpu.Info()
[{
“cpu”:0,
"vendorId":"GenuineIntel",
"family":"6",
"model":"158",
"stepping":10,
"physicalId":"",
"coreId":"",
"cores":6,
"modelName":"Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz",
"mhz":2600,
"cacheSize":256,
“flags”:[*],
"microcode":""
}]
// go-psutil (works on windows too)
disk.Usage("/")
{
"path": "/",
"fstype": "",
"total": 53009707008, // HD Size
"free": 24934088704,
"used": 28075618304,
"usedPercent": 52.96316446299721,
"inodesTotal": 0,
"inodesUsed": 0,
"inodesFree": 0,
"inodesUsedPercent": 0
}
// https://github.com/rdegges/go-ipify/blob/master/ipify.go
or
// remote.request_ip on Rails API
or
// https://ipv6.encryption.io/json
// https://ipv4.encryption.io/json
// stdlib
ifaces, _ := net.Interfaces()
for _, i := range ifaces {
addrs, _ := i.Addrs()
for _, a := range addrs {
fmt.Println(a)
}
}
192.168.86.234/24
172.16.42.40/32
// github.com/jackpal/gateway
gateway.DiscoverGateway()
192.168.86.1 <nil>
??? Can’t figure this one out yet
I think this would be a timestamp of the last time the computer was online. Calculated by API.
// stdlib
user, _ := user.Current()
fmt.Println(user.Username)
forbes
// windows only cli command
c:\>wmic csproduct get vendor, version
Vendor Version
LENOVO ThinkPad T410
- https://github.com/shirou/gopsutil
- Disk Usage info like
df -h
for Golang · GitHub - go - Detect operating system version - Stack Overflow
- How to get computer make and model
- GitHub - jackpal/gateway: A library for discovering the address of a LAN gateway.
- GitHub - jaypipes/ghw: Golang hardware discovery/inspection library
IP Lookup: If we are going to use ipify, I'd rather self-host it. Otherwise, if we are looking for a service, I'd rather pay for IPStack. (
https://api.ipstack.com/check?access_key=YOUR_ACCESS_KEY
) IPStack is used by AirBNB, HubSpot, and Microsoft. The one I have on Encryption is echoip. (https://github.com/mpolden/echoip) If you like that one, I will deploy it on AWS for Level.DNS: We can skip this one and do later.
Overall, looks great!