Skip to content

Commit

Permalink
Remove unused parsed output from docker top
Browse files Browse the repository at this point in the history
This removes the need to parse all output from docker top, preventing
parsing errors where format of columns may differ from host to host.

**Warning:** This could potentially break client code, if any client
actively relies on the public method:

- IContainerService.DockerHost.Top(...).Processes.Rows
  • Loading branch information
Rory-Reid committed Sep 28, 2023
1 parent ea6ec51 commit 4213c3e
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions Ductus.FluentDocker/Model/Containers/ProcessRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,7 @@ public sealed class ProcessRow
private const string StartConst = "START";
private const string CmdConstWin = "Name";

public string User { get; internal set; }
public long Pid { get; internal set; }
public long ProcessPid { get; internal set; }
public string Command { get; internal set; }
public string Tty { get; internal set; }
public TimeSpan Time { get; internal set; }
public TimeSpan Started { get; internal set; }
public string Status { get; internal set; }
public float PercentCpuUtilization { get; internal set; }
public TimeSpan Cpu { get; private set; }
public float PercentMemoryUtilization { get; internal set; }
public IList<string> FullRow { get; internal set; }

internal static ProcessRow ToRow(IList<string> columns, IList<string> fullRow)
Expand All @@ -53,39 +43,6 @@ internal static ProcessRow ToRow(IList<string> columns, IList<string> fullRow)
case CmdConstWin:
row.Command = fullRow[i];
break;
case UserConst:
case UidConst:
row.User = fullRow[i];
break;
case PidConst:
row.Pid = long.Parse(fullRow[i]);
break;
case PpidConst:
row.ProcessPid = long.Parse(fullRow[i]);
break;
case StartConst:
case StartTimeConst:
row.Started = TimeSpan.Parse(fullRow[i]);
break;
case TimeConst:
row.Time = TimeSpan.Parse(fullRow[i]);
break;
case TerminalConst:
row.Tty = fullRow[i];
break;
case StatConst:
row.Status = fullRow[i];
break;
case CpuTime:
if (TimeSpan.TryParse(fullRow[i], out var cpuTime))
row.Cpu = cpuTime;
break;
case PercentCpuConst:
row.PercentCpuUtilization = float.Parse(fullRow[i], CultureInfo.InvariantCulture.NumberFormat);
break;
case PercentMemoryConst:
row.PercentMemoryUtilization = float.Parse(fullRow[i], CultureInfo.InvariantCulture.NumberFormat);
break;
}
}

Expand Down

0 comments on commit 4213c3e

Please sign in to comment.