mirror of
				https://github.com/prometheus/node_exporter.git
				synced 2025-08-20 18:33:52 -07:00 
			
		
		
		
	AIX: Add context switches to cpu collector
Signed-off-by: Johannes Ziemke <github@5pi.de> Signed-off-by: Shashwat Hiregoudar <shashwat.h@flipkart.com>
This commit is contained in:
		
							parent
							
								
									1292993082
								
							
						
					
					
						commit
						f365644d94
					
				| 
						 | 
					@ -45,13 +45,19 @@ var (
 | 
				
			||||||
		"CPU flags.",
 | 
							"CPU flags.",
 | 
				
			||||||
		[]string{"cpu", "flag"}, nil,
 | 
							[]string{"cpu", "flag"}, nil,
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
						nodeCPUContextSwitchDesc = prometheus.NewDesc(
 | 
				
			||||||
 | 
							prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "context_switches_total"),
 | 
				
			||||||
 | 
							"Number of context switches.",
 | 
				
			||||||
 | 
							[]string{"cpu"}, nil,
 | 
				
			||||||
 | 
						)
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type cpuCollector struct {
 | 
					type cpuCollector struct {
 | 
				
			||||||
	cpu         typedDesc
 | 
						cpu              typedDesc
 | 
				
			||||||
	cpuPhysical typedDesc
 | 
						cpuPhysical      typedDesc
 | 
				
			||||||
	cpuRunQueue typedDesc
 | 
						cpuRunQueue      typedDesc
 | 
				
			||||||
	cpuFlags    typedDesc
 | 
						cpuFlags         typedDesc
 | 
				
			||||||
 | 
						cpuContextSwitch typedDesc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	logger        *slog.Logger
 | 
						logger        *slog.Logger
 | 
				
			||||||
	tickPerSecond int64
 | 
						tickPerSecond int64
 | 
				
			||||||
| 
						 | 
					@ -75,12 +81,13 @@ func NewCpuCollector(logger *slog.Logger) (Collector, error) {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return &cpuCollector{
 | 
						return &cpuCollector{
 | 
				
			||||||
		cpu:           typedDesc{nodeCPUSecondsDesc, prometheus.CounterValue},
 | 
							cpu:              typedDesc{nodeCPUSecondsDesc, prometheus.CounterValue},
 | 
				
			||||||
		cpuPhysical:   typedDesc{nodeCPUPhysicalSecondsDesc, prometheus.CounterValue},
 | 
							cpuPhysical:      typedDesc{nodeCPUPhysicalSecondsDesc, prometheus.CounterValue},
 | 
				
			||||||
		cpuRunQueue:   typedDesc{nodeCPUSRunQueueDesc, prometheus.GaugeValue},
 | 
							cpuRunQueue:      typedDesc{nodeCPUSRunQueueDesc, prometheus.GaugeValue},
 | 
				
			||||||
		cpuFlags:      typedDesc{nodeCPUFlagsDesc, prometheus.GaugeValue},
 | 
							cpuFlags:         typedDesc{nodeCPUFlagsDesc, prometheus.GaugeValue},
 | 
				
			||||||
		logger:        logger,
 | 
							cpuContextSwitch: typedDesc{nodeCPUContextSwitchDesc, prometheus.CounterValue},
 | 
				
			||||||
		tickPerSecond: ticks,
 | 
							logger:           logger,
 | 
				
			||||||
 | 
							tickPerSecond:    ticks,
 | 
				
			||||||
	}, nil
 | 
						}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -108,6 +115,9 @@ func (c *cpuCollector) Update(ch chan<- prometheus.Metric) error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Flags
 | 
							// Flags
 | 
				
			||||||
		ch <- c.cpuFlags.mustNewConstMetric(float64(stat.SpurrFlag), strconv.Itoa(n), "spurr")
 | 
							ch <- c.cpuFlags.mustNewConstMetric(float64(stat.SpurrFlag), strconv.Itoa(n), "spurr")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// Context switches
 | 
				
			||||||
 | 
							ch <- c.cpuContextSwitch.mustNewConstMetric(float64(stat.CSwitches), strconv.Itoa(n))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue