git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/sysinfo/chassis.go (about) 1 // Copyright © 2016 Zlatko Čalušić 2 // 3 // Use of this source code is governed by an MIT-style license that can be found in the LICENSE file. 4 5 package sysinfo 6 7 import "strconv" 8 9 // Chassis information. 10 type Chassis struct { 11 Type uint `json:"type,omitempty"` 12 Vendor string `json:"vendor,omitempty"` 13 Version string `json:"version,omitempty"` 14 Serial string `json:"serial,omitempty"` 15 AssetTag string `json:"assettag,omitempty"` 16 } 17 18 func (si *SysInfo) getChassisInfo() { 19 if chtype, err := strconv.ParseUint(slurpFile("/sys/class/dmi/id/chassis_type"), 10, 64); err == nil { 20 si.Chassis.Type = uint(chtype) 21 } 22 si.Chassis.Vendor = slurpFile("/sys/class/dmi/id/chassis_vendor") 23 si.Chassis.Version = slurpFile("/sys/class/dmi/id/chassis_version") 24 si.Chassis.Serial = slurpFile("/sys/class/dmi/id/chassis_serial") 25 si.Chassis.AssetTag = slurpFile("/sys/class/dmi/id/chassis_asset_tag") 26 }