MCPcopy
hub / github.com/evilsocket/opensnitch / Serialize

Method Serialize

daemon/statistics/stats.go:261–289  ·  view source on GitHub ↗

Serialize returns the collected statistics. After return the stats, the Events are emptied, to keep collecting more stats and not miss connections.

()

Source from the content-addressed store, hash-verified

259// After return the stats, the Events are emptied, to keep collecting more stats
260// and not miss connections.
261func (s *Statistics) Serialize() *protocol.Statistics {
262 s.Lock()
263 defer s.emptyStats()
264 defer s.Unlock()
265
266 if !s.newEvents {
267 return nil
268 }
269
270 return &protocol.Statistics{
271 DaemonVersion: core.Version,
272 Rules: uint64(s.rules.NumRules()),
273 Uptime: uint64(time.Since(s.Started).Seconds()),
274 DnsResponses: uint64(s.DNSResponses),
275 Connections: uint64(s.Connections),
276 Ignored: uint64(s.Ignored),
277 Accepted: uint64(s.Accepted),
278 Dropped: uint64(s.Dropped),
279 RuleHits: uint64(s.RuleHits),
280 RuleMisses: uint64(s.RuleMisses),
281 Events: s.serializeEvents(),
282 ByProto: s.ByProto,
283 ByAddress: s.ByAddress,
284 ByHost: s.ByHost,
285 ByPort: s.ByPort,
286 ByUid: s.ByUID,
287 ByExecutable: s.ByExecutable,
288 }
289}

Callers

nothing calls this directly

Calls 5

emptyStatsMethod · 0.95
serializeEventsMethod · 0.95
LockMethod · 0.80
UnlockMethod · 0.80
NumRulesMethod · 0.80

Tested by

no test coverage detected