mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-05 10:41:36 +00:00
* Add gin-contrib/pprof dependency * Run pprof server on agent with --profiler flag * Add --profiler flag to cli * Fix error message * Print cpu usage percentage * measure cpu of current pid instead of globaly on the system * Add scripts to plot performance * Plot packetsCount in analysis * Concat to DataFrame * Plot in turbo colorscheme * Make COLORMAP const * Fix rss units * Reduce code repetition by adding function for plotting * Allow grouping based on filenames * Temporary: Marked with comments where to disable code for experiments * Add newline at end of file * Add tap.cpuprofile flag. Change memprofile flag to tap.memprofile * create tapper modes for debugging using env vars * Fix rss plot units (MB instead of bytes) * Remove comment * Add info to plot script * Remove tap.cpumemprofile. Rename tap.memprofile to memprofile * Remove unused import * Remove whitespaces Co-authored-by: M. Mert Yıldıran <mehmet@up9.com> * Remove whitespaces Co-authored-by: M. Mert Yıldıran <mehmet@up9.com> * Remove whitespaces Co-authored-by: M. Mert Yıldıran <mehmet@up9.com> * Remove whitespaces Co-authored-by: M. Mert Yıldıran <mehmet@up9.com> * Remove whitespaces Co-authored-by: M. Mert Yıldıran <mehmet@up9.com> * Remove whitespaces Co-authored-by: M. Mert Yıldıran <mehmet@up9.com> * Rename debug env vars * Create package for debug env vars, read each env var once * Run go mod tidy * Increment MatchedPairs before emitting * Only count cores once * Count virtual and physical cores * Add dbgctl replace in cli * Fix lint: Check return values * Add tap/dbgctl to test-lint make rule * Replace tap/dbgctl in all modules * #run_acceptance_tests * Copy dbgctl module to docker image * Debug/profile tapper benchmark (#1093) * add mizu debug env to avoid all extensions * add readme + run_tapper_benchmark.sh * temporary change branch name * fix readme * fix MIZU_BENCHMARK_CLIENTS_COUNT env * change tap target to tcp stream * track live tcp streams * pr fixes * rename tapperPacketsCount to ignored_packets_count * change mizu tapper to mizu debugg Co-authored-by: David Levanon <dvdlevanon@gmail.com> Co-authored-by: M. Mert Yıldıran <mehmet@up9.com>
87 lines
2.6 KiB
Go
87 lines
2.6 KiB
Go
package api
|
|
|
|
import (
|
|
"sync/atomic"
|
|
"time"
|
|
)
|
|
|
|
type AppStats struct {
|
|
StartTime time.Time `json:"-"`
|
|
ProcessedBytes uint64 `json:"processedBytes"`
|
|
PacketsCount uint64 `json:"packetsCount"`
|
|
TcpPacketsCount uint64 `json:"tcpPacketsCount"`
|
|
IgnoredPacketsCount uint64 `json:"ignoredPacketsCount"`
|
|
ReassembledTcpPayloadsCount uint64 `json:"reassembledTcpPayloadsCount"`
|
|
TlsConnectionsCount uint64 `json:"tlsConnectionsCount"`
|
|
MatchedPairs uint64 `json:"matchedPairs"`
|
|
DroppedTcpStreams uint64 `json:"droppedTcpStreams"`
|
|
LiveTcpStreams uint64 `json:"liveTcpStreams"`
|
|
}
|
|
|
|
func (as *AppStats) IncMatchedPairs() {
|
|
atomic.AddUint64(&as.MatchedPairs, 1)
|
|
}
|
|
|
|
func (as *AppStats) IncDroppedTcpStreams() {
|
|
atomic.AddUint64(&as.DroppedTcpStreams, 1)
|
|
}
|
|
|
|
func (as *AppStats) IncPacketsCount() uint64 {
|
|
atomic.AddUint64(&as.PacketsCount, 1)
|
|
return as.PacketsCount
|
|
}
|
|
|
|
func (as *AppStats) IncTcpPacketsCount() {
|
|
atomic.AddUint64(&as.TcpPacketsCount, 1)
|
|
}
|
|
|
|
func (as *AppStats) IncIgnoredPacketsCount() {
|
|
atomic.AddUint64(&as.IgnoredPacketsCount, 1)
|
|
}
|
|
|
|
func (as *AppStats) IncReassembledTcpPayloadsCount() {
|
|
atomic.AddUint64(&as.ReassembledTcpPayloadsCount, 1)
|
|
}
|
|
|
|
func (as *AppStats) IncTlsConnectionsCount() {
|
|
atomic.AddUint64(&as.TlsConnectionsCount, 1)
|
|
}
|
|
|
|
func (as *AppStats) IncLiveTcpStreams() {
|
|
atomic.AddUint64(&as.LiveTcpStreams, 1)
|
|
}
|
|
|
|
func (as *AppStats) DecLiveTcpStreams() {
|
|
atomic.AddUint64(&as.LiveTcpStreams, ^uint64(0))
|
|
}
|
|
|
|
func (as *AppStats) UpdateProcessedBytes(size uint64) {
|
|
atomic.AddUint64(&as.ProcessedBytes, size)
|
|
}
|
|
|
|
func (as *AppStats) SetStartTime(startTime time.Time) {
|
|
as.StartTime = startTime
|
|
}
|
|
|
|
func (as *AppStats) DumpStats() *AppStats {
|
|
currentAppStats := &AppStats{StartTime: as.StartTime}
|
|
|
|
currentAppStats.ProcessedBytes = resetUint64(&as.ProcessedBytes)
|
|
currentAppStats.PacketsCount = resetUint64(&as.PacketsCount)
|
|
currentAppStats.TcpPacketsCount = resetUint64(&as.TcpPacketsCount)
|
|
currentAppStats.IgnoredPacketsCount = resetUint64(&as.IgnoredPacketsCount)
|
|
currentAppStats.ReassembledTcpPayloadsCount = resetUint64(&as.ReassembledTcpPayloadsCount)
|
|
currentAppStats.TlsConnectionsCount = resetUint64(&as.TlsConnectionsCount)
|
|
currentAppStats.MatchedPairs = resetUint64(&as.MatchedPairs)
|
|
currentAppStats.DroppedTcpStreams = resetUint64(&as.DroppedTcpStreams)
|
|
currentAppStats.LiveTcpStreams = as.LiveTcpStreams
|
|
|
|
return currentAppStats
|
|
}
|
|
|
|
func resetUint64(ref *uint64) (val uint64) {
|
|
val = atomic.LoadUint64(ref)
|
|
atomic.StoreUint64(ref, 0)
|
|
return
|
|
}
|