Implement review feedback

This commit is contained in:
Daniel
2020-10-30 11:54:00 +01:00
parent ed00e1fe83
commit fa3f873c31
7 changed files with 64 additions and 28 deletions

View File

@@ -122,11 +122,12 @@ func CleanProcessStorage(activePIDs map[int]struct{}) {
}
// Process is inactive, start deletion process
lastSeen := p.GetLastSeen()
switch {
case p.LastSeen == 0:
// add last
p.LastSeen = time.Now().Unix()
case p.LastSeen > threshold:
case lastSeen == 0:
// add last seen timestamp
p.SetLastSeen(time.Now().Unix())
case lastSeen > threshold:
// within keep period
default:
// delete now

View File

@@ -59,9 +59,29 @@ type Process struct {
// Profile returns the assigned layered profile.
func (p *Process) Profile() *profile.LayeredProfile {
if p == nil {
return nil
}
return p.profile
}
// GetLastSeen returns the unix timestamp when the process was last seen.
func (p *Process) GetLastSeen() int64 {
p.Lock()
defer p.Unlock()
return p.LastSeen
}
// SetLastSeen sets the unix timestamp when the process was last seen.
func (p *Process) SetLastSeen(lastSeen int64) {
p.Lock()
defer p.Unlock()
p.LastSeen = lastSeen
}
// Strings returns a string representation of process.
func (p *Process) String() string {
if p == nil {