mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-06 12:59:13 +00:00
37 lines
696 B
Go
37 lines
696 B
Go
package providers
|
|
|
|
import (
|
|
"reflect"
|
|
"time"
|
|
)
|
|
|
|
type GeneralStats struct {
|
|
EntriesCount int
|
|
EntriesVolumeInGB float64
|
|
FirstEntryTimestamp int
|
|
LastEntryTimestamp int
|
|
}
|
|
|
|
var generalStats = GeneralStats{}
|
|
|
|
func ResetGeneralStats() {
|
|
generalStats = GeneralStats{}
|
|
}
|
|
|
|
func GetGeneralStats() GeneralStats {
|
|
return generalStats
|
|
}
|
|
|
|
func EntryAdded(size int) {
|
|
generalStats.EntriesCount++
|
|
generalStats.EntriesVolumeInGB += float64(size) / (1 << 30)
|
|
|
|
currentTimestamp := int(time.Now().Unix())
|
|
|
|
if reflect.Value.IsZero(reflect.ValueOf(generalStats.FirstEntryTimestamp)) {
|
|
generalStats.FirstEntryTimestamp = currentTimestamp
|
|
}
|
|
|
|
generalStats.LastEntryTimestamp = currentTimestamp
|
|
}
|