generated from demus/golang-rpm
111 lines
4.6 KiB
Diff
111 lines
4.6 KiB
Diff
Index: cmd/ctr/commands/tasks/metrics.go
|
|
IDEA additional info:
|
|
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
|
<+>UTF-8
|
|
===================================================================
|
|
diff --git a/cmd/ctr/commands/tasks/metrics.go b/cmd/ctr/commands/tasks/metrics.go
|
|
--- a/cmd/ctr/commands/tasks/metrics.go
|
|
+++ b/cmd/ctr/commands/tasks/metrics.go (date 1732200040000)
|
|
@@ -23,7 +23,6 @@
|
|
"os"
|
|
"text/tabwriter"
|
|
|
|
- wstats "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats"
|
|
v1 "github.com/containerd/cgroups/v3/cgroup1/stats"
|
|
v2 "github.com/containerd/cgroups/v3/cgroup2/stats"
|
|
"github.com/containerd/containerd/cmd/ctr/commands"
|
|
@@ -75,8 +74,6 @@
|
|
data = &v1.Metrics{}
|
|
case typeurl.Is(metric.Data, (*v2.Metrics)(nil)):
|
|
data = &v2.Metrics{}
|
|
- case typeurl.Is(metric.Data, (*wstats.Statistics)(nil)):
|
|
- data = &wstats.Statistics{}
|
|
default:
|
|
return errors.New("cannot convert metric data to cgroups.Metrics or windows.Statistics")
|
|
}
|
|
@@ -94,11 +91,6 @@
|
|
printCgroupMetricsTable(w, v)
|
|
case *v2.Metrics:
|
|
printCgroup2MetricsTable(w, v)
|
|
- case *wstats.Statistics:
|
|
- if err := printWindowsStats(w, v); err != nil {
|
|
- return fmt.Errorf("cannot convert metrics data from windows.Statistics: %w", err)
|
|
- }
|
|
- }
|
|
return w.Flush()
|
|
case formatJSON:
|
|
marshaledJSON, err := json.MarshalIndent(data, "", " ")
|
|
@@ -151,72 +143,3 @@
|
|
fmt.Fprintf(w, "memory.swap_limit\t%v\t\n", data.Memory.SwapLimit)
|
|
}
|
|
}
|
|
-
|
|
-func printWindowsStats(w *tabwriter.Writer, windowsStats *wstats.Statistics) error {
|
|
- if windowsStats.GetLinux() != nil {
|
|
- var stats v1.Metrics
|
|
-
|
|
- // It cannot be casted to v1.Metrics since windowsStats is still generated by gogo/protobuf.
|
|
- linux := windowsStats.GetLinux()
|
|
-
|
|
- // But Marshal/Unmarshal works because the underlying protobuf message is compatible.
|
|
- data, err := linux.Marshal()
|
|
- if err != nil {
|
|
- return err
|
|
- }
|
|
- err = proto.Unmarshal(data, &stats)
|
|
- if err != nil {
|
|
- return err
|
|
- }
|
|
-
|
|
- printCgroupMetricsTable(w, &stats)
|
|
- } else if windowsStats.GetWindows() != nil {
|
|
- printWindowsContainerStatistics(w, windowsStats.GetWindows())
|
|
- }
|
|
- // Print VM stats if its isolated
|
|
- if windowsStats.VM != nil {
|
|
- printWindowsVMStatistics(w, windowsStats.VM)
|
|
- }
|
|
- return nil
|
|
-}
|
|
-
|
|
-func printWindowsContainerStatistics(w *tabwriter.Writer, stats *wstats.WindowsContainerStatistics) {
|
|
- fmt.Fprintf(w, "METRIC\tVALUE\t\n")
|
|
- fmt.Fprintf(w, "timestamp\t%s\t\n", stats.Timestamp)
|
|
- fmt.Fprintf(w, "start_time\t%s\t\n", stats.ContainerStartTime)
|
|
- fmt.Fprintf(w, "uptime_ns\t%d\t\n", stats.UptimeNS)
|
|
- if stats.Processor != nil {
|
|
- fmt.Fprintf(w, "cpu.total_runtime_ns\t%d\t\n", stats.Processor.TotalRuntimeNS)
|
|
- fmt.Fprintf(w, "cpu.runtime_user_ns\t%d\t\n", stats.Processor.RuntimeUserNS)
|
|
- fmt.Fprintf(w, "cpu.runtime_kernel_ns\t%d\t\n", stats.Processor.RuntimeKernelNS)
|
|
- }
|
|
- if stats.Memory != nil {
|
|
- fmt.Fprintf(w, "memory.commit_bytes\t%d\t\n", stats.Memory.MemoryUsageCommitBytes)
|
|
- fmt.Fprintf(w, "memory.commit_peak_bytes\t%d\t\n", stats.Memory.MemoryUsageCommitPeakBytes)
|
|
- fmt.Fprintf(w, "memory.private_working_set_bytes\t%d\t\n", stats.Memory.MemoryUsagePrivateWorkingSetBytes)
|
|
- }
|
|
- if stats.Storage != nil {
|
|
- fmt.Fprintf(w, "storage.read_count_normalized\t%d\t\n", stats.Storage.ReadCountNormalized)
|
|
- fmt.Fprintf(w, "storage.read_size_bytes\t%d\t\n", stats.Storage.ReadSizeBytes)
|
|
- fmt.Fprintf(w, "storage.write_count_normalized\t%d\t\n", stats.Storage.WriteCountNormalized)
|
|
- fmt.Fprintf(w, "storage.write_size_bytes\t%d\t\n", stats.Storage.WriteSizeBytes)
|
|
- }
|
|
-}
|
|
-
|
|
-func printWindowsVMStatistics(w *tabwriter.Writer, stats *wstats.VirtualMachineStatistics) {
|
|
- fmt.Fprintf(w, "METRIC\tVALUE\t\n")
|
|
- if stats.Processor != nil {
|
|
- fmt.Fprintf(w, "vm.cpu.total_runtime_ns\t%d\t\n", stats.Processor.TotalRuntimeNS)
|
|
- }
|
|
- if stats.Memory != nil {
|
|
- fmt.Fprintf(w, "vm.memory.working_set_bytes\t%d\t\n", stats.Memory.WorkingSetBytes)
|
|
- fmt.Fprintf(w, "vm.memory.virtual_node_count\t%d\t\n", stats.Memory.VirtualNodeCount)
|
|
- fmt.Fprintf(w, "vm.memory.available\t%d\t\n", stats.Memory.VmMemory.AvailableMemory)
|
|
- fmt.Fprintf(w, "vm.memory.available_buffer\t%d\t\n", stats.Memory.VmMemory.AvailableMemoryBuffer)
|
|
- fmt.Fprintf(w, "vm.memory.reserved\t%d\t\n", stats.Memory.VmMemory.ReservedMemory)
|
|
- fmt.Fprintf(w, "vm.memory.assigned\t%d\t\n", stats.Memory.VmMemory.AssignedMemory)
|
|
- fmt.Fprintf(w, "vm.memory.slp_active\t%t\t\n", stats.Memory.VmMemory.SlpActive)
|
|
- fmt.Fprintf(w, "vm.memory.balancing_enabled\t%t\t\n", stats.Memory.VmMemory.BalancingEnabled)
|
|
- fmt.Fprintf(w, "vm.memory.dm_operation_in_progress\t%t\t\n", stats.Memory.VmMemory.DmOperationInProgress)
|
|
- }
|
|
-}
|