package main import ( "log" "github.com/rosti-cz/node-api/apps" "github.com/rosti-cz/node-api/docker" ) // gatherContainerStats gathers information about containers and saves it into the database func gatherContainerStats() error { appList, err := apps.List() if err != nil { return err } for _, app := range *appList { container := docker.Container{ App: &app, } state, err := container.GetState() if err != nil { log.Println("STATS ERROR:", err.Error()) continue } err = apps.UpdateState( app.Name, state.State, state.CPUUsage, state.MemoryUsage, state.DiskUsageBytes, state.DiskUsageInodes, ) if err != nil { log.Println("STATS ERROR:", err.Error()) } } return nil }