Comments (15)
I don't think we should use this library (at least for now) at all
as you can see , they just read a file and we should get from that file directly
https://github.com/zcalusic/sysinfo/blob/99e836ba64f229922382eecd8a346e6b3d1b560a/kernel_linux.go#L22
from kepler.
I will submit a PR to fix this soon
from kepler.
we can refer to this function and just use it instead of using the whole library
from kepler.
package main
import (
"encoding/json"
"fmt"
"github.com/zcalusic/sysinfo"
)
func main() {
var si sysinfo.SysInfo
si.GetSysInfo()
data, err := json.MarshalIndent(&si, "", " ")
fmt.Println(data)
fmt.Println(si)
fmt.Println(si.Kernel.Version)
if err == nil {
var result map[string]map[string]string
if err = json.Unmarshal(data, &result); err != nil {
fmt.Println("----")
fmt.Println(err)
fmt.Println("----")
}
}
fmt.Println("done")
}
[123 10 32 32 34 115 121 115 105 110 102 111 34 58 32 123 10 32 32 32 32 34 118 101 114 115 105 111 110 34 58 32 34 48 46 57 46 53 34 44 10 32 32 32 32 34 116 105 109 101 115 116 97 109 112 34 58 32 34 50 48 48 57 45 49 49 45 49 48 84 50 51 58 48 48 58 48 48 90 34 10 32 32 125 44 10 32 32 34 110 111 100 101 34 58 32 123 10 32 32 32 32 34 104 111 115 116 110 97 109 101 34 58 32 34 100 57 53 55 99 54 57 51 100 50 57 102 34 44 10 32 32 32 32 34 109 97 99 104 105 110 101 105 100 34 58 32 34 57 57 56 97 50 102 57 56 57 48 52 101 49 51 55 97 102 53 98 102 55 102 57 55 52 97 102 57 102 48 55 48 34 44 10 32 32 32 32 34 104 121 112 101 114 118 105 115 111 114 34 58 32 34 107 118 109 34 10 32 32 125 44 10 32 32 34 111 115 34 58 32 123 10 32 32 32 32 34 97 114 99 104 105 116 101 99 116 117 114 101 34 58 32 34 97 109 100 54 52 34 10 32 32 125 44 10 32 32 34 107 101 114 110 101 108 34 58 32 123 10 32 32 32 32 34 97 114 99 104 105 116 101 99 116 117 114 101 34 58 32 34 120 56 54 95 54 52 34 10 32 32 125 44 10 32 32 34 112 114 111 100 117 99 116 34 58 32 123 125 44 10 32 32 34 98 111 97 114 100 34 58 32 123 125 44 10 32 32 34 99 104 97 115 115 105 115 34 58 32 123 125 44 10 32 32 34 98 105 111 115 34 58 32 123 125 44 10 32 32 34 99 112 117 34 58 32 123 10 32 32 32 32 34 118 101 110 100 111 114 34 58 32 34 65 117 116 104 101 110 116 105 99 65 77 68 34 44 10 32 32 32 32 34 109 111 100 101 108 34 58 32 34 117 110 107 110 111 119 110 34 44 10 32 32 32 32 34 116 104 114 101 97 100 115 34 58 32 56 10 32 32 125 44 10 32 32 34 109 101 109 111 114 121 34 58 32 123 125 10 125]
{{0.9.5 2009-11-10 23:00:00 +0000 UTC m=+0.000000001} {d957c693d29f 998a2f98904e137af5bf7f974af9f070 kvm } { amd64} { x86_64} { } { } {0 } { } {AuthenticAMD unknown 0 0 0 0 8} { 0 0} [] []}
----
json: cannot unmarshal number into Go value of type string
----
done
I am not sure if we should correct to si.Kernel.Version
? as the function named as getKernelVersion
from kepler.
but fmt.Println(si.Kernel.Version)
is empty at go playground.
from kepler.
I don't think we should use this library (at least for now) at all as you can see , they just read a file and we should get from that file directly https://github.com/zcalusic/sysinfo/blob/99e836ba64f229922382eecd8a346e6b3d1b560a/kernel_linux.go#L22
I am not sure if this one looks better
https://github.com/cilium/ebpf/blob/b81c37125bd70a4f086b073e821a5ea79b31e394/features/version.go#L12
...// ignore for code trace stack
https://github.com/cilium/ebpf/blob/3418f341ac0460cf4164146e0c1ec6c40156b4fc/internal/vdso.go#L21
from kepler.
We can read the os-release files instead of use the library.
For example docker-slim reads different files depending on the OS distribution.
Note that we also need to support macOS for developing purpose.
Could you please submit a PR for this?
from kepler.
we can read /proc/version
package main
import (
"fmt"
"log"
"os"
)
func main() {
output, err := os.ReadFile("/proc/version")
if err != nil {
log.Fatal(err)
}
fmt.Printf("output: %q\n", string(output))
}
Here is the go playground test
from kepler.
GetSysInfo
gets kernel version from /proc/sys
While uname and golang Uname use syscall.
Let's switch to the uname way. Here is the go playground sample
from kepler.
yes, thanks for the info, I will update the code with your comment soon
BTW I don't have Mac env, guess the unix way should be able to cover that as well?
from kepler.
Here is what I get:
uname -a
Darwin MacBook-Pro-3.local 21.6.0 Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64 x86_64
name -v
Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64
from kepler.
But the golang code before returns:
2022/09/14 22:52:58 open /proc/version: no such file or directory
exit status 1
We can handle the error and return a low number, so by default we will use an "old" kernel version if it is not identified....
from kepler.
is #179 (comment) works for you?
anyway, as metioned, previously the mac version from sysinfo library doesn't have Mac implementation at all...
from kepler.
I only tested the unix way in golang locally, but found those in latest build env
Not able to parse kernel version, use -1 instead
config getKernelVersion: -1
Not able to parse kernel version, use -1 instead
need check why ...
from kepler.
5.4.0-48-generic is my OS, so based on current logic, it's 5.4. (note the .)
so not able to parse the kernel version
from kepler.
Related Issues (20)
- Kepler metric readings incorrectly report “source=intel-rapl” on RHEL9/arm64
- Huge difference between Kepler power consumption and real PDU power consumption HOT 3
- Could not find any ACPI power meter path. Is it a VM? HOT 7
- RAPL and ACPI in AMD and INTEL CPU environment. HOT 1
- Kepler not reporting correct process name in metrics
- Add support to show Kepler images info in CI HOT 1
- Use make targets instead of docker actions for building and pushing images on CI HOT 1
- Can we add kwok support for integration test?
- Remove BCC Code
- Evaluate using tracepoint/sched_switch over kprobe/finish_task_switch
- No value reported by Kepler latest on OpenShift HOT 7
- Audit usage of build tags
- CPU Ref Cycles in unused HOT 1
- Using bpf_perf_event_read_value causes verifier error
- Add eBPF Testing HOT 1
- "Other" metrics are out of proportion on local Kind cluster
- Kepler rpm not installable HOT 4
- Replace libbpfgo with cilium/ebpf
- Add workflow to build and push Kepler builder image
- Keep ginkgo versions in sync
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kepler.