phpfpm

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package phpfpm provides convenient access to PHP-FPM pool data

Index

Constants

View Source
const PoolProcessRequestActive string = "Running"

PoolProcessRequestIdle defines a process that is active.

View Source
const PoolProcessRequestIdle string = "Idle"

PoolProcessRequestIdle defines a process that is idle.

Variables

This section is empty.

Functions

func CalculateProcessScoreboard added in v0.2.0

func CalculateProcessScoreboard(p Pool) (active int64, idle int64, total int64)

func SetLogger

func SetLogger(logger logger)

SetLogger configures the used logger

Types

type Exporter

type Exporter struct {
	PoolManager PoolManager

	CalculateProcessScoreboard 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   int64   `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 int     `json:"last request memory"`
}

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

Jump to

Keyboard shortcuts

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