Skip to content

Add network protocol stats to the ContainerStats - #963

Merged
JaewonHur merged 3 commits into
apple:mainfrom
JaewonHur:network-protocol-stats
Oct 13, 2026
Merged

JaewonHur merged 3 commits into
apple:mainfrom
JaewonHur:network-protocol-stats

Conversation

@JaewonHur

Copy link
Copy Markdown
Contributor
  • Add protocols field in ContainerStats proto.

  • Containers share the network namespace, so the reported stats are all identical.

  • Get received/transmitted packets and received/transmitted bytes of the protocols tcp, udp, icmp and ip from Snmp and netstat Linux service. stats of ip are for entire packets and bytes. Bytes are populated only for ip now.

    • Read /proc/<container-pid>/net/snmp, and /proc/<container-pid>/net/netstat and parses the tables.
    • Initialize to 0 if not there.

* Add `protocols` field in `ContainerStats` proto.
* Containers share the network namespace, so the reported stats are all
  identical.
* Get received/transmitted packets and received/transmitted bytes of the
  protocols tcp, udp, icmp and ip from Snmp and netstat Linux service.
  stats of ip are for entire packets and bytes. Bytes are populated only
  for ip now.

  * Read `/proc/<container-pid>/net/snmp`, and
    `/proc/<container-pid>/net/netstat` and parses the tables.
  * Initialize to 0 if not there.
Comment thread Sources/ContainerizationOS/Linux/ProcNetSnmp.swift
return .init()
}

public func containerStatistics(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who calls this stats?

@JaewonHur
JaewonHur merged commit 109beaf into apple:main Oct 13, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants