f-39: host: faits et état de l'hôte lus depuis /proc et /etc #39
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
c34915e3e2
commit
080ce82d0d
12 changed files with 730 additions and 0 deletions
225
internal/host/host.go
Normal file
225
internal/host/host.go
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
package host
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type CPU struct {
|
||||
Vendor string
|
||||
Model string
|
||||
Sockets int
|
||||
Cores int
|
||||
Threads int
|
||||
}
|
||||
|
||||
type OS struct {
|
||||
ID string
|
||||
VersionID string
|
||||
PrettyName string
|
||||
}
|
||||
|
||||
type Facts struct {
|
||||
Hostname string
|
||||
CPU CPU
|
||||
MemoryBytes uint64
|
||||
OS OS
|
||||
Kernel string
|
||||
}
|
||||
|
||||
type State struct {
|
||||
BootTime int64
|
||||
UptimeSeconds float64
|
||||
Load [3]float64
|
||||
}
|
||||
|
||||
func ReadFacts(fsys fs.FS) (Facts, error) {
|
||||
var f Facts
|
||||
var err error
|
||||
if f.Hostname, err = readLine(fsys, "proc/sys/kernel/hostname"); err != nil {
|
||||
return Facts{}, err
|
||||
}
|
||||
if f.Kernel, err = readLine(fsys, "proc/sys/kernel/osrelease"); err != nil {
|
||||
return Facts{}, err
|
||||
}
|
||||
data, err := fs.ReadFile(fsys, "proc/cpuinfo")
|
||||
if err != nil {
|
||||
return Facts{}, err
|
||||
}
|
||||
if f.CPU, err = parseCPUInfo(string(data)); err != nil {
|
||||
return Facts{}, err
|
||||
}
|
||||
data, err = fs.ReadFile(fsys, "proc/meminfo")
|
||||
if err != nil {
|
||||
return Facts{}, err
|
||||
}
|
||||
if f.MemoryBytes, err = parseMemTotal(string(data)); err != nil {
|
||||
return Facts{}, err
|
||||
}
|
||||
data, err = fs.ReadFile(fsys, "etc/os-release")
|
||||
if err != nil {
|
||||
return Facts{}, err
|
||||
}
|
||||
f.OS = parseOSRelease(string(data))
|
||||
return f, nil
|
||||
}
|
||||
|
||||
func ReadState(fsys fs.FS) (State, error) {
|
||||
var s State
|
||||
data, err := fs.ReadFile(fsys, "proc/stat")
|
||||
if err != nil {
|
||||
return State{}, err
|
||||
}
|
||||
if s.BootTime, err = parseBootTime(string(data)); err != nil {
|
||||
return State{}, err
|
||||
}
|
||||
line, err := readLine(fsys, "proc/uptime")
|
||||
if err != nil {
|
||||
return State{}, err
|
||||
}
|
||||
if s.UptimeSeconds, err = parseUptime(line); err != nil {
|
||||
return State{}, err
|
||||
}
|
||||
if line, err = readLine(fsys, "proc/loadavg"); err != nil {
|
||||
return State{}, err
|
||||
}
|
||||
if s.Load, err = parseLoadAvg(line); err != nil {
|
||||
return State{}, err
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func readLine(fsys fs.FS, name string) (string, error) {
|
||||
data, err := fs.ReadFile(fsys, name)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
line := strings.TrimSpace(string(data))
|
||||
if line == "" {
|
||||
return "", fmt.Errorf("%s: empty", name)
|
||||
}
|
||||
return line, nil
|
||||
}
|
||||
|
||||
func parseCPUInfo(data string) (CPU, error) {
|
||||
var cpu CPU
|
||||
sockets := map[string]bool{}
|
||||
cores := map[string]bool{}
|
||||
var physical string
|
||||
scanner := bufio.NewScanner(strings.NewReader(data))
|
||||
for scanner.Scan() {
|
||||
key, value, ok := strings.Cut(scanner.Text(), ":")
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
value = strings.TrimSpace(value)
|
||||
switch strings.TrimSpace(key) {
|
||||
case "processor":
|
||||
cpu.Threads++
|
||||
physical = ""
|
||||
case "vendor_id":
|
||||
cpu.Vendor = value
|
||||
case "model name":
|
||||
cpu.Model = value
|
||||
case "physical id":
|
||||
physical = value
|
||||
sockets[value] = true
|
||||
case "core id":
|
||||
if physical == "" {
|
||||
return CPU{}, fmt.Errorf("cpuinfo: core id %s without physical id", value)
|
||||
}
|
||||
cores[physical+"/"+value] = true
|
||||
}
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
return CPU{}, fmt.Errorf("cpuinfo: %w", err)
|
||||
}
|
||||
if cpu.Threads == 0 || len(sockets) == 0 || len(cores) == 0 {
|
||||
return CPU{}, fmt.Errorf("cpuinfo: %d processors, %d physical ids, %d core ids", cpu.Threads, len(sockets), len(cores))
|
||||
}
|
||||
cpu.Sockets = len(sockets)
|
||||
cpu.Cores = len(cores)
|
||||
return cpu, nil
|
||||
}
|
||||
|
||||
func parseMemTotal(data string) (uint64, error) {
|
||||
for _, line := range strings.Split(data, "\n") {
|
||||
fields := strings.Fields(line)
|
||||
if len(fields) != 3 || fields[0] != "MemTotal:" || fields[2] != "kB" {
|
||||
continue
|
||||
}
|
||||
kb, err := strconv.ParseUint(fields[1], 10, 64)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("meminfo: MemTotal: %w", err)
|
||||
}
|
||||
return kb * 1024, nil
|
||||
}
|
||||
return 0, fmt.Errorf("meminfo: no MemTotal in kB")
|
||||
}
|
||||
|
||||
func parseOSRelease(data string) OS {
|
||||
var rel OS
|
||||
for _, line := range strings.Split(data, "\n") {
|
||||
key, value, ok := strings.Cut(strings.TrimSpace(line), "=")
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if unquoted, err := strconv.Unquote(value); err == nil {
|
||||
value = unquoted
|
||||
}
|
||||
switch key {
|
||||
case "ID":
|
||||
rel.ID = value
|
||||
case "VERSION_ID":
|
||||
rel.VersionID = value
|
||||
case "PRETTY_NAME":
|
||||
rel.PrettyName = value
|
||||
}
|
||||
}
|
||||
return rel
|
||||
}
|
||||
|
||||
func parseBootTime(data string) (int64, error) {
|
||||
for _, line := range strings.Split(data, "\n") {
|
||||
fields := strings.Fields(line)
|
||||
if len(fields) == 2 && fields[0] == "btime" {
|
||||
t, err := strconv.ParseInt(fields[1], 10, 64)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("stat: btime: %w", err)
|
||||
}
|
||||
return t, nil
|
||||
}
|
||||
}
|
||||
return 0, fmt.Errorf("stat: no btime")
|
||||
}
|
||||
|
||||
func parseUptime(line string) (float64, error) {
|
||||
fields := strings.Fields(line)
|
||||
if len(fields) != 2 {
|
||||
return 0, fmt.Errorf("uptime: %q", line)
|
||||
}
|
||||
up, err := strconv.ParseFloat(fields[0], 64)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("uptime: %w", err)
|
||||
}
|
||||
return up, nil
|
||||
}
|
||||
|
||||
func parseLoadAvg(line string) ([3]float64, error) {
|
||||
var load [3]float64
|
||||
fields := strings.Fields(line)
|
||||
if len(fields) != 5 {
|
||||
return load, fmt.Errorf("loadavg: %q", line)
|
||||
}
|
||||
for i := range load {
|
||||
v, err := strconv.ParseFloat(fields[i], 64)
|
||||
if err != nil {
|
||||
return load, fmt.Errorf("loadavg: %w", err)
|
||||
}
|
||||
load[i] = v
|
||||
}
|
||||
return load, nil
|
||||
}
|
||||
128
internal/host/host_test.go
Normal file
128
internal/host/host_test.go
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
package host
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"testing/fstest"
|
||||
)
|
||||
|
||||
func debian12() fstest.MapFS {
|
||||
fsys := fstest.MapFS{}
|
||||
for _, name := range []string{
|
||||
"proc/cpuinfo", "proc/meminfo", "proc/stat", "proc/uptime", "proc/loadavg",
|
||||
"proc/sys/kernel/osrelease", "proc/sys/kernel/hostname", "etc/os-release",
|
||||
} {
|
||||
data, err := os.ReadFile("testdata/debian12/" + name)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fsys[name] = &fstest.MapFile{Data: data}
|
||||
}
|
||||
return fsys
|
||||
}
|
||||
|
||||
func TestReadFacts_Debian12(t *testing.T) {
|
||||
got, err := ReadFacts(debian12())
|
||||
if err != nil {
|
||||
t.Fatalf("ReadFacts: %v", err)
|
||||
}
|
||||
want := Facts{
|
||||
Hostname: "hv1",
|
||||
CPU: CPU{Vendor: "AuthenticAMD", Model: "QEMU Virtual CPU version 2.5+", Sockets: 1, Cores: 2, Threads: 2},
|
||||
MemoryBytes: 2010432 * 1024,
|
||||
OS: OS{ID: "debian", VersionID: "12", PrettyName: "Debian GNU/Linux 12 (bookworm)"},
|
||||
Kernel: "6.8.0-50-generic",
|
||||
}
|
||||
if got != want {
|
||||
t.Errorf("faits %+v, %+v attendus", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadState_Debian12(t *testing.T) {
|
||||
got, err := ReadState(debian12())
|
||||
if err != nil {
|
||||
t.Fatalf("ReadState: %v", err)
|
||||
}
|
||||
want := State{BootTime: 1792210880, UptimeSeconds: 1243445.41, Load: [3]float64{0.08, 0.03, 0.04}}
|
||||
if got != want {
|
||||
t.Errorf("état %+v, %+v attendu", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseCPUInfo_SocketsCoresAndThreadsAreDistinct(t *testing.T) {
|
||||
data, err := os.ReadFile("testdata/cpuinfo-2x2x2")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, err := parseCPUInfo(string(data))
|
||||
if err != nil {
|
||||
t.Fatalf("parseCPUInfo: %v", err)
|
||||
}
|
||||
if got.Sockets != 2 || got.Cores != 4 || got.Threads != 8 {
|
||||
t.Errorf("%d sockets, %d cœurs, %d threads ; 2, 4 et 8 attendus", got.Sockets, got.Cores, got.Threads)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseCPUInfo_RefusesMissingTopology(t *testing.T) {
|
||||
data, err := os.ReadFile("testdata/debian12/proc/cpuinfo")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for label, input := range map[string]string{
|
||||
"vide": "",
|
||||
"sans physical id": strings.ReplaceAll(string(data), "physical id\t: 0\n", ""),
|
||||
"sans core id": strings.ReplaceAll(strings.ReplaceAll(string(data), "core id\t\t: 0\n", ""), "core id\t\t: 1\n", ""),
|
||||
} {
|
||||
if _, err := parseCPUInfo(input); err == nil {
|
||||
t.Errorf("%s : accepté", label)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadFacts_FailsOnAMissingFile(t *testing.T) {
|
||||
for _, name := range []string{"proc/cpuinfo", "proc/meminfo", "etc/os-release", "proc/sys/kernel/osrelease", "proc/sys/kernel/hostname"} {
|
||||
fsys := debian12()
|
||||
delete(fsys, name)
|
||||
if _, err := ReadFacts(fsys); err == nil || !strings.Contains(err.Error(), name) {
|
||||
t.Errorf("sans %s : erreur %v", name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadState_FailsOnAMissingFile(t *testing.T) {
|
||||
for _, name := range []string{"proc/stat", "proc/uptime", "proc/loadavg"} {
|
||||
fsys := debian12()
|
||||
delete(fsys, name)
|
||||
if _, err := ReadState(fsys); err == nil || !strings.Contains(err.Error(), name) {
|
||||
t.Errorf("sans %s : erreur %v", name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseOSRelease_Rocky10Quoted(t *testing.T) {
|
||||
data, err := os.ReadFile("testdata/rocky10/etc/os-release")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := parseOSRelease(string(data))
|
||||
want := OS{ID: "rocky", VersionID: "10.2", PrettyName: "Rocky Linux 10.2 (Red Quartz)"}
|
||||
if got != want {
|
||||
t.Errorf("%+v, %+v attendu", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParsers_RefuseMalformedInput(t *testing.T) {
|
||||
if _, err := parseMemTotal("MemFree: 12 kB\n"); err == nil {
|
||||
t.Error("meminfo sans MemTotal accepté")
|
||||
}
|
||||
if _, err := parseBootTime("cpu 1 2 3\n"); err == nil {
|
||||
t.Error("stat sans btime accepté")
|
||||
}
|
||||
if _, err := parseUptime("12.5"); err == nil {
|
||||
t.Error("uptime à un champ accepté")
|
||||
}
|
||||
if _, err := parseLoadAvg("0.1 0.2 x 1/2 3"); err == nil {
|
||||
t.Error("loadavg invalide accepté")
|
||||
}
|
||||
}
|
||||
224
internal/host/testdata/cpuinfo-2x2x2
vendored
Normal file
224
internal/host/testdata/cpuinfo-2x2x2
vendored
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
processor : 0
|
||||
vendor_id : AuthenticAMD
|
||||
cpu family : 15
|
||||
model : 107
|
||||
model name : QEMU Virtual CPU version 2.5+
|
||||
stepping : 1
|
||||
microcode : 0x1000065
|
||||
cpu MHz : 999.997
|
||||
cache size : 512 KB
|
||||
physical id : 0
|
||||
siblings : 4
|
||||
core id : 0
|
||||
cpu cores : 2
|
||||
apicid : 0
|
||||
initial apicid : 0
|
||||
fpu : yes
|
||||
fpu_exception : yes
|
||||
cpuid level : 13
|
||||
wp : yes
|
||||
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm rep_good nopl cpuid extd_apicid pni cx16 hypervisor lahf_lm cmp_legacy svm 3dnowprefetch vmmcall
|
||||
bugs : fxsave_leak sysret_ss_attrs null_seg swapgs_fence amd_e400 spectre_v1 spectre_v2
|
||||
bogomips : 1999.99
|
||||
TLB size : 1024 4K pages
|
||||
clflush size : 64
|
||||
cache_alignment : 64
|
||||
address sizes : 40 bits physical, 48 bits virtual
|
||||
power management:
|
||||
|
||||
processor : 1
|
||||
vendor_id : AuthenticAMD
|
||||
cpu family : 15
|
||||
model : 107
|
||||
model name : QEMU Virtual CPU version 2.5+
|
||||
stepping : 1
|
||||
microcode : 0x1000065
|
||||
cpu MHz : 999.997
|
||||
cache size : 512 KB
|
||||
physical id : 0
|
||||
siblings : 4
|
||||
core id : 1
|
||||
cpu cores : 2
|
||||
apicid : 0
|
||||
initial apicid : 0
|
||||
fpu : yes
|
||||
fpu_exception : yes
|
||||
cpuid level : 13
|
||||
wp : yes
|
||||
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm rep_good nopl cpuid extd_apicid pni cx16 hypervisor lahf_lm cmp_legacy svm 3dnowprefetch vmmcall
|
||||
bugs : fxsave_leak sysret_ss_attrs null_seg swapgs_fence amd_e400 spectre_v1 spectre_v2
|
||||
bogomips : 1999.99
|
||||
TLB size : 1024 4K pages
|
||||
clflush size : 64
|
||||
cache_alignment : 64
|
||||
address sizes : 40 bits physical, 48 bits virtual
|
||||
power management:
|
||||
|
||||
processor : 2
|
||||
vendor_id : AuthenticAMD
|
||||
cpu family : 15
|
||||
model : 107
|
||||
model name : QEMU Virtual CPU version 2.5+
|
||||
stepping : 1
|
||||
microcode : 0x1000065
|
||||
cpu MHz : 999.997
|
||||
cache size : 512 KB
|
||||
physical id : 1
|
||||
siblings : 4
|
||||
core id : 0
|
||||
cpu cores : 2
|
||||
apicid : 0
|
||||
initial apicid : 0
|
||||
fpu : yes
|
||||
fpu_exception : yes
|
||||
cpuid level : 13
|
||||
wp : yes
|
||||
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm rep_good nopl cpuid extd_apicid pni cx16 hypervisor lahf_lm cmp_legacy svm 3dnowprefetch vmmcall
|
||||
bugs : fxsave_leak sysret_ss_attrs null_seg swapgs_fence amd_e400 spectre_v1 spectre_v2
|
||||
bogomips : 1999.99
|
||||
TLB size : 1024 4K pages
|
||||
clflush size : 64
|
||||
cache_alignment : 64
|
||||
address sizes : 40 bits physical, 48 bits virtual
|
||||
power management:
|
||||
|
||||
processor : 3
|
||||
vendor_id : AuthenticAMD
|
||||
cpu family : 15
|
||||
model : 107
|
||||
model name : QEMU Virtual CPU version 2.5+
|
||||
stepping : 1
|
||||
microcode : 0x1000065
|
||||
cpu MHz : 999.997
|
||||
cache size : 512 KB
|
||||
physical id : 1
|
||||
siblings : 4
|
||||
core id : 1
|
||||
cpu cores : 2
|
||||
apicid : 0
|
||||
initial apicid : 0
|
||||
fpu : yes
|
||||
fpu_exception : yes
|
||||
cpuid level : 13
|
||||
wp : yes
|
||||
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm rep_good nopl cpuid extd_apicid pni cx16 hypervisor lahf_lm cmp_legacy svm 3dnowprefetch vmmcall
|
||||
bugs : fxsave_leak sysret_ss_attrs null_seg swapgs_fence amd_e400 spectre_v1 spectre_v2
|
||||
bogomips : 1999.99
|
||||
TLB size : 1024 4K pages
|
||||
clflush size : 64
|
||||
cache_alignment : 64
|
||||
address sizes : 40 bits physical, 48 bits virtual
|
||||
power management:
|
||||
|
||||
processor : 4
|
||||
vendor_id : AuthenticAMD
|
||||
cpu family : 15
|
||||
model : 107
|
||||
model name : QEMU Virtual CPU version 2.5+
|
||||
stepping : 1
|
||||
microcode : 0x1000065
|
||||
cpu MHz : 999.997
|
||||
cache size : 512 KB
|
||||
physical id : 0
|
||||
siblings : 4
|
||||
core id : 0
|
||||
cpu cores : 2
|
||||
apicid : 0
|
||||
initial apicid : 0
|
||||
fpu : yes
|
||||
fpu_exception : yes
|
||||
cpuid level : 13
|
||||
wp : yes
|
||||
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm rep_good nopl cpuid extd_apicid pni cx16 hypervisor lahf_lm cmp_legacy svm 3dnowprefetch vmmcall
|
||||
bugs : fxsave_leak sysret_ss_attrs null_seg swapgs_fence amd_e400 spectre_v1 spectre_v2
|
||||
bogomips : 1999.99
|
||||
TLB size : 1024 4K pages
|
||||
clflush size : 64
|
||||
cache_alignment : 64
|
||||
address sizes : 40 bits physical, 48 bits virtual
|
||||
power management:
|
||||
|
||||
processor : 5
|
||||
vendor_id : AuthenticAMD
|
||||
cpu family : 15
|
||||
model : 107
|
||||
model name : QEMU Virtual CPU version 2.5+
|
||||
stepping : 1
|
||||
microcode : 0x1000065
|
||||
cpu MHz : 999.997
|
||||
cache size : 512 KB
|
||||
physical id : 0
|
||||
siblings : 4
|
||||
core id : 1
|
||||
cpu cores : 2
|
||||
apicid : 0
|
||||
initial apicid : 0
|
||||
fpu : yes
|
||||
fpu_exception : yes
|
||||
cpuid level : 13
|
||||
wp : yes
|
||||
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm rep_good nopl cpuid extd_apicid pni cx16 hypervisor lahf_lm cmp_legacy svm 3dnowprefetch vmmcall
|
||||
bugs : fxsave_leak sysret_ss_attrs null_seg swapgs_fence amd_e400 spectre_v1 spectre_v2
|
||||
bogomips : 1999.99
|
||||
TLB size : 1024 4K pages
|
||||
clflush size : 64
|
||||
cache_alignment : 64
|
||||
address sizes : 40 bits physical, 48 bits virtual
|
||||
power management:
|
||||
|
||||
processor : 6
|
||||
vendor_id : AuthenticAMD
|
||||
cpu family : 15
|
||||
model : 107
|
||||
model name : QEMU Virtual CPU version 2.5+
|
||||
stepping : 1
|
||||
microcode : 0x1000065
|
||||
cpu MHz : 999.997
|
||||
cache size : 512 KB
|
||||
physical id : 1
|
||||
siblings : 4
|
||||
core id : 0
|
||||
cpu cores : 2
|
||||
apicid : 0
|
||||
initial apicid : 0
|
||||
fpu : yes
|
||||
fpu_exception : yes
|
||||
cpuid level : 13
|
||||
wp : yes
|
||||
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm rep_good nopl cpuid extd_apicid pni cx16 hypervisor lahf_lm cmp_legacy svm 3dnowprefetch vmmcall
|
||||
bugs : fxsave_leak sysret_ss_attrs null_seg swapgs_fence amd_e400 spectre_v1 spectre_v2
|
||||
bogomips : 1999.99
|
||||
TLB size : 1024 4K pages
|
||||
clflush size : 64
|
||||
cache_alignment : 64
|
||||
address sizes : 40 bits physical, 48 bits virtual
|
||||
power management:
|
||||
|
||||
processor : 7
|
||||
vendor_id : AuthenticAMD
|
||||
cpu family : 15
|
||||
model : 107
|
||||
model name : QEMU Virtual CPU version 2.5+
|
||||
stepping : 1
|
||||
microcode : 0x1000065
|
||||
cpu MHz : 999.997
|
||||
cache size : 512 KB
|
||||
physical id : 1
|
||||
siblings : 4
|
||||
core id : 1
|
||||
cpu cores : 2
|
||||
apicid : 0
|
||||
initial apicid : 0
|
||||
fpu : yes
|
||||
fpu_exception : yes
|
||||
cpuid level : 13
|
||||
wp : yes
|
||||
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm rep_good nopl cpuid extd_apicid pni cx16 hypervisor lahf_lm cmp_legacy svm 3dnowprefetch vmmcall
|
||||
bugs : fxsave_leak sysret_ss_attrs null_seg swapgs_fence amd_e400 spectre_v1 spectre_v2
|
||||
bogomips : 1999.99
|
||||
TLB size : 1024 4K pages
|
||||
clflush size : 64
|
||||
cache_alignment : 64
|
||||
address sizes : 40 bits physical, 48 bits virtual
|
||||
power management:
|
||||
|
||||
9
internal/host/testdata/debian12/etc/os-release
vendored
Normal file
9
internal/host/testdata/debian12/etc/os-release
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
|
||||
NAME="Debian GNU/Linux"
|
||||
VERSION_ID="12"
|
||||
VERSION="12 (bookworm)"
|
||||
VERSION_CODENAME=bookworm
|
||||
ID=debian
|
||||
HOME_URL="https://www.debian.org/"
|
||||
SUPPORT_URL="https://www.debian.org/support"
|
||||
BUG_REPORT_URL="https://bugs.debian.org/"
|
||||
56
internal/host/testdata/debian12/proc/cpuinfo
vendored
Normal file
56
internal/host/testdata/debian12/proc/cpuinfo
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
processor : 0
|
||||
vendor_id : AuthenticAMD
|
||||
cpu family : 15
|
||||
model : 107
|
||||
model name : QEMU Virtual CPU version 2.5+
|
||||
stepping : 1
|
||||
microcode : 0x1000065
|
||||
cpu MHz : 999.997
|
||||
cache size : 512 KB
|
||||
physical id : 0
|
||||
siblings : 2
|
||||
core id : 0
|
||||
cpu cores : 2
|
||||
apicid : 0
|
||||
initial apicid : 0
|
||||
fpu : yes
|
||||
fpu_exception : yes
|
||||
cpuid level : 13
|
||||
wp : yes
|
||||
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm rep_good nopl cpuid extd_apicid pni cx16 hypervisor lahf_lm cmp_legacy svm 3dnowprefetch vmmcall
|
||||
bugs : fxsave_leak sysret_ss_attrs null_seg swapgs_fence amd_e400 spectre_v1 spectre_v2
|
||||
bogomips : 1999.99
|
||||
TLB size : 1024 4K pages
|
||||
clflush size : 64
|
||||
cache_alignment : 64
|
||||
address sizes : 40 bits physical, 48 bits virtual
|
||||
power management:
|
||||
|
||||
processor : 1
|
||||
vendor_id : AuthenticAMD
|
||||
cpu family : 15
|
||||
model : 107
|
||||
model name : QEMU Virtual CPU version 2.5+
|
||||
stepping : 1
|
||||
microcode : 0x1000065
|
||||
cpu MHz : 999.997
|
||||
cache size : 512 KB
|
||||
physical id : 0
|
||||
siblings : 2
|
||||
core id : 1
|
||||
cpu cores : 2
|
||||
apicid : 1
|
||||
initial apicid : 1
|
||||
fpu : yes
|
||||
fpu_exception : yes
|
||||
cpuid level : 13
|
||||
wp : yes
|
||||
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm rep_good nopl cpuid extd_apicid pni cx16 hypervisor lahf_lm cmp_legacy svm 3dnowprefetch vmmcall
|
||||
bugs : fxsave_leak sysret_ss_attrs null_seg swapgs_fence amd_e400 spectre_v1 spectre_v2
|
||||
bogomips : 2503.44
|
||||
TLB size : 1024 4K pages
|
||||
clflush size : 64
|
||||
cache_alignment : 64
|
||||
address sizes : 40 bits physical, 48 bits virtual
|
||||
power management:
|
||||
|
||||
1
internal/host/testdata/debian12/proc/loadavg
vendored
Normal file
1
internal/host/testdata/debian12/proc/loadavg
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
0.08 0.03 0.04 1/144 6
|
||||
54
internal/host/testdata/debian12/proc/meminfo
vendored
Normal file
54
internal/host/testdata/debian12/proc/meminfo
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
MemTotal: 2010432 kB
|
||||
MemFree: 690340 kB
|
||||
MemAvailable: 1620016 kB
|
||||
Buffers: 177720 kB
|
||||
Cached: 837308 kB
|
||||
SwapCached: 0 kB
|
||||
Active: 409508 kB
|
||||
Inactive: 681136 kB
|
||||
Active(anon): 81680 kB
|
||||
Inactive(anon): 72 kB
|
||||
Active(file): 327828 kB
|
||||
Inactive(file): 681064 kB
|
||||
Unevictable: 11868 kB
|
||||
Mlocked: 0 kB
|
||||
SwapTotal: 0 kB
|
||||
SwapFree: 0 kB
|
||||
Zswap: 0 kB
|
||||
Zswapped: 0 kB
|
||||
Dirty: 568 kB
|
||||
Writeback: 0 kB
|
||||
AnonPages: 80808 kB
|
||||
Mapped: 166636 kB
|
||||
Shmem: 4936 kB
|
||||
KReclaimable: 105056 kB
|
||||
Slab: 159000 kB
|
||||
SReclaimable: 105056 kB
|
||||
SUnreclaim: 53944 kB
|
||||
KernelStack: 2320 kB
|
||||
PageTables: 2928 kB
|
||||
SecPageTables: 0 kB
|
||||
NFS_Unstable: 0 kB
|
||||
Bounce: 0 kB
|
||||
WritebackTmp: 0 kB
|
||||
CommitLimit: 1005216 kB
|
||||
Committed_AS: 496972 kB
|
||||
VmallocTotal: 34359738367 kB
|
||||
VmallocUsed: 17080 kB
|
||||
VmallocChunk: 0 kB
|
||||
Percpu: 1192 kB
|
||||
HardwareCorrupted: 0 kB
|
||||
AnonHugePages: 0 kB
|
||||
ShmemHugePages: 0 kB
|
||||
ShmemPmdMapped: 0 kB
|
||||
FileHugePages: 0 kB
|
||||
FilePmdMapped: 0 kB
|
||||
Unaccepted: 0 kB
|
||||
HugePages_Total: 0
|
||||
HugePages_Free: 0
|
||||
HugePages_Rsvd: 0
|
||||
HugePages_Surp: 0
|
||||
Hugepagesize: 2048 kB
|
||||
Hugetlb: 0 kB
|
||||
DirectMap4k: 112268 kB
|
||||
DirectMap2M: 1980416 kB
|
||||
10
internal/host/testdata/debian12/proc/stat
vendored
Normal file
10
internal/host/testdata/debian12/proc/stat
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
cpu 2014808 0 3797047 237290637 7608 0 66047 0 0 0
|
||||
cpu0 997273 0 1861281 118761074 3753 0 27566 0 0 0
|
||||
cpu1 1017534 0 1935766 118529563 3854 0 38481 0 0 0
|
||||
intr 191922858 235 9 0 0 1122 0 0 0 0 0 0 0 144 0 0 0 0 0 0 0 0 0 0 0 0 6 0 3 0 274341 277139 0 0 0 281571 324044 0 1603949 1543300 0 20236 0 1770807 0 21 0 0 0 0 0 0 0 0 0 5953816 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
ctxt 212551065
|
||||
btime 1792210880
|
||||
processes 2962640
|
||||
procs_running 1
|
||||
procs_blocked 0
|
||||
softirq 141699889 5 32984936 1057 2776040 0 0 74 54302609 3 51635165
|
||||
1
internal/host/testdata/debian12/proc/sys/kernel/hostname
vendored
Normal file
1
internal/host/testdata/debian12/proc/sys/kernel/hostname
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
hv1
|
||||
1
internal/host/testdata/debian12/proc/sys/kernel/osrelease
vendored
Normal file
1
internal/host/testdata/debian12/proc/sys/kernel/osrelease
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
6.8.0-50-generic
|
||||
1
internal/host/testdata/debian12/proc/uptime
vendored
Normal file
1
internal/host/testdata/debian12/proc/uptime
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
1243445.41 2372906.39
|
||||
20
internal/host/testdata/rocky10/etc/os-release
vendored
Normal file
20
internal/host/testdata/rocky10/etc/os-release
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
NAME="Rocky Linux"
|
||||
VERSION="10.2 (Red Quartz)"
|
||||
RELEASE_TYPE="stable"
|
||||
ID="rocky"
|
||||
ID_LIKE="rhel centos fedora"
|
||||
VERSION_ID="10.2"
|
||||
PLATFORM_ID="platform:el10"
|
||||
PRETTY_NAME="Rocky Linux 10.2 (Red Quartz)"
|
||||
ANSI_COLOR="0;32"
|
||||
LOGO="fedora-logo-icon"
|
||||
CPE_NAME="cpe:/o:rocky:rocky:10::baseos"
|
||||
HOME_URL="https://rockylinux.org/"
|
||||
VENDOR_NAME="RESF"
|
||||
VENDOR_URL="https://resf.org/"
|
||||
BUG_REPORT_URL="https://bugs.rockylinux.org/"
|
||||
SUPPORT_END="2035-05-31"
|
||||
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-10"
|
||||
ROCKY_SUPPORT_PRODUCT_VERSION="10.2"
|
||||
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
|
||||
REDHAT_SUPPORT_PRODUCT_VERSION="10.2"
|
||||
Loading…
Add table
Add a link
Reference in a new issue