* Fix evaluation when to recalculate metrics

* Rename "CalculateProcessScoreboard" to "CountProcessState"
This commit is contained in:
Enrico Stahn 2018-02-28 22:22:35 +11:00
parent 7e6f6c32c5
commit a00bd5b50d
No known key found for this signature in database
GPG key ID: 5263621C269A50DE
2 changed files with 5 additions and 5 deletions

View file

@ -57,7 +57,7 @@ to quickly create a Cobra application.`,
if fixProcessCount { if fixProcessCount {
log.Info("Idle/Active/Total Processes will be calculated by php-fpm_exporter.") log.Info("Idle/Active/Total Processes will be calculated by php-fpm_exporter.")
exporter.CalculateProcessScoreboard = true exporter.CountProcessState = true
} }
prometheus.MustRegister(exporter) prometheus.MustRegister(exporter)

View file

@ -30,7 +30,7 @@ type Exporter struct {
mutex sync.Mutex mutex sync.Mutex
PoolManager PoolManager PoolManager PoolManager
CalculateProcessScoreboard bool CountProcessState bool
up *prometheus.Desc up *prometheus.Desc
scrapeFailues *prometheus.Desc scrapeFailues *prometheus.Desc
@ -56,7 +56,7 @@ func NewExporter(pm PoolManager) *Exporter {
return &Exporter{ return &Exporter{
PoolManager: pm, PoolManager: pm,
CalculateProcessScoreboard: false, CountProcessState: false,
up: prometheus.NewDesc( up: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "up"), prometheus.BuildFQName(namespace, "", "up"),
@ -179,11 +179,11 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
} }
active, idle, total := CountProcessState(pool.Processes) active, idle, total := CountProcessState(pool.Processes)
if !e.CalculateProcessScoreboard && (active != pool.ActiveProcesses || idle != pool.IdleProcesses) { if !e.CountProcessState && (active != pool.ActiveProcesses || idle != pool.IdleProcesses) {
log.Error("Inconsistent active and idle processes reported. Set `--fix-process-count` to have this calculated by php-fpm_exporter instead.") log.Error("Inconsistent active and idle processes reported. Set `--fix-process-count` to have this calculated by php-fpm_exporter instead.")
} }
if e.CalculateProcessScoreboard { if !e.CountProcessState {
active = pool.ActiveProcesses active = pool.ActiveProcesses
idle = pool.IdleProcesses idle = pool.IdleProcesses
total = pool.TotalProcesses total = pool.TotalProcesses