Update procfs vendor (#1248)

Signed-off-by: Mark Knapp <mknapp@hudson-trading.com>
This commit is contained in:
mknapphrt 2019-02-04 10:54:41 -05:00 committed by Ben Kochie
commit 7fbdd0ae93
26 changed files with 2200 additions and 156 deletions

View file

@ -32,6 +32,9 @@ type cpuCollector struct {
cpuFreq *prometheus.Desc
cpuFreqMin *prometheus.Desc
cpuFreqMax *prometheus.Desc
scalingFreq *prometheus.Desc
scalingFreqMin *prometheus.Desc
scalingFreqMax *prometheus.Desc
cpuCoreThrottle *prometheus.Desc
cpuPackageThrottle *prometheus.Desc
}
@ -64,6 +67,21 @@ func NewCPUCollector() (Collector, error) {
"Maximum cpu thread frequency in hertz.",
[]string{"cpu"}, nil,
),
scalingFreq: prometheus.NewDesc(
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "scaling_frequency_hertz"),
"Current scaled cpu thread frequency in hertz.",
[]string{"cpu"}, nil,
),
scalingFreqMin: prometheus.NewDesc(
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "scaling_frequency_min_hrts"),
"Minimum scaled cpu thread frequency in hertz.",
[]string{"cpu"}, nil,
),
scalingFreqMax: prometheus.NewDesc(
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "scaling_frequency_max_hrts"),
"Maximum scaled cpu thread frequency in hertz.",
[]string{"cpu"}, nil,
),
cpuCoreThrottle: prometheus.NewDesc(
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "core_throttles_total"),
"Number of times this cpu core has been throttled.",
@ -106,24 +124,54 @@ func (c *cpuCollector) updateCPUfreq(ch chan<- prometheus.Metric) error {
// sysfs cpufreq values are kHz, thus multiply by 1000 to export base units (hz).
// See https://www.kernel.org/doc/Documentation/cpu-freq/user-guide.txt
for _, stats := range cpuFreqs {
ch <- prometheus.MustNewConstMetric(
c.cpuFreq,
prometheus.GaugeValue,
float64(stats.CurrentFrequency)*1000.0,
stats.Name,
)
ch <- prometheus.MustNewConstMetric(
c.cpuFreqMin,
prometheus.GaugeValue,
float64(stats.MinimumFrequency)*1000.0,
stats.Name,
)
ch <- prometheus.MustNewConstMetric(
c.cpuFreqMax,
prometheus.GaugeValue,
float64(stats.MaximumFrequency)*1000.0,
stats.Name,
)
if stats.CpuinfoCurrentFrequency != nil {
ch <- prometheus.MustNewConstMetric(
c.cpuFreq,
prometheus.GaugeValue,
float64(*stats.CpuinfoCurrentFrequency)*1000.0,
stats.Name,
)
}
if stats.CpuinfoMinimumFrequency != nil {
ch <- prometheus.MustNewConstMetric(
c.cpuFreqMin,
prometheus.GaugeValue,
float64(*stats.CpuinfoMinimumFrequency)*1000.0,
stats.Name,
)
}
if stats.CpuinfoMaximumFrequency != nil {
ch <- prometheus.MustNewConstMetric(
c.cpuFreqMax,
prometheus.GaugeValue,
float64(*stats.CpuinfoMaximumFrequency)*1000.0,
stats.Name,
)
}
if stats.ScalingCurrentFrequency != nil {
ch <- prometheus.MustNewConstMetric(
c.scalingFreq,
prometheus.GaugeValue,
float64(*stats.ScalingCurrentFrequency)*1000.0,
stats.Name,
)
}
if stats.ScalingMinimumFrequency != nil {
ch <- prometheus.MustNewConstMetric(
c.scalingFreqMin,
prometheus.GaugeValue,
float64(*stats.ScalingMinimumFrequency)*1000.0,
stats.Name,
)
}
if stats.ScalingMaximumFrequency != nil {
ch <- prometheus.MustNewConstMetric(
c.scalingFreqMax,
prometheus.GaugeValue,
float64(*stats.ScalingMaximumFrequency)*1000.0,
stats.Name,
)
}
}
return nil
}