Skip to content

Commit

Permalink
Merge pull request #438 from simonpasquier/add-max-vsize-process-metric
Browse files Browse the repository at this point in the history
Add process_maximum_virtual_memory_bytes metric
  • Loading branch information
beorn7 authored Aug 7, 2018
2 parents 0d7f072 + 4ab15af commit 420e2ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion prometheus/process_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ type processCollector struct {
pidFn func() (int, error)
cpuTotal *Desc
openFDs, maxFDs *Desc
vsize, rss *Desc
vsize, maxVsize *Desc
rss *Desc
startTime *Desc
}

Expand Down Expand Up @@ -72,6 +73,11 @@ func NewProcessCollectorPIDFn(
"Virtual memory size in bytes.",
nil, nil,
),
maxVsize: NewDesc(
ns+"process_max_virtual_memory_bytes",
"Maximum amount of virtual memory available in bytes.",
nil, nil,
),
rss: NewDesc(
ns+"process_resident_memory_bytes",
"Resident memory size in bytes.",
Expand All @@ -98,6 +104,7 @@ func (c *processCollector) Describe(ch chan<- *Desc) {
ch <- c.openFDs
ch <- c.maxFDs
ch <- c.vsize
ch <- c.maxVsize
ch <- c.rss
ch <- c.startTime
}
Expand Down Expand Up @@ -135,5 +142,6 @@ func (c *processCollector) processCollect(ch chan<- Metric) {

if limits, err := p.NewLimits(); err == nil {
ch <- MustNewConstMetric(c.maxFDs, GaugeValue, float64(limits.OpenFiles))
ch <- MustNewConstMetric(c.maxVsize, GaugeValue, float64(limits.AddressSpace))
}
}
2 changes: 2 additions & 0 deletions prometheus/process_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ func TestProcessCollector(t *testing.T) {
regexp.MustCompile("\nprocess_cpu_seconds_total [0-9]"),
regexp.MustCompile("\nprocess_max_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_resident_memory_bytes [1-9]"),
regexp.MustCompile("\nprocess_start_time_seconds [0-9.]{10,}"),
regexp.MustCompile("\nfoobar_process_cpu_seconds_total [0-9]"),
regexp.MustCompile("\nfoobar_process_max_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_resident_memory_bytes [1-9]"),
regexp.MustCompile("\nfoobar_process_start_time_seconds [0-9.]{10,}"),
Expand Down

0 comments on commit 420e2ef

Please sign in to comment.