Skip to content

Commit

Permalink
router: extend packet processing metrics (#4422)
Browse files Browse the repository at this point in the history
Improve metrics for router packet processing:

* Classify packets by size bucket: log2(size)
* Classify packets by traffic type: incoming, outgoing, as-transit-in/out, br-transit.
* Add process-level on-cpu and sleep time accounting
  • Loading branch information
jiceatscion authored Oct 30, 2023
1 parent a82e4fb commit fa43782
Show file tree
Hide file tree
Showing 15 changed files with 813 additions and 209 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ _build
node_modules

# gobra
#######
*.vpr
tmp/
logger.log

# emacs backup files
####################
*~
12 changes: 8 additions & 4 deletions demo/file_transfer/file_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,15 @@ def _get_br_traffic(self, endpoint):
conn.request('GET', '/metrics')
resp = conn.getresponse()
metrics = resp.read().decode('utf-8')
total = 0
regexp = re.compile(r"""^router_input_bytes_total{.*interface="internal".*\s(.*)$""")
for line in metrics.splitlines():
m = re.search(r"""^router_input_bytes_total{interface="internal".*\s(.*)$""", line)
if m is not None:
return float(m.group(1)) / 1024 / 1024
return None
try:
m = regexp.search(line)
total += float(m.group(1)) / 1024 / 1024
except (TypeError, AttributeError, ValueError):
pass
return total

def setup_prepare(self):
print("setting up the infrastructure")
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ require (
github.com/pelletier/go-toml v1.9.5
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/procfs v0.12.0
github.com/quic-go/quic-go v0.38.1
github.com/sergi/go-diff v1.3.1
github.com/smartystreets/goconvey v1.7.2
Expand All @@ -44,7 +45,7 @@ require (
go4.org/netipx v0.0.0-20230125063823-8449b0a6169f
golang.org/x/crypto v0.6.0
golang.org/x/net v0.10.0
golang.org/x/sync v0.2.0
golang.org/x/sync v0.3.0
golang.org/x/tools v0.9.1
google.golang.org/grpc v1.57.2
google.golang.org/grpc/examples v0.0.0-20230222033013-5353eaa44095
Expand Down Expand Up @@ -97,7 +98,6 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/quic-go/qtls-go1-20 v0.3.3 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand All @@ -112,7 +112,7 @@ require (
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230815205213-6bfd019c3878 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/quic-go/qtls-go1-20 v0.3.3 h1:17/glZSLI9P9fDAeyCHBFSWSqJcwx1byhLwP5eUIDCM=
github.com/quic-go/qtls-go1-20 v0.3.3/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
github.com/quic-go/quic-go v0.38.1 h1:M36YWA5dEhEeT+slOu/SwMEucbYd0YFidxG3KlGPZaE=
Expand Down Expand Up @@ -564,8 +564,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -617,8 +617,8 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
12 changes: 6 additions & 6 deletions go_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1012,8 +1012,8 @@ def go_deps():
go_repository(
name = "com_github_prometheus_procfs",
importpath = "github.com/prometheus/procfs",
sum = "h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=",
version = "v0.8.0",
sum = "h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=",
version = "v0.12.0",
)
go_repository(
name = "com_github_quic_go_qpack",
Expand Down Expand Up @@ -1482,14 +1482,14 @@ def go_deps():
go_repository(
name = "org_golang_x_sync",
importpath = "golang.org/x/sync",
sum = "h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=",
version = "v0.2.0",
sum = "h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=",
version = "v0.3.0",
)
go_repository(
name = "org_golang_x_sys",
importpath = "golang.org/x/sys",
sum = "h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=",
version = "v0.8.0",
sum = "h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=",
version = "v0.12.0",
)
go_repository(
name = "org_golang_x_term",
Expand Down
60 changes: 60 additions & 0 deletions pkg/private/processmetrics/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
load("//tools/lint:go.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = [
"processmetrics_linux.go",
"processmetrics_other.go",
],
importpath = "github.com/scionproto/scion/pkg/private/processmetrics",
visibility = ["//visibility:public"],
deps = select({
"@io_bazel_rules_go//go/platform:aix": [
"//pkg/private/serrors:go_default_library",
],
"@io_bazel_rules_go//go/platform:android": [
"//pkg/private/serrors:go_default_library",
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_prometheus_procfs//:go_default_library",
],
"@io_bazel_rules_go//go/platform:darwin": [
"//pkg/private/serrors:go_default_library",
],
"@io_bazel_rules_go//go/platform:dragonfly": [
"//pkg/private/serrors:go_default_library",
],
"@io_bazel_rules_go//go/platform:freebsd": [
"//pkg/private/serrors:go_default_library",
],
"@io_bazel_rules_go//go/platform:illumos": [
"//pkg/private/serrors:go_default_library",
],
"@io_bazel_rules_go//go/platform:ios": [
"//pkg/private/serrors:go_default_library",
],
"@io_bazel_rules_go//go/platform:js": [
"//pkg/private/serrors:go_default_library",
],
"@io_bazel_rules_go//go/platform:linux": [
"//pkg/private/serrors:go_default_library",
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_prometheus_procfs//:go_default_library",
],
"@io_bazel_rules_go//go/platform:netbsd": [
"//pkg/private/serrors:go_default_library",
],
"@io_bazel_rules_go//go/platform:openbsd": [
"//pkg/private/serrors:go_default_library",
],
"@io_bazel_rules_go//go/platform:plan9": [
"//pkg/private/serrors:go_default_library",
],
"@io_bazel_rules_go//go/platform:solaris": [
"//pkg/private/serrors:go_default_library",
],
"@io_bazel_rules_go//go/platform:windows": [
"//pkg/private/serrors:go_default_library",
],
"//conditions:default": [],
}),
)
Loading

0 comments on commit fa43782

Please sign in to comment.