Skip to content

Commit

Permalink
Improve procstat
Browse files Browse the repository at this point in the history
closes #799
  • Loading branch information
titilambert authored and sparrc committed Mar 7, 2016
1 parent 240f994 commit cd66e20
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,7 @@
- [#788](https://github.com/influxdata/telegraf/pull/788): -input-list and -output-list command-line options. Thanks @ebookbug!
- [#778](https://github.com/influxdata/telegraf/pull/778): Adding a TCP input listener.
- [#797](https://github.com/influxdata/telegraf/issues/797): Provide option for persistent MQTT consumer client sessions.
- [#799](https://github.com/influxdata/telegraf/pull/799): Add number of threads for procstat input plugin. Thanks @titilambert!

### Bugfixes
- [#748](https://github.com/influxdata/telegraf/issues/748): Fix sensor plugin split on ":"
Expand Down
4 changes: 4 additions & 0 deletions plugins/inputs/procstat/README.md
Expand Up @@ -35,6 +35,10 @@ The above configuration would result in output like:
# Measurements
Note: prefix can be set by the user, per process.


Threads related measurement names:
- procstat_[prefix_]num_threads value=5

File descriptor related measurement names:
- procstat_[prefix_]num_fds value=4

Expand Down
10 changes: 10 additions & 0 deletions plugins/inputs/procstat/spec_processor.go
Expand Up @@ -52,6 +52,7 @@ func NewSpecProcessor(
}

func (p *SpecProcessor) pushMetrics() {
p.pushNThreadsStats()
p.pushFDStats()
p.pushCtxStats()
p.pushIOStats()
Expand All @@ -60,6 +61,15 @@ func (p *SpecProcessor) pushMetrics() {
p.flush()
}

func (p *SpecProcessor) pushNThreadsStats() error {
numThreads, err := p.proc.NumThreads()
if err != nil {
return fmt.Errorf("NumThreads error: %s\n", err)
}
p.add("num_threads", numThreads)
return nil
}

func (p *SpecProcessor) pushFDStats() error {
fds, err := p.proc.NumFDs()
if err != nil {
Expand Down

0 comments on commit cd66e20

Please sign in to comment.