github.com/demonoid81/containerd@v1.3.4/cmd/containerd-stress/size.go (about) 1 /* 2 Copyright The containerd Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package main 18 19 import ( 20 "os" 21 "path/filepath" 22 23 "github.com/sirupsen/logrus" 24 ) 25 26 var binaries = []string{ 27 "ctr", 28 "containerd", 29 "containerd-shim", 30 "containerd-shim-runc-v1", 31 "containerd-shim-runc-v2", 32 } 33 34 // checkBinarySizes checks and reports the binary sizes for the containerd compiled binaries to prometheus 35 func checkBinarySizes() { 36 for _, name := range binaries { 37 fi, err := os.Stat(filepath.Join("/usr/local/bin", name)) 38 if err != nil { 39 logrus.WithError(err).Error("stat binary") 40 continue 41 } 42 binarySizeGauge.WithValues(name).Set(float64(fi.Size())) 43 } 44 }