diff --git a/assets/status.html b/assets/status.html index 172c5a1..e05cf20 100644 --- a/assets/status.html +++ b/assets/status.html @@ -15,17 +15,17 @@ Name Last Active + Stop Delay Rx Tx - Stop Delay {{range $val := .Active}} {{$val.Name}} - {{$val.LastActive.Format "2006-01-02 15:04:05"}} + {{$val.LastActiveAge}} + {{$val.StopDelay}} {{$val.Rx}} {{$val.Tx}} - {{$val.StopDelay}} {{end}} diff --git a/config.yaml b/config.yaml index b937609..0bf4fc1 100644 --- a/config.yaml +++ b/config.yaml @@ -8,5 +8,4 @@ pollfreq: 10s statushost: "" verbose: false -labels: - prefix: lazyloader \ No newline at end of file +labelprefix: lazyloader \ No newline at end of file diff --git a/pkg/config/config.go b/pkg/config/config.go index e1f13ce..32fb862 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -22,9 +22,7 @@ type ConfigModel struct { Verbose bool // Debug-level logging - Labels struct { - Prefix string `mapstructure:"prefix"` - } `mapstructure:"labels"` + LabelPrefix string } var Model *ConfigModel = new(ConfigModel) @@ -48,5 +46,5 @@ func init() { } func SubLabel(name string) string { - return Model.Labels.Prefix + "." + name + return Model.LabelPrefix + "." + name } diff --git a/pkg/service/container.go b/pkg/service/container.go index b05b436..fce36e9 100644 --- a/pkg/service/container.go +++ b/pkg/service/container.go @@ -62,6 +62,10 @@ func (s *ContainerState) LastActive() time.Time { return s.lastActivity } +func (s *ContainerState) LastActiveAge() string { + return time.Since(s.lastActivity).Round(time.Second).String() +} + func (s *ContainerState) Rx() int64 { return s.lastRecv } diff --git a/pkg/service/service.go b/pkg/service/service.go index 20b70cd..79d260b 100644 --- a/pkg/service/service.go +++ b/pkg/service/service.go @@ -257,7 +257,7 @@ func (s *Core) findContainerByHostname(ctx context.Context, hostname string) (*t // Finds all containers on node that are labeled with lazyloader config func (s *Core) findAllLazyloadContainers(ctx context.Context, includeStopped bool) ([]types.Container, error) { filters := filters.NewArgs() - filters.Add("label", config.Model.Labels.Prefix) + filters.Add("label", config.Model.LabelPrefix) return s.client.ContainerList(ctx, types.ContainerListOptions{ All: includeStopped,