NewCPUCollector returns a new Collector exposing kernel/system statistics.
()
| 41 | |
| 42 | // NewCPUCollector returns a new Collector exposing kernel/system statistics. |
| 43 | func NewCPUCollector() (Collector, error) { |
| 44 | return &cpuCollector{ |
| 45 | cpu: nodeCPUSecondsDesc, |
| 46 | cpuGuest: prometheus.NewDesc( |
| 47 | prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "guest_seconds_total"), |
| 48 | "Seconds the cpus spent in guests (VMs) for each mode.", |
| 49 | []string{"cpu", "mode"}, nil, |
| 50 | ), |
| 51 | cpuFreq: prometheus.NewDesc( |
| 52 | prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_hertz"), |
| 53 | "Current cpu thread frequency in hertz.", |
| 54 | []string{"cpu"}, nil, |
| 55 | ), |
| 56 | cpuFreqMin: prometheus.NewDesc( |
| 57 | prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_min_hertz"), |
| 58 | "Minimum cpu thread frequency in hertz.", |
| 59 | []string{"cpu"}, nil, |
| 60 | ), |
| 61 | cpuFreqMax: prometheus.NewDesc( |
| 62 | prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_max_hertz"), |
| 63 | "Maximum cpu thread frequency in hertz.", |
| 64 | []string{"cpu"}, nil, |
| 65 | ), |
| 66 | cpuCoreThrottle: prometheus.NewDesc( |
| 67 | prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "core_throttles_total"), |
| 68 | "Number of times this cpu core has been throttled.", |
| 69 | []string{"package", "core"}, nil, |
| 70 | ), |
| 71 | cpuPackageThrottle: prometheus.NewDesc( |
| 72 | prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "package_throttles_total"), |
| 73 | "Number of times this cpu package has been throttled.", |
| 74 | []string{"package"}, nil, |
| 75 | ), |
| 76 | }, nil |
| 77 | } |
| 78 | |
| 79 | // Update implements Collector and exposes cpu related metrics from /proc/stat and /sys/.../cpu/. |
| 80 | func (c *cpuCollector) Update(ch chan<- prometheus.Metric) error { |