mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 09:18:59 +00:00
dfa2d83855
Replaces the existing calculation that uses a global online interval. This method was lacking due to the fact that different hosts may have different checkin intervals set. The new calculation uses `min(distributed_interval, config_tls_refresh) + 30` as the interval. This is calculated with the stored values for each host. Closes #1321
62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
package kolide
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type TargetSearchResults struct {
|
|
Hosts []Host
|
|
Labels []Label
|
|
}
|
|
|
|
// TargetMetrics contains information about the online status of a set of
|
|
// hosts.
|
|
type TargetMetrics struct {
|
|
// TotalHosts is the total hosts in any status. It should equal
|
|
// OnlineHosts + OfflineHosts + MissingInActionHosts.
|
|
TotalHosts uint `db:"total"`
|
|
// OnlineHosts is the count of hosts that have checked in within their
|
|
// expected checkin interval (based on the configuration interval
|
|
// values, see Host.Status()).
|
|
OnlineHosts uint `db:"online"`
|
|
// OfflineHosts is the count of hosts that have not checked in within
|
|
// their expected interval.
|
|
OfflineHosts uint `db:"offline"`
|
|
// MissingInActionHosts is the count of hosts that have not checked in
|
|
// within the last 30 days.
|
|
MissingInActionHosts uint `db:"mia"`
|
|
// NewHosts is the count of hosts that have enrolled in the last 24
|
|
// hours.
|
|
NewHosts uint `db:"new"`
|
|
}
|
|
|
|
type TargetService interface {
|
|
// SearchTargets will accept a search query, a slice of IDs of hosts to omit,
|
|
// and a slice of IDs of labels to omit, and it will return a set of targets
|
|
// (hosts and label) which match the supplied search query.
|
|
SearchTargets(ctx context.Context, query string, selectedHostIDs []uint, selectedLabelIDs []uint) (*TargetSearchResults, error)
|
|
|
|
// CountHostsInTargets returns the metrics of the hosts in the provided
|
|
// label and explicit host IDs.
|
|
CountHostsInTargets(ctx context.Context, hostIDs []uint, labelIDs []uint) (*TargetMetrics, error)
|
|
}
|
|
|
|
type TargetStore interface {
|
|
// CountHostsInTargets returns the metrics of the hosts in the provided
|
|
// label and explicit host IDs.
|
|
CountHostsInTargets(hostIDs []uint, labelIDs []uint, now time.Time) (TargetMetrics, error)
|
|
}
|
|
|
|
type TargetType int
|
|
|
|
const (
|
|
TargetLabel TargetType = iota
|
|
TargetHost
|
|
)
|
|
|
|
type Target struct {
|
|
Type TargetType
|
|
TargetID uint
|
|
}
|