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