Serialize returns the collected statistics. After return the stats, the Events are emptied, to keep collecting more stats and not miss connections.
()
| 259 | // After return the stats, the Events are emptied, to keep collecting more stats |
| 260 | // and not miss connections. |
| 261 | func (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 | } |
nothing calls this directly
no test coverage detected