Skip to content

Commit

Permalink
fix typo in sample config and README
Browse files Browse the repository at this point in the history
Closes #240
  • Loading branch information
ranjib authored and sparrc committed Oct 7, 2015
1 parent e424d47 commit 6827459
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 15 deletions.
45 changes: 42 additions & 3 deletions plugins/procstat/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Procstat plugin
# Telegraf plugin: procstat

#### Description

The procstat plugin can be used to monitor system resource usage by an
individual process.
individual process using their /proc data.

Processes can be specified either by pid file or by executable name. Procstat
plugin will use `pgrep` when executable name is provided to obtain the pid. Proctsta plugin will transmit IO, memory, cpu, file descriptor related measurements for every process specified. A prefix can be set to isolate individual process specific measurements.
plugin will use `pgrep` when executable name is provided to obtain the pid.
Proctsta plugin will transmit IO, memory, cpu, file descriptor related
measurements for every process specified. A prefix can be set to isolate
individual process specific measurements.

Example:

Expand All @@ -19,3 +24,37 @@ Example:
pid_file = "/var/run/lxc/dnsmasq.pid"
prefix = "dnsmasq"
```

# Measurements
Note: prefix will set by the user, per process.

File descriptor related measurement names:
- procstat_prefix_num_fds value=4

Context switch related measurement names:
- procstat_prefix_voluntary_context_switches value=250
- procstat_prefix_involuntary_context_switches value=0

I/O related measurement names:
- procstat_prefix_read_count value=396
- procstat_prefix_write_count value=1
- procstat_prefix_read_bytes value=1019904
- procstat_prefix_write_bytes value=1

CPU related measurement names:
- procstat_prefix_cpu_user value=0
- procstat_prefix_cpu_system value=0.01
- procstat_prefix_cpu_idle value=0
- procstat_prefix_cpu_nice value=0
- procstat_prefix_cpu_iowait value=0
- procstat_prefix_cpu_irq value=0
- procstat_prefix_cpu_soft_irq value=0
- procstat_prefix_cpu_soft_steal value=0
- procstat_prefix_cpu_soft_stolen value=0
- procstat_prefix_cpu_soft_guest value=0
- procstat_prefix_cpu_soft_guest_nice value=0

Memory related measurement names:
- procstat_prefix_memory_rss value=1777664
- procstat_prefix_memory_vms value=24227840
- procstat_prefix_memory_swap value=282624
18 changes: 10 additions & 8 deletions plugins/procstat/procstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package procstat

import (
"fmt"
"github.com/influxdb/telegraf/plugins"
"github.com/shirou/gopsutil/process"
"io/ioutil"
"os/exec"
"strconv"
"strings"
"sync"

"github.com/shirou/gopsutil/process"

"github.com/influxdb/telegraf/plugins"
)

type Specification struct {
Expand All @@ -26,20 +28,20 @@ func NewProcstat() *Procstat {
}

var sampleConfig = `
[[process.specifications]]
# pid file
pid_file = "/path/to/foo.pid"
[[procstat.specifications]]
prefix = "nginx" # required
# Use one of pid_file or exe to find process
pid_file = "/var/run/nginx.pid"
# executable name (used by pgrep)
exe = "/path/to/foo"
name = "foo" # required
# exe = "nginx"
`

func (_ *Procstat) SampleConfig() string {
return sampleConfig
}

func (_ *Procstat) Description() string {
return "Monitor process cpu and memory usage"
return "Monitor process cpu and memory usage"
}

func (p *Procstat) Gather(acc plugins.Accumulator) error {
Expand Down
8 changes: 5 additions & 3 deletions plugins/procstat/procstat_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package procstat

import (
"github.com/influxdb/telegraf/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"io/ioutil"
"os"
"strconv"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/influxdb/telegraf/testutil"
)

func TestGather(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion plugins/procstat/spec_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package procstat

import (
"fmt"
"github.com/influxdb/telegraf/plugins"

"github.com/shirou/gopsutil/process"

"github.com/influxdb/telegraf/plugins"
)

type SpecProcessor struct {
Expand Down

0 comments on commit 6827459

Please sign in to comment.