Skip to content

Commit

Permalink
Correct field naming
Browse files Browse the repository at this point in the history
  • Loading branch information
srebhan committed Apr 19, 2024
1 parent 772e0a7 commit 1969374
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions plugins/inputs/procstat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ Below are an example set of tags and fields:
- cpu_time_system (float)
- cpu_time_user (float)
- cpu_usage (float)
- disk_read_bytes (int, Linux only, *telegraf* may need to be ran as **root**)
- disk_write_bytes (int, Linux only, *telegraf* may need to be ran as **root**)
- involuntary_context_switches (int)
- major_faults (int)
- memory_anonymous (int)
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/procstat/os_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func findByWindowsServices(_ []string) ([]processGroup, error) {
return nil, nil
}

func collectCachedReadWrite(proc Process) (r, w uint64, err error) {
func collectTotalReadWrite(proc Process) (r, w uint64, err error) {
path := procfs.DefaultMountPoint
if hp := os.Getenv("HOST_PROC"); hp != "" {
path = hp
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/procstat/os_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ func findByWindowsServices(_ []string) ([]processGroup, error) {
return nil, nil
}

func collectCachedReadWrite(_ Process) (r, w uint64, err error) {
func collectTotalReadWrite(_ Process) (r, w uint64, err error) {
return 0, 0, errors.ErrUnsupported
}
2 changes: 1 addition & 1 deletion plugins/inputs/procstat/os_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ func findByWindowsServices(services []string) ([]processGroup, error) {
return groups, nil
}

func collectCachedReadWrite(_ Process) (r, w uint64, err error) {
func collectTotalReadWrite(_ Process) (r, w uint64, err error) {
return 0, 0, errors.ErrUnsupported
}
10 changes: 7 additions & 3 deletions plugins/inputs/procstat/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ func (p *Proc) Metric(prefix string, tagging map[string]bool, solarisMode bool)
fields[prefix+"write_bytes"] = io.WriteBytes
}

if rc, wc, err := collectCachedReadWrite(p); err == nil {
fields[prefix+"cached_read_bytes"] = rc
fields[prefix+"cached_write_bytes"] = wc
// Linux fixup for gopsutils exposing the disk-only-IO instead of the total
// I/O as for example on Windows
if rc, wc, err := collectTotalReadWrite(p); err == nil {
fields[prefix+"read_bytes"] = rc
fields[prefix+"write_bytes"] = wc
fields[prefix+"disk_read_bytes"] = io.ReadBytes
fields[prefix+"disk_write_bytes"] = io.WriteBytes
}

createdAt, err := p.CreateTime() // returns epoch in ms
Expand Down

0 comments on commit 1969374

Please sign in to comment.