mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 00:26:36 +03:00
The commit introduces the `vm_os_info` metric, which is exposed by all VM binaries by default. It provides visibility into the operating system version on which VictoriaMetrics is running, helping with troubleshooting environment-specific issues, like known kernel or fs bugs. FIxes https://github.com/VictoriaMetrics/VictoriaMetrics/issues/10481 PR https://github.com/VictoriaMetrics/VictoriaMetrics/pull/10746 Co-authored-by: Max Kotliar <mkotlyar@victoriametrics.com>
31 lines
689 B
Go
31 lines
689 B
Go
package osinfo
|
|
|
|
import (
|
|
"fmt"
|
|
"syscall"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
|
"github.com/VictoriaMetrics/metrics"
|
|
)
|
|
|
|
var linuxRelease string
|
|
|
|
func ExposeAsMetric() {
|
|
var uname syscall.Utsname
|
|
if err := syscall.Uname(&uname); err != nil {
|
|
logger.Warnf("os info wont be exposed as vm_os_info metric; failed to call syscall.Uname: %s", err)
|
|
return
|
|
}
|
|
|
|
release := make([]byte, 0, len(uname.Release))
|
|
for _, v := range uname.Release {
|
|
if v == 0 {
|
|
break
|
|
}
|
|
release = append(release, byte(v))
|
|
}
|
|
linuxRelease = string(release)
|
|
|
|
_ = metrics.GetOrCreateGauge(fmt.Sprintf(`vm_os_info{os="linux", release=%q}`, linuxRelease), func() float64 { return 1 })
|
|
}
|