collect docker mem
This commit is contained in:
parent
50d8b88e2e
commit
be84d84de1
|
@ -6,7 +6,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"regexp"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -38,7 +37,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
sizeRegex = regexp.MustCompile(`^(\d+(\.\d+)*) ?([kKmMgGtTpP])?[bB]?$`)
|
// sizeRegex = regexp.MustCompile(`^(\d+(\.\d+)*) ?([kKmMgGtTpP])?[bB]?$`)
|
||||||
containerStates = []string{"created", "restarting", "running", "removing", "paused", "exited", "dead"}
|
containerStates = []string{"created", "restarting", "running", "removing", "paused", "exited", "dead"}
|
||||||
containerMetricClasses = []string{"cpu", "network", "blkio"}
|
containerMetricClasses = []string{"cpu", "network", "blkio"}
|
||||||
)
|
)
|
||||||
|
@ -345,45 +344,45 @@ func (ins *Instance) gatherContainerInspect(container types.Container, slist *li
|
||||||
func (ins *Instance) parseContainerStats(stat *types.StatsJSON, slist *list.SafeList, tags map[string]string, ostype string) {
|
func (ins *Instance) parseContainerStats(stat *types.StatsJSON, slist *list.SafeList, tags map[string]string, ostype string) {
|
||||||
// memory
|
// memory
|
||||||
|
|
||||||
// memstats := []string{
|
memstats := []string{
|
||||||
// "active_anon",
|
// "active_anon",
|
||||||
// "active_file",
|
// "active_file",
|
||||||
// "cache",
|
"cache",
|
||||||
// "hierarchical_memory_limit",
|
// "hierarchical_memory_limit",
|
||||||
// "inactive_anon",
|
// "inactive_anon",
|
||||||
// "inactive_file",
|
// "inactive_file",
|
||||||
// "mapped_file",
|
// "mapped_file",
|
||||||
// "pgfault",
|
// "pgfault",
|
||||||
// "pgmajfault",
|
// "pgmajfault",
|
||||||
// "pgpgin",
|
// "pgpgin",
|
||||||
// "pgpgout",
|
// "pgpgout",
|
||||||
// "rss",
|
"rss",
|
||||||
// "rss_huge",
|
// "rss_huge",
|
||||||
// "total_active_anon",
|
// "total_active_anon",
|
||||||
// "total_active_file",
|
// "total_active_file",
|
||||||
// "total_cache",
|
"total_cache",
|
||||||
// "total_inactive_anon",
|
// "total_inactive_anon",
|
||||||
// "total_inactive_file",
|
// "total_inactive_file",
|
||||||
// "total_mapped_file",
|
// "total_mapped_file",
|
||||||
// "total_pgfault",
|
// "total_pgfault",
|
||||||
// "total_pgmajfault",
|
// "total_pgmajfault",
|
||||||
// "total_pgpgin",
|
// "total_pgpgin",
|
||||||
// "total_pgpgout",
|
// "total_pgpgout",
|
||||||
// "total_rss",
|
"total_rss",
|
||||||
// "total_rss_huge",
|
// "total_rss_huge",
|
||||||
// "total_unevictable",
|
// "total_unevictable",
|
||||||
// "total_writeback",
|
// "total_writeback",
|
||||||
// "unevictable",
|
// "unevictable",
|
||||||
// "writeback",
|
// "writeback",
|
||||||
// }
|
}
|
||||||
|
|
||||||
memfields := map[string]interface{}{}
|
memfields := map[string]interface{}{}
|
||||||
|
|
||||||
// for _, field := range memstats {
|
for _, field := range memstats {
|
||||||
// if value, ok := stat.MemoryStats.Stats[field]; ok {
|
if value, ok := stat.MemoryStats.Stats[field]; ok {
|
||||||
// memfields["docker_container_mem_"+field] = value
|
memfields["docker_container_mem_"+field] = value
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
if stat.MemoryStats.Failcnt != 0 {
|
if stat.MemoryStats.Failcnt != 0 {
|
||||||
memfields["docker_container_mem_fail_count"] = stat.MemoryStats.Failcnt
|
memfields["docker_container_mem_fail_count"] = stat.MemoryStats.Failcnt
|
||||||
|
|
Loading…
Reference in New Issue