Skip to content

Commit

Permalink
pkg/rpcserver: export modules stat
Browse files Browse the repository at this point in the history
We have a /modules link in the manager, but it's not exposed anywhere.
Add a stat with this link.
  • Loading branch information
dvyukov committed Nov 7, 2024
1 parent 6410b21 commit 179b040
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/rpcserver/rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,31 @@ type Stats struct {
StatExecs *stat.Val
StatNumFuzzing *stat.Val
StatVMRestarts *stat.Val
StatModules *stat.Val
}

func NewStats() Stats {
return NewNamedStats("")
}

func NewNamedStats(name string) Stats {
suffix := name
if suffix != "" {
suffix = " [" + suffix + "]"
}
vmsLink := "/vms"
suffix, linkSuffix := "", ""
if name != "" {
vmsLink += "?pool=" + url.QueryEscape(name)
suffix = " [" + name + "]"
linkSuffix = "?pool=" + url.QueryEscape(name)
}
return Stats{
StatExecs: stat.New("exec total"+suffix, "Total test program executions",
stat.Console, stat.Rate{}, stat.Prometheus("syz_exec_total"+name),
),
StatNumFuzzing: stat.New("fuzzing VMs"+suffix,
"Number of VMs that are currently fuzzing", stat.Graph("fuzzing VMs"),
stat.Link(vmsLink),
stat.Link("/vms"+linkSuffix),
),
StatVMRestarts: stat.New("vm restarts"+suffix, "Total number of VM starts",
stat.Rate{}, stat.NoGraph),
StatModules: stat.New("modules"+suffix, "Number of loaded kernel modules",
stat.NoGraph, stat.Link("/modules"+linkSuffix)),
}
}

Expand Down Expand Up @@ -306,6 +306,7 @@ func (serv *server) handleMachineInfo(infoReq *flatrpc.InfoRequestRawT) (handsha
return handshakeResult{}, errors.New("machine check failed")
}
serv.infoOnce.Do(func() {
serv.StatModules.Add(len(modules))
serv.canonicalModules = cover.NewCanonicalizer(modules, serv.cfg.Cover)
serv.coverFilter = serv.mgr.CoverageFilter(modules)
globs := make(map[string][]string)
Expand Down

0 comments on commit 179b040

Please sign in to comment.