Some config and display tweaks

This commit is contained in:
Christopher LaPointe
2023-05-24 17:52:40 -04:00
parent c0ec096bd5
commit 97f3805899
5 changed files with 11 additions and 10 deletions

View File

@@ -15,17 +15,17 @@
<tr>
<th>Name</th>
<th>Last Active</th>
<th>Stop Delay</th>
<th>Rx</th>
<th>Tx</th>
<th>Stop Delay</th>
</tr>
{{range $val := .Active}}
<tr>
<td>{{$val.Name}}</td>
<td>{{$val.LastActive.Format "2006-01-02 15:04:05"}}</td>
<td>{{$val.LastActiveAge}}</td>
<td>{{$val.StopDelay}}</td>
<td>{{$val.Rx}}</td>
<td>{{$val.Tx}}</td>
<td>{{$val.StopDelay}}</td>
</tr>
{{end}}
</table>

View File

@@ -8,5 +8,4 @@ pollfreq: 10s
statushost: ""
verbose: false
labels:
prefix: lazyloader
labelprefix: lazyloader

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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,