github.com/demonoid81/containerd@v1.3.4/metrics/cgroups/hugetlb.go (about) 1 // +build linux 2 3 /* 4 Copyright The containerd Authors. 5 6 Licensed under the Apache License, Version 2.0 (the "License"); 7 you may not use this file except in compliance with the License. 8 You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 See the License for the specific language governing permissions and 16 limitations under the License. 17 */ 18 19 package cgroups 20 21 import ( 22 v1 "github.com/containerd/containerd/metrics/types/v1" 23 metrics "github.com/docker/go-metrics" 24 "github.com/prometheus/client_golang/prometheus" 25 ) 26 27 var hugetlbMetrics = []*metric{ 28 { 29 name: "hugetlb_usage", 30 help: "The hugetlb usage", 31 unit: metrics.Bytes, 32 vt: prometheus.GaugeValue, 33 labels: []string{"page"}, 34 getValues: func(stats *v1.Metrics) []value { 35 if stats.Hugetlb == nil { 36 return nil 37 } 38 var out []value 39 for _, v := range stats.Hugetlb { 40 out = append(out, value{ 41 v: float64(v.Usage), 42 l: []string{v.Pagesize}, 43 }) 44 } 45 return out 46 }, 47 }, 48 { 49 name: "hugetlb_failcnt", 50 help: "The hugetlb failcnt", 51 unit: metrics.Total, 52 vt: prometheus.GaugeValue, 53 labels: []string{"page"}, 54 getValues: func(stats *v1.Metrics) []value { 55 if stats.Hugetlb == nil { 56 return nil 57 } 58 var out []value 59 for _, v := range stats.Hugetlb { 60 out = append(out, value{ 61 v: float64(v.Failcnt), 62 l: []string{v.Pagesize}, 63 }) 64 } 65 return out 66 }, 67 }, 68 { 69 name: "hugetlb_max", 70 help: "The hugetlb maximum usage", 71 unit: metrics.Bytes, 72 vt: prometheus.GaugeValue, 73 labels: []string{"page"}, 74 getValues: func(stats *v1.Metrics) []value { 75 if stats.Hugetlb == nil { 76 return nil 77 } 78 var out []value 79 for _, v := range stats.Hugetlb { 80 out = append(out, value{ 81 v: float64(v.Max), 82 l: []string{v.Pagesize}, 83 }) 84 } 85 return out 86 }, 87 }, 88 }