-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #504 from essentialkaos/develop
Version 13.5.0
- Loading branch information
Showing
22 changed files
with
913 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//go:build linux || darwin | ||
// +build linux darwin | ||
|
||
// Package kernel provides methods for collecting information from OS kernel | ||
package kernel | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
// // | ||
// Copyright (c) 2024 ESSENTIAL KAOS // | ||
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> // | ||
// // | ||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/essentialkaos/ek/v13/strutil" | ||
"github.com/essentialkaos/ek/v13/support" | ||
"github.com/essentialkaos/ek/v13/system/sysctl" | ||
) | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
// Collect collects info from OS kernel | ||
func Collect(params ...string) []support.KernelParam { | ||
kernelParams, err := sysctl.All() | ||
|
||
if err != nil { | ||
return nil | ||
} | ||
|
||
var result []support.KernelParam | ||
|
||
for _, param := range params { | ||
for k, v := range kernelParams { | ||
if !strings.HasPrefix(k, param) { | ||
continue | ||
} | ||
|
||
value := strings.ReplaceAll(v, "\t", " ") | ||
value = strutil.SqueezeRepeats(value, " ") | ||
|
||
result = append(result, support.KernelParam{ | ||
Key: k, | ||
Value: value, | ||
}) | ||
} | ||
} | ||
|
||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Package kernel provides methods for collecting information from OS kernel | ||
package kernel | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
// // | ||
// Copyright (c) 2024 ESSENTIAL KAOS // | ||
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> // | ||
// // | ||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
import "github.com/essentialkaos/ek/v13/support" | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
// Collect collects info from OS kernel | ||
func Collect(params ...string) []support.KernelParam { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//go:build linux || darwin | ||
// +build linux darwin | ||
|
||
// Package resources provides methods for collecting information about system | ||
// resources (cpu/memory) | ||
package resources | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
// // | ||
// Copyright (c) 2024 ESSENTIAL KAOS // | ||
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> // | ||
// // | ||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
import ( | ||
"github.com/essentialkaos/ek/v13/support" | ||
"github.com/essentialkaos/ek/v13/system" | ||
) | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
// Collect collects info about CPU and memory | ||
func Collect() *support.ResourcesInfo { | ||
result := &support.ResourcesInfo{} | ||
|
||
cpuInfo, err1 := system.GetCPUInfo() | ||
|
||
if err1 == nil { | ||
for _, p := range cpuInfo { | ||
result.CPU = append(result.CPU, support.CPUInfo{ | ||
Model: p.Model, | ||
Cores: p.Cores, | ||
Threads: p.Siblings / p.Cores, | ||
}) | ||
} | ||
} | ||
|
||
memInfo, err2 := system.GetMemUsage() | ||
|
||
if err2 == nil { | ||
result.MemTotal = memInfo.MemTotal | ||
result.MemFree = memInfo.MemFree | ||
result.MemUsed = memInfo.MemUsed | ||
result.SwapTotal = memInfo.SwapTotal | ||
result.SwapFree = memInfo.SwapFree | ||
result.SwapUsed = memInfo.SwapUsed | ||
} | ||
|
||
if err1 != nil && err2 != nil { | ||
return nil | ||
} | ||
|
||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Package resources provides methods for collecting information about system | ||
// resources (cpu/memory) | ||
package resources | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
// // | ||
// Copyright (c) 2024 ESSENTIAL KAOS // | ||
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> // | ||
// // | ||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
import ( | ||
"github.com/essentialkaos/ek/v13/support" | ||
) | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
// Collect collects info about CPU and memory | ||
func Collect() *support.ResourcesInfo { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.