forked from mirror/client_golang
Add process_maximum_virtual_memory_bytes metric
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
bcbbc08eb2
commit
4ab15af0dc
|
@ -20,7 +20,8 @@ type processCollector struct {
|
||||||
pidFn func() (int, error)
|
pidFn func() (int, error)
|
||||||
cpuTotal *Desc
|
cpuTotal *Desc
|
||||||
openFDs, maxFDs *Desc
|
openFDs, maxFDs *Desc
|
||||||
vsize, rss *Desc
|
vsize, maxVsize *Desc
|
||||||
|
rss *Desc
|
||||||
startTime *Desc
|
startTime *Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +73,11 @@ func NewProcessCollectorPIDFn(
|
||||||
"Virtual memory size in bytes.",
|
"Virtual memory size in bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
|
maxVsize: NewDesc(
|
||||||
|
ns+"process_max_virtual_memory_bytes",
|
||||||
|
"Maximum amount of virtual memory available in bytes.",
|
||||||
|
nil, nil,
|
||||||
|
),
|
||||||
rss: NewDesc(
|
rss: NewDesc(
|
||||||
ns+"process_resident_memory_bytes",
|
ns+"process_resident_memory_bytes",
|
||||||
"Resident memory size in bytes.",
|
"Resident memory size in bytes.",
|
||||||
|
@ -98,6 +104,7 @@ func (c *processCollector) Describe(ch chan<- *Desc) {
|
||||||
ch <- c.openFDs
|
ch <- c.openFDs
|
||||||
ch <- c.maxFDs
|
ch <- c.maxFDs
|
||||||
ch <- c.vsize
|
ch <- c.vsize
|
||||||
|
ch <- c.maxVsize
|
||||||
ch <- c.rss
|
ch <- c.rss
|
||||||
ch <- c.startTime
|
ch <- c.startTime
|
||||||
}
|
}
|
||||||
|
@ -135,5 +142,6 @@ func (c *processCollector) processCollect(ch chan<- Metric) {
|
||||||
|
|
||||||
if limits, err := p.NewLimits(); err == nil {
|
if limits, err := p.NewLimits(); err == nil {
|
||||||
ch <- MustNewConstMetric(c.maxFDs, GaugeValue, float64(limits.OpenFiles))
|
ch <- MustNewConstMetric(c.maxFDs, GaugeValue, float64(limits.OpenFiles))
|
||||||
|
ch <- MustNewConstMetric(c.maxVsize, GaugeValue, float64(limits.AddressSpace))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,12 +43,14 @@ func TestProcessCollector(t *testing.T) {
|
||||||
regexp.MustCompile("\nprocess_cpu_seconds_total [0-9]"),
|
regexp.MustCompile("\nprocess_cpu_seconds_total [0-9]"),
|
||||||
regexp.MustCompile("\nprocess_max_fds [1-9]"),
|
regexp.MustCompile("\nprocess_max_fds [1-9]"),
|
||||||
regexp.MustCompile("\nprocess_open_fds [1-9]"),
|
regexp.MustCompile("\nprocess_open_fds [1-9]"),
|
||||||
|
regexp.MustCompile("\nprocess_max_virtual_memory_bytes (-1|[1-9])"),
|
||||||
regexp.MustCompile("\nprocess_virtual_memory_bytes [1-9]"),
|
regexp.MustCompile("\nprocess_virtual_memory_bytes [1-9]"),
|
||||||
regexp.MustCompile("\nprocess_resident_memory_bytes [1-9]"),
|
regexp.MustCompile("\nprocess_resident_memory_bytes [1-9]"),
|
||||||
regexp.MustCompile("\nprocess_start_time_seconds [0-9.]{10,}"),
|
regexp.MustCompile("\nprocess_start_time_seconds [0-9.]{10,}"),
|
||||||
regexp.MustCompile("\nfoobar_process_cpu_seconds_total [0-9]"),
|
regexp.MustCompile("\nfoobar_process_cpu_seconds_total [0-9]"),
|
||||||
regexp.MustCompile("\nfoobar_process_max_fds [1-9]"),
|
regexp.MustCompile("\nfoobar_process_max_fds [1-9]"),
|
||||||
regexp.MustCompile("\nfoobar_process_open_fds [1-9]"),
|
regexp.MustCompile("\nfoobar_process_open_fds [1-9]"),
|
||||||
|
regexp.MustCompile("\nfoobar_process_max_virtual_memory_bytes (-1|[1-9])"),
|
||||||
regexp.MustCompile("\nfoobar_process_virtual_memory_bytes [1-9]"),
|
regexp.MustCompile("\nfoobar_process_virtual_memory_bytes [1-9]"),
|
||||||
regexp.MustCompile("\nfoobar_process_resident_memory_bytes [1-9]"),
|
regexp.MustCompile("\nfoobar_process_resident_memory_bytes [1-9]"),
|
||||||
regexp.MustCompile("\nfoobar_process_start_time_seconds [0-9.]{10,}"),
|
regexp.MustCompile("\nfoobar_process_start_time_seconds [0-9.]{10,}"),
|
||||||
|
|
Loading…
Reference in New Issue