introduce basic fact collection
This commit is contained in:
33
client/vendor/github.com/zcalusic/sysinfo/kernel_linux.go
generated
vendored
Normal file
33
client/vendor/github.com/zcalusic/sysinfo/kernel_linux.go
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// 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.
|
||||
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package sysinfo
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// Kernel information.
|
||||
type Kernel struct {
|
||||
Release string `json:"release,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
Architecture string `json:"architecture,omitempty"`
|
||||
}
|
||||
|
||||
func (si *SysInfo) getKernelInfo() {
|
||||
si.Kernel.Release = slurpFile("/proc/sys/kernel/osrelease")
|
||||
si.Kernel.Version = slurpFile("/proc/sys/kernel/version")
|
||||
|
||||
var uname syscall.Utsname
|
||||
if err := syscall.Uname(&uname); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
si.Kernel.Architecture = strings.TrimRight(string((*[65]byte)(unsafe.Pointer(&uname.Machine))[:]), "\000")
|
||||
}
|
||||
Reference in New Issue
Block a user