mirror of
https://github.com/kubernetes/node-problem-detector.git
synced 2026-08-28 01:47:20 +00:00
Move glog/klog logging to klog/v2
This commit is contained in:
committed by
Ciprian Hacman
parent
eeab0ab06f
commit
e43459d86d
@@ -17,8 +17,8 @@ limitations under the License.
|
||||
package systemstatsmonitor
|
||||
|
||||
import (
|
||||
"github.com/golang/glog"
|
||||
"github.com/shirou/gopsutil/v3/cpu"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
ssmtypes "k8s.io/node-problem-detector/pkg/systemstatsmonitor/types"
|
||||
"k8s.io/node-problem-detector/pkg/util/metrics"
|
||||
@@ -67,7 +67,7 @@ func NewCPUCollectorOrDie(cpuConfig *ssmtypes.CPUStatsConfig, procPath string) *
|
||||
metrics.LastValue,
|
||||
[]string{})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.CPURunnableTaskCountID, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.CPURunnableTaskCountID, err)
|
||||
}
|
||||
|
||||
cc.mUsageTime, err = metrics.NewFloat64Metric(
|
||||
@@ -78,7 +78,7 @@ func NewCPUCollectorOrDie(cpuConfig *ssmtypes.CPUStatsConfig, procPath string) *
|
||||
metrics.Sum,
|
||||
[]string{stateLabel})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.CPUUsageTimeID, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.CPUUsageTimeID, err)
|
||||
}
|
||||
|
||||
cc.mCpuLoad1m, err = metrics.NewFloat64Metric(
|
||||
@@ -89,7 +89,7 @@ func NewCPUCollectorOrDie(cpuConfig *ssmtypes.CPUStatsConfig, procPath string) *
|
||||
metrics.LastValue,
|
||||
[]string{})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.CPULoad1m, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.CPULoad1m, err)
|
||||
}
|
||||
|
||||
cc.mCpuLoad5m, err = metrics.NewFloat64Metric(
|
||||
@@ -100,7 +100,7 @@ func NewCPUCollectorOrDie(cpuConfig *ssmtypes.CPUStatsConfig, procPath string) *
|
||||
metrics.LastValue,
|
||||
[]string{})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.CPULoad5m, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.CPULoad5m, err)
|
||||
}
|
||||
|
||||
cc.mCpuLoad15m, err = metrics.NewFloat64Metric(
|
||||
@@ -111,7 +111,7 @@ func NewCPUCollectorOrDie(cpuConfig *ssmtypes.CPUStatsConfig, procPath string) *
|
||||
metrics.LastValue,
|
||||
[]string{})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.CPULoad15m, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.CPULoad15m, err)
|
||||
}
|
||||
|
||||
cc.mSystemProcessesTotal, err = metrics.NewInt64Metric(
|
||||
@@ -122,7 +122,7 @@ func NewCPUCollectorOrDie(cpuConfig *ssmtypes.CPUStatsConfig, procPath string) *
|
||||
metrics.Sum,
|
||||
[]string{})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.SystemProcessesTotal, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.SystemProcessesTotal, err)
|
||||
}
|
||||
|
||||
cc.mSystemProcsRunning, err = metrics.NewInt64Metric(
|
||||
@@ -133,7 +133,7 @@ func NewCPUCollectorOrDie(cpuConfig *ssmtypes.CPUStatsConfig, procPath string) *
|
||||
metrics.LastValue,
|
||||
[]string{})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.SystemProcsRunning, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.SystemProcsRunning, err)
|
||||
}
|
||||
|
||||
cc.mSystemProcsBlocked, err = metrics.NewInt64Metric(
|
||||
@@ -144,7 +144,7 @@ func NewCPUCollectorOrDie(cpuConfig *ssmtypes.CPUStatsConfig, procPath string) *
|
||||
metrics.LastValue,
|
||||
[]string{})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.SystemProcsBlocked, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.SystemProcsBlocked, err)
|
||||
}
|
||||
|
||||
cc.mSystemInterruptsTotal, err = metrics.NewInt64Metric(
|
||||
@@ -155,7 +155,7 @@ func NewCPUCollectorOrDie(cpuConfig *ssmtypes.CPUStatsConfig, procPath string) *
|
||||
metrics.Sum,
|
||||
[]string{})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.SystemInterruptsTotal, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.SystemInterruptsTotal, err)
|
||||
}
|
||||
|
||||
cc.mSystemCPUStat, err = metrics.NewFloat64Metric(
|
||||
@@ -166,7 +166,7 @@ func NewCPUCollectorOrDie(cpuConfig *ssmtypes.CPUStatsConfig, procPath string) *
|
||||
metrics.Sum,
|
||||
[]string{cpuLabel, stageLabel})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.SystemCPUStat, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.SystemCPUStat, err)
|
||||
}
|
||||
|
||||
cc.lastUsageTime = make(map[string]float64)
|
||||
@@ -182,7 +182,7 @@ func (cc *cpuCollector) recordUsage() {
|
||||
// Set percpu=false to get aggregated usage from all CPUs.
|
||||
timersStats, err := cpu.Times(false)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to retrieve CPU timers stat: %v", err)
|
||||
klog.Errorf("Failed to retrieve CPU timers stat: %v", err)
|
||||
return
|
||||
}
|
||||
timersStat := timersStats[0]
|
||||
|
||||
@@ -21,9 +21,9 @@ package systemstatsmonitor
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/prometheus/procfs"
|
||||
"github.com/shirou/gopsutil/v3/load"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
func (cc *cpuCollector) recordLoad() {
|
||||
@@ -35,7 +35,7 @@ func (cc *cpuCollector) recordLoad() {
|
||||
|
||||
loadAvg, err := load.Avg()
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to retrieve average CPU load: %v", err)
|
||||
klog.Errorf("Failed to retrieve average CPU load: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func (cc *cpuCollector) recordSystemStats() {
|
||||
fs, err := procfs.NewFS(cc.procPath)
|
||||
stats, err := fs.Stat()
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to retrieve cpu/process stats: %v", err)
|
||||
klog.Errorf("Failed to retrieve cpu/process stats: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/shirou/gopsutil/v3/disk"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
ssmtypes "k8s.io/node-problem-detector/pkg/systemstatsmonitor/types"
|
||||
"k8s.io/node-problem-detector/pkg/util/metrics"
|
||||
@@ -69,7 +69,7 @@ func NewDiskCollectorOrDie(diskConfig *ssmtypes.DiskStatsConfig) *diskCollector
|
||||
metrics.Sum,
|
||||
[]string{deviceNameLabel})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for disk/io_time: %v", err)
|
||||
klog.Fatalf("Error initializing metric for disk/io_time: %v", err)
|
||||
}
|
||||
|
||||
// Use metrics.Sum aggregation method to ensure the metric is a counter/cumulative metric.
|
||||
@@ -81,7 +81,7 @@ func NewDiskCollectorOrDie(diskConfig *ssmtypes.DiskStatsConfig) *diskCollector
|
||||
metrics.Sum,
|
||||
[]string{deviceNameLabel})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for disk/weighted_io: %v", err)
|
||||
klog.Fatalf("Error initializing metric for disk/weighted_io: %v", err)
|
||||
}
|
||||
|
||||
dc.mAvgQueueLen, err = metrics.NewFloat64Metric(
|
||||
@@ -92,7 +92,7 @@ func NewDiskCollectorOrDie(diskConfig *ssmtypes.DiskStatsConfig) *diskCollector
|
||||
metrics.LastValue,
|
||||
[]string{deviceNameLabel})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for disk/avg_queue_len: %v", err)
|
||||
klog.Fatalf("Error initializing metric for disk/avg_queue_len: %v", err)
|
||||
}
|
||||
|
||||
dc.mOpsCount, err = metrics.NewInt64Metric(
|
||||
@@ -103,7 +103,7 @@ func NewDiskCollectorOrDie(diskConfig *ssmtypes.DiskStatsConfig) *diskCollector
|
||||
metrics.Sum,
|
||||
[]string{deviceNameLabel, directionLabel})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.DiskOpsCountID, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.DiskOpsCountID, err)
|
||||
}
|
||||
|
||||
dc.mMergedOpsCount, err = metrics.NewInt64Metric(
|
||||
@@ -114,7 +114,7 @@ func NewDiskCollectorOrDie(diskConfig *ssmtypes.DiskStatsConfig) *diskCollector
|
||||
metrics.Sum,
|
||||
[]string{deviceNameLabel, directionLabel})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.DiskMergedOpsCountID, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.DiskMergedOpsCountID, err)
|
||||
}
|
||||
|
||||
dc.mOpsBytes, err = metrics.NewInt64Metric(
|
||||
@@ -125,7 +125,7 @@ func NewDiskCollectorOrDie(diskConfig *ssmtypes.DiskStatsConfig) *diskCollector
|
||||
metrics.Sum,
|
||||
[]string{deviceNameLabel, directionLabel})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.DiskOpsBytesID, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.DiskOpsBytesID, err)
|
||||
}
|
||||
|
||||
dc.mOpsTime, err = metrics.NewInt64Metric(
|
||||
@@ -136,7 +136,7 @@ func NewDiskCollectorOrDie(diskConfig *ssmtypes.DiskStatsConfig) *diskCollector
|
||||
metrics.Sum,
|
||||
[]string{deviceNameLabel, directionLabel})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.DiskOpsTimeID, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.DiskOpsTimeID, err)
|
||||
}
|
||||
|
||||
dc.mBytesUsed, err = metrics.NewInt64Metric(
|
||||
@@ -147,7 +147,7 @@ func NewDiskCollectorOrDie(diskConfig *ssmtypes.DiskStatsConfig) *diskCollector
|
||||
metrics.LastValue,
|
||||
[]string{deviceNameLabel, fsTypeLabel, mountOptionLabel, stateLabel})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.DiskBytesUsedID, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.DiskBytesUsedID, err)
|
||||
}
|
||||
|
||||
dc.lastIOTime = make(map[string]uint64)
|
||||
@@ -247,7 +247,7 @@ func (dc *diskCollector) collect() {
|
||||
|
||||
partitions, err := disk.Partitions(false)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to list disk partitions: %v", err)
|
||||
klog.Errorf("Failed to list disk partitions: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ func (dc *diskCollector) collect() {
|
||||
// Fetch metrics from /proc, /sys.
|
||||
ioCountersStats, err := disk.IOCounters(devices...)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to retrieve disk IO counters: %v", err)
|
||||
klog.Errorf("Failed to retrieve disk IO counters: %v", err)
|
||||
return
|
||||
}
|
||||
sampleTime := time.Now()
|
||||
@@ -283,7 +283,7 @@ func (dc *diskCollector) collect() {
|
||||
seen[partition.Device] = true
|
||||
usageStat, err := disk.Usage(partition.Mountpoint)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to retrieve disk usage for %q: %v", partition.Mountpoint, err)
|
||||
klog.Errorf("Failed to retrieve disk usage for %q: %v", partition.Mountpoint, err)
|
||||
continue
|
||||
}
|
||||
deviceName := strings.TrimPrefix(partition.Device, "/dev/")
|
||||
@@ -306,7 +306,7 @@ func listRootBlockDevices(timeout time.Duration) []string {
|
||||
cmd := exec.CommandContext(ctx, "lsblk", "-d", "-n", "-o", "NAME")
|
||||
stdout, err := cmd.Output()
|
||||
if err != nil {
|
||||
glog.Errorf("Error calling lsblk")
|
||||
klog.Errorf("Error calling lsblk")
|
||||
}
|
||||
return strings.Split(strings.TrimSpace(string(stdout)), "\n")
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ limitations under the License.
|
||||
package systemstatsmonitor
|
||||
|
||||
import (
|
||||
"github.com/golang/glog"
|
||||
"github.com/shirou/gopsutil/v3/host"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
ssmtypes "k8s.io/node-problem-detector/pkg/systemstatsmonitor/types"
|
||||
"k8s.io/node-problem-detector/pkg/util"
|
||||
@@ -35,13 +35,13 @@ func NewHostCollectorOrDie(hostConfig *ssmtypes.HostStatsConfig) *hostCollector
|
||||
|
||||
kernelVersion, err := host.KernelVersion()
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed to retrieve kernel version: %v", err)
|
||||
klog.Fatalf("Failed to retrieve kernel version: %v", err)
|
||||
}
|
||||
hc.tags["kernel_version"] = kernelVersion
|
||||
|
||||
osVersion, err := util.GetOSVersion()
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed to retrieve OS version: %v", err)
|
||||
klog.Fatalf("Failed to retrieve OS version: %v", err)
|
||||
}
|
||||
hc.tags["os_version"] = osVersion
|
||||
|
||||
@@ -55,7 +55,7 @@ func NewHostCollectorOrDie(hostConfig *ssmtypes.HostStatsConfig) *hostCollector
|
||||
metrics.LastValue,
|
||||
[]string{"kernel_version", "os_version"})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for host/uptime: %v", err)
|
||||
klog.Fatalf("Error initializing metric for host/uptime: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ func (hc *hostCollector) collect() {
|
||||
|
||||
uptime, err := host.Uptime()
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to retrieve uptime of the host: %v", err)
|
||||
klog.Errorf("Failed to retrieve uptime of the host: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package systemstatsmonitor
|
||||
|
||||
import (
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
ssmtypes "k8s.io/node-problem-detector/pkg/systemstatsmonitor/types"
|
||||
"k8s.io/node-problem-detector/pkg/util/metrics"
|
||||
@@ -46,7 +46,7 @@ func NewMemoryCollectorOrDie(memoryConfig *ssmtypes.MemoryStatsConfig) *memoryCo
|
||||
metrics.LastValue,
|
||||
[]string{stateLabel})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.MemoryBytesUsedID, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.MemoryBytesUsedID, err)
|
||||
}
|
||||
|
||||
mc.mAnonymousUsed, err = metrics.NewInt64Metric(
|
||||
@@ -57,7 +57,7 @@ func NewMemoryCollectorOrDie(memoryConfig *ssmtypes.MemoryStatsConfig) *memoryCo
|
||||
metrics.LastValue,
|
||||
[]string{stateLabel})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.MemoryAnonymousUsedID, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.MemoryAnonymousUsedID, err)
|
||||
}
|
||||
|
||||
mc.mPageCacheUsed, err = metrics.NewInt64Metric(
|
||||
@@ -68,7 +68,7 @@ func NewMemoryCollectorOrDie(memoryConfig *ssmtypes.MemoryStatsConfig) *memoryCo
|
||||
metrics.LastValue,
|
||||
[]string{stateLabel})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.MemoryPageCacheUsedID, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.MemoryPageCacheUsedID, err)
|
||||
}
|
||||
|
||||
mc.mUnevictableUsed, err = metrics.NewInt64Metric(
|
||||
@@ -79,7 +79,7 @@ func NewMemoryCollectorOrDie(memoryConfig *ssmtypes.MemoryStatsConfig) *memoryCo
|
||||
metrics.LastValue,
|
||||
[]string{})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.MemoryUnevictableUsedID, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.MemoryUnevictableUsedID, err)
|
||||
}
|
||||
|
||||
mc.mDirtyUsed, err = metrics.NewInt64Metric(
|
||||
@@ -90,7 +90,7 @@ func NewMemoryCollectorOrDie(memoryConfig *ssmtypes.MemoryStatsConfig) *memoryCo
|
||||
metrics.LastValue,
|
||||
[]string{stateLabel})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for %q: %v", metrics.MemoryDirtyUsedID, err)
|
||||
klog.Fatalf("Error initializing metric for %q: %v", metrics.MemoryDirtyUsedID, err)
|
||||
}
|
||||
|
||||
return &mc
|
||||
|
||||
@@ -19,8 +19,8 @@ limitations under the License.
|
||||
package systemstatsmonitor
|
||||
|
||||
import (
|
||||
"github.com/golang/glog"
|
||||
"github.com/prometheus/procfs"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
func (mc *memoryCollector) collect() {
|
||||
@@ -30,12 +30,12 @@ func (mc *memoryCollector) collect() {
|
||||
|
||||
proc, err := procfs.NewDefaultFS()
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to find /proc mount point: %v", err)
|
||||
klog.Errorf("Failed to find /proc mount point: %v", err)
|
||||
return
|
||||
}
|
||||
meminfo, err := proc.Meminfo()
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to retrieve memory stats: %v", err)
|
||||
klog.Errorf("Failed to retrieve memory stats: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package systemstatsmonitor
|
||||
|
||||
import (
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"github.com/shirou/gopsutil/v3/mem"
|
||||
)
|
||||
@@ -29,7 +29,7 @@ func (mc *memoryCollector) collect() {
|
||||
|
||||
meminfo, err := mem.VirtualMemory()
|
||||
if err != nil {
|
||||
glog.Errorf("cannot get windows memory metrics from GlobalMemoryStatusEx: %v", err)
|
||||
klog.Errorf("cannot get windows memory metrics from GlobalMemoryStatusEx: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
ssmtypes "k8s.io/node-problem-detector/pkg/systemstatsmonitor/types"
|
||||
"k8s.io/node-problem-detector/pkg/util/metrics"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/prometheus/procfs"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
type newInt64MetricFn func(metricID metrics.MetricID, viewName string, description string, unit string, aggregation metrics.Aggregation, tagNames []string) (metrics.Int64MetricInterface, error)
|
||||
@@ -208,12 +208,12 @@ func (nc *netCollector) mustRegisterMetric(metricID metrics.MetricID, descriptio
|
||||
aggregation metrics.Aggregation, exporter func(stat procfs.NetDevLine) int64) {
|
||||
metricConfig, ok := nc.config.MetricsConfigs[string(metricID)]
|
||||
if !ok {
|
||||
glog.Fatalf("Metric config `%q` not found", metricID)
|
||||
klog.Fatalf("Metric config `%q` not found", metricID)
|
||||
}
|
||||
err := nc.recorder.Register(metricID, metricConfig.DisplayName, description, unit,
|
||||
aggregation, []string{interfaceNameLabel}, exporter)
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed to initialize metric %q: %v", metricID, err)
|
||||
klog.Fatalf("Failed to initialize metric %q: %v", metricID, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,14 +221,14 @@ func (nc *netCollector) recordNetDev() {
|
||||
fs, err := procfs.NewFS(nc.procPath)
|
||||
stats, err := fs.NetDev()
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to retrieve net dev stat: %v", err)
|
||||
klog.Errorf("Failed to retrieve net dev stat: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
excludeInterfaceRegexp := nc.config.ExcludeInterfaceRegexp.R
|
||||
for iface, ifaceStats := range stats {
|
||||
if excludeInterfaceRegexp != nil && excludeInterfaceRegexp.MatchString(iface) {
|
||||
glog.V(6).Infof("Network interface %s matched exclude regexp %q, skipping recording", iface, excludeInterfaceRegexp)
|
||||
klog.V(6).Infof("Network interface %s matched exclude regexp %q, skipping recording", iface, excludeInterfaceRegexp)
|
||||
continue
|
||||
}
|
||||
tags := map[string]string{}
|
||||
@@ -282,7 +282,7 @@ func (r ifaceStatRecorder) RecordWithSameTags(stat procfs.NetDevLine, tags map[s
|
||||
for metricID, collector := range r.collectors {
|
||||
measurement := collector.exporter(stat)
|
||||
collector.metric.Record(tags, measurement)
|
||||
glog.V(6).Infof("Metric %q record measurement %d with tags %v", metricID, measurement, tags)
|
||||
klog.V(6).Infof("Metric %q record measurement %d with tags %v", metricID, measurement, tags)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog/v2"
|
||||
ssmtypes "k8s.io/node-problem-detector/pkg/systemstatsmonitor/types"
|
||||
"k8s.io/node-problem-detector/pkg/util/metrics"
|
||||
"k8s.io/node-problem-detector/pkg/util/metrics/system"
|
||||
@@ -48,7 +48,7 @@ func NewOsFeatureCollectorOrDie(osFeatureConfig *ssmtypes.OSFeatureStatsConfig,
|
||||
metrics.LastValue,
|
||||
[]string{featureLabel, valueLabel})
|
||||
if err != nil {
|
||||
glog.Fatalf("Error initializing metric for system/os_feature: %v", err)
|
||||
klog.Fatalf("Error initializing metric for system/os_feature: %v", err)
|
||||
}
|
||||
}
|
||||
return &oc
|
||||
@@ -104,7 +104,7 @@ func (ofc *osFeatureCollector) recordFeaturesFromModules(modules []system.Module
|
||||
var knownModules []system.Module
|
||||
f, err := os.ReadFile(ofc.config.KnownModulesConfigPath)
|
||||
if err != nil {
|
||||
glog.Warningf("Failed to read configuration file %s: %v",
|
||||
klog.Warningf("Failed to read configuration file %s: %v",
|
||||
ofc.config.KnownModulesConfigPath, err)
|
||||
}
|
||||
// When the knownModulesConfigPath is not set
|
||||
@@ -112,7 +112,7 @@ func (ofc *osFeatureCollector) recordFeaturesFromModules(modules []system.Module
|
||||
if f != nil {
|
||||
err = json.Unmarshal(f, &knownModules)
|
||||
if err != nil {
|
||||
glog.Warningf("Failed to retrieve known modules %v", err)
|
||||
klog.Warningf("Failed to retrieve known modules %v", err)
|
||||
}
|
||||
} else {
|
||||
knownModules = []system.Module{}
|
||||
@@ -152,12 +152,12 @@ func (ofc *osFeatureCollector) collect() {
|
||||
}
|
||||
cmdlineArgs, err := system.CmdlineArgs(filepath.Join(ofc.procPath, "/cmdline"))
|
||||
if err != nil {
|
||||
glog.Fatalf("Error retrieving cmdline args: %v", err)
|
||||
klog.Fatalf("Error retrieving cmdline args: %v", err)
|
||||
}
|
||||
ofc.recordFeaturesFromCmdline(cmdlineArgs)
|
||||
modules, err := system.Modules(filepath.Join(ofc.procPath, "/modules"))
|
||||
if err != nil {
|
||||
glog.Fatalf("Error retrieving kernel modules: %v", err)
|
||||
klog.Fatalf("Error retrieving kernel modules: %v", err)
|
||||
}
|
||||
ofc.recordFeaturesFromModules(modules)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"k8s.io/node-problem-detector/pkg/problemdaemon"
|
||||
ssmtypes "k8s.io/node-problem-detector/pkg/systemstatsmonitor/types"
|
||||
@@ -60,21 +60,21 @@ func NewSystemStatsMonitorOrDie(configPath string) types.Monitor {
|
||||
// Apply configurations.
|
||||
f, err := os.ReadFile(configPath)
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed to read configuration file %q: %v", configPath, err)
|
||||
klog.Fatalf("Failed to read configuration file %q: %v", configPath, err)
|
||||
}
|
||||
err = json.Unmarshal(f, &ssm.config)
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed to unmarshal configuration file %q: %v", configPath, err)
|
||||
klog.Fatalf("Failed to unmarshal configuration file %q: %v", configPath, err)
|
||||
}
|
||||
|
||||
err = ssm.config.ApplyConfiguration()
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed to apply configuration for %q: %v", configPath, err)
|
||||
klog.Fatalf("Failed to apply configuration for %q: %v", configPath, err)
|
||||
}
|
||||
|
||||
err = ssm.config.Validate()
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed to validate %s configuration %+v: %v", ssm.configPath, ssm.config, err)
|
||||
klog.Fatalf("Failed to validate %s configuration %+v: %v", ssm.configPath, ssm.config, err)
|
||||
}
|
||||
|
||||
if len(ssm.config.CPUConfig.MetricsConfigs) > 0 {
|
||||
@@ -105,7 +105,7 @@ func NewSystemStatsMonitorOrDie(configPath string) types.Monitor {
|
||||
}
|
||||
|
||||
func (ssm *systemStatsMonitor) Start() (<-chan *types.Status, error) {
|
||||
glog.Infof("Start system stats monitor %s", ssm.configPath)
|
||||
klog.Infof("Start system stats monitor %s", ssm.configPath)
|
||||
go ssm.monitorLoop()
|
||||
return nil, nil
|
||||
}
|
||||
@@ -118,7 +118,7 @@ func (ssm *systemStatsMonitor) monitorLoop() {
|
||||
|
||||
select {
|
||||
case <-ssm.tomb.Stopping():
|
||||
glog.Infof("System stats monitor stopped: %s", ssm.configPath)
|
||||
klog.Infof("System stats monitor stopped: %s", ssm.configPath)
|
||||
return
|
||||
default:
|
||||
ssm.cpuCollector.collect()
|
||||
@@ -139,13 +139,13 @@ func (ssm *systemStatsMonitor) monitorLoop() {
|
||||
ssm.osFeatureCollector.collect()
|
||||
ssm.netCollector.collect()
|
||||
case <-ssm.tomb.Stopping():
|
||||
glog.Infof("System stats monitor stopped: %s", ssm.configPath)
|
||||
klog.Infof("System stats monitor stopped: %s", ssm.configPath)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (ssm *systemStatsMonitor) Stop() {
|
||||
glog.Infof("Stop system stats monitor %s", ssm.configPath)
|
||||
klog.Infof("Stop system stats monitor %s", ssm.configPath)
|
||||
ssm.tomb.Stop()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user