phpfpm

package
Version: v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package phpfpm provides convenient access to PHP-FPM pool data

Package phpfpm provides convenient access to PHP-FPM pool data

Index

Constants

View Source
const PoolProcessRequestEnding string = "Ending"

PoolProcessRequestEnding defines a process that is about to end.

View Source
const PoolProcessRequestFinishing string = "Finishing"

PoolProcessRequestFinishing defines a process that is about to finish.

View Source
const PoolProcessRequestIdle string = "Idle"

PoolProcessRequestIdle defines a process that is idle.

View Source
const PoolProcessRequestInfo string = "Getting request informations"

PoolProcessRequestInfo defines a process that is getting request information.

View Source
const PoolProcessRequestReadingHeaders string = "Reading headers"

PoolProcessRequestReadingHeaders defines a process that is reading headers.

View Source
const PoolProcessRequestRunning string = "Running"

PoolProcessRequestRunning defines a process that is running.

Variables

This section is empty.

Functions

func CountProcessState added in v0.3.0

func CountProcessState(processes []PoolProcess) (active int64, idle int64, total int64)

CountProcessState return the calculated metrics based on the reported processes.

func JSONResponseFixer added in v0.5.3

func JSONResponseFixer(content []byte) []byte

JSONResponseFixer resolves encoding issues with PHP-FPMs JSON response

func SetLogger

func SetLogger(logger logger)

SetLogger configures the used logger

Types

type Exporter

type Exporter struct {
	PoolManager PoolManager

	CountProcessState bool
	// contains filtered or unexported fields
}

Exporter configures and exposes PHP-FPM metrics to Prometheus.

func NewExporter

func NewExporter(pm PoolManager) *Exporter

NewExporter creates a new Exporter for a PoolManager and configures the necessary metrics.

func (*Exporter) Collect

func (e *Exporter) Collect(ch chan<- prometheus.Metric)

Collect updates the Pools and sends the collected metrics to Prometheus

func (*Exporter) Describe

func (e *Exporter) Describe(ch chan<- *prometheus.Desc)

Describe exposes the metric description to Prometheus

type Pool

type Pool struct {
	// The address of the pool, e.g. tcp://127.0.0.1:9000 or unix:///tmp/php-fpm.sock
	Address             string        `json:"-"`
	ScrapeError         error         `json:"-"`
	ScrapeFailures      int64         `json:"-"`
	Name                string        `json:"pool"`
	ProcessManager      string        `json:"process manager"`
	StartTime           timestamp     `json:"start time"`
	StartSince          int64         `json:"start since"`
	AcceptedConnections int64         `json:"accepted conn"`
	ListenQueue         int64         `json:"listen queue"`
	MaxListenQueue      int64         `json:"max listen queue"`
	ListenQueueLength   int64         `json:"listen queue len"`
	IdleProcesses       int64         `json:"idle processes"`
	ActiveProcesses     int64         `json:"active processes"`
	TotalProcesses      int64         `json:"total processes"`
	MaxActiveProcesses  int64         `json:"max active processes"`
	MaxChildrenReached  int64         `json:"max children reached"`
	SlowRequests        int64         `json:"slow requests"`
	Processes           []PoolProcess `json:"processes"`
}

Pool describes a single PHP-FPM pool that can be reached via a Socket or TCP address

func (*Pool) Update

func (p *Pool) Update() (err error)

Update will connect to PHP-FPM and retrieve the latest data for the pool.

type PoolManager

type PoolManager struct {
	Pools []Pool `json:"pools"`
}

PoolManager manages all configured Pools

func (*PoolManager) Add

func (pm *PoolManager) Add(uri string) Pool

Add will add a pool to the pool manager based on the given URI.

func (*PoolManager) Update

func (pm *PoolManager) Update() (err error)

Update will run the pool.Update() method concurrently on all Pools.

type PoolProcess

type PoolProcess struct {
	PID               int64           `json:"pid"`
	State             string          `json:"state"`
	StartTime         int64           `json:"start time"`
	StartSince        int64           `json:"start since"`
	Requests          int64           `json:"requests"`
	RequestDuration   requestDuration `json:"request duration"`
	RequestMethod     string          `json:"request method"`
	RequestURI        string          `json:"request uri"`
	ContentLength     int64           `json:"content length"`
	User              string          `json:"user"`
	Script            string          `json:"script"`
	LastRequestCPU    float64         `json:"last request cpu"`
	LastRequestMemory int64           `json:"last request memory"`
}

PoolProcess describes a single PHP-FPM process. A pool can have multiple processes.

type PoolProcessStateCounter added in v0.3.0

type PoolProcessStateCounter struct {
	Running        int64
	Idle           int64
	Finishing      int64
	ReadingHeaders int64
	Info           int64
	Ending         int64
}

PoolProcessStateCounter holds the calculated metrics for pool processes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL