#9 Fix Unknown states and Inconsistent processes error message
This commit is contained in:
parent
07154a3a86
commit
fa24ebae1a
2 changed files with 48 additions and 15 deletions
|
@ -171,15 +171,15 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
active, idle, total := CalculateProcessScoreboard(pool)
|
pps := CalculateProcessScoreboard(pool)
|
||||||
if active != pool.ActiveProcesses || idle != pool.IdleProcesses {
|
if e.CalculateProcessScoreboard == false && (pps.Active != pool.ActiveProcesses || pps.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 == false {
|
if e.CalculateProcessScoreboard == false {
|
||||||
active = pool.ActiveProcesses
|
pps.Active = pool.ActiveProcesses
|
||||||
idle = pool.IdleProcesses
|
pps.Idle = pool.IdleProcesses
|
||||||
total = pool.TotalProcesses
|
pps.Total = pool.TotalProcesses
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(e.up, prometheus.GaugeValue, 1, pool.Name)
|
ch <- prometheus.MustNewConstMetric(e.up, prometheus.GaugeValue, 1, pool.Name)
|
||||||
|
@ -188,9 +188,9 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
|
||||||
ch <- prometheus.MustNewConstMetric(e.listenQueue, prometheus.GaugeValue, float64(pool.ListenQueue), pool.Name)
|
ch <- prometheus.MustNewConstMetric(e.listenQueue, prometheus.GaugeValue, float64(pool.ListenQueue), pool.Name)
|
||||||
ch <- prometheus.MustNewConstMetric(e.maxListenQueue, prometheus.CounterValue, float64(pool.MaxListenQueue), pool.Name)
|
ch <- prometheus.MustNewConstMetric(e.maxListenQueue, prometheus.CounterValue, float64(pool.MaxListenQueue), pool.Name)
|
||||||
ch <- prometheus.MustNewConstMetric(e.listenQueueLength, prometheus.GaugeValue, float64(pool.ListenQueueLength), pool.Name)
|
ch <- prometheus.MustNewConstMetric(e.listenQueueLength, prometheus.GaugeValue, float64(pool.ListenQueueLength), pool.Name)
|
||||||
ch <- prometheus.MustNewConstMetric(e.idleProcesses, prometheus.GaugeValue, float64(idle), pool.Name)
|
ch <- prometheus.MustNewConstMetric(e.idleProcesses, prometheus.GaugeValue, float64(pps.Idle), pool.Name)
|
||||||
ch <- prometheus.MustNewConstMetric(e.activeProcesses, prometheus.GaugeValue, float64(active), pool.Name)
|
ch <- prometheus.MustNewConstMetric(e.activeProcesses, prometheus.GaugeValue, float64(pps.Active), pool.Name)
|
||||||
ch <- prometheus.MustNewConstMetric(e.totalProcesses, prometheus.GaugeValue, float64(total), pool.Name)
|
ch <- prometheus.MustNewConstMetric(e.totalProcesses, prometheus.GaugeValue, float64(pps.Total), pool.Name)
|
||||||
ch <- prometheus.MustNewConstMetric(e.maxActiveProcesses, prometheus.CounterValue, float64(pool.MaxActiveProcesses), pool.Name)
|
ch <- prometheus.MustNewConstMetric(e.maxActiveProcesses, prometheus.CounterValue, float64(pool.MaxActiveProcesses), pool.Name)
|
||||||
ch <- prometheus.MustNewConstMetric(e.maxChildrenReached, prometheus.CounterValue, float64(pool.MaxChildrenReached), pool.Name)
|
ch <- prometheus.MustNewConstMetric(e.maxChildrenReached, prometheus.CounterValue, float64(pool.MaxChildrenReached), pool.Name)
|
||||||
ch <- prometheus.MustNewConstMetric(e.slowRequests, prometheus.CounterValue, float64(pool.SlowRequests), pool.Name)
|
ch <- prometheus.MustNewConstMetric(e.slowRequests, prometheus.CounterValue, float64(pool.SlowRequests), pool.Name)
|
||||||
|
|
|
@ -32,6 +32,18 @@ const PoolProcessRequestIdle string = "Idle"
|
||||||
// PoolProcessRequestIdle defines a process that is active.
|
// PoolProcessRequestIdle defines a process that is active.
|
||||||
const PoolProcessRequestActive string = "Running"
|
const PoolProcessRequestActive string = "Running"
|
||||||
|
|
||||||
|
// PoolProcessRequestFinishing defines a process that is about to finish.
|
||||||
|
const PoolProcessRequestFinishing string = "Finishing"
|
||||||
|
|
||||||
|
// PoolProcessRequestReadingHeaders defines a process that is reading headers.
|
||||||
|
const PoolProcessRequestReadingHeaders string = "Reading headers"
|
||||||
|
|
||||||
|
// PoolProcessRequestInfo defines a process that is getting request information.
|
||||||
|
const PoolProcessRequestInfo string = "Getting request informations"
|
||||||
|
|
||||||
|
// PoolProcessRequestFinishing defines a process that is about to end.
|
||||||
|
const PoolProcessRequestEnding string = "Ending"
|
||||||
|
|
||||||
var log logger
|
var log logger
|
||||||
|
|
||||||
type logger interface {
|
type logger interface {
|
||||||
|
@ -88,6 +100,18 @@ type PoolProcess struct {
|
||||||
LastRequestMemory int `json:"last request memory"`
|
LastRequestMemory int `json:"last request memory"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PoolProcessScoreboard holds the calculated metrics for pool processes.
|
||||||
|
type PoolProcessScoreboard struct {
|
||||||
|
Active int64
|
||||||
|
Idle int64
|
||||||
|
Finishing int64
|
||||||
|
ReadingHeaders int64
|
||||||
|
Info int64
|
||||||
|
Ending int64
|
||||||
|
Unknown int64
|
||||||
|
Total int64
|
||||||
|
}
|
||||||
|
|
||||||
// Add will add a pool to the pool manager based on the given URI.
|
// Add will add a pool to the pool manager based on the given URI.
|
||||||
func (pm *PoolManager) Add(uri string) Pool {
|
func (pm *PoolManager) Add(uri string) Pool {
|
||||||
p := Pool{Address: uri}
|
p := Pool{Address: uri}
|
||||||
|
@ -170,23 +194,32 @@ func (p *Pool) error(err error) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func CalculateProcessScoreboard(p Pool) (active int64, idle int64, total int64) {
|
func CalculateProcessScoreboard(p Pool) PoolProcessScoreboard {
|
||||||
active = 0
|
pps := PoolProcessScoreboard{}
|
||||||
idle = 0
|
|
||||||
total = 0
|
|
||||||
|
|
||||||
for idx := range p.Processes {
|
for idx := range p.Processes {
|
||||||
switch p.Processes[idx].State {
|
switch p.Processes[idx].State {
|
||||||
case PoolProcessRequestActive:
|
case PoolProcessRequestActive:
|
||||||
active++
|
pps.Active++
|
||||||
case PoolProcessRequestIdle:
|
case PoolProcessRequestIdle:
|
||||||
idle++
|
pps.Idle++
|
||||||
|
case PoolProcessRequestEnding:
|
||||||
|
pps.Ending++
|
||||||
|
case PoolProcessRequestFinishing:
|
||||||
|
pps.Finishing++
|
||||||
|
case PoolProcessRequestInfo:
|
||||||
|
pps.Info++
|
||||||
|
case PoolProcessRequestReadingHeaders:
|
||||||
|
pps.ReadingHeaders++
|
||||||
default:
|
default:
|
||||||
|
pps.Unknown++
|
||||||
log.Errorf("Unknown process state '%v'", p.Processes[idx].State)
|
log.Errorf("Unknown process state '%v'", p.Processes[idx].State)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return active, idle, active + idle
|
pps.Total = pps.Active + pps.Idle + pps.Ending + pps.Finishing + pps.Info + pps.ReadingHeaders + pps.Unknown
|
||||||
|
|
||||||
|
return pps
|
||||||
}
|
}
|
||||||
|
|
||||||
type timestamp time.Time
|
type timestamp time.Time
|
||||||
|
|
Loading…
Reference in a new issue