Add slab to mem plugin (#3518)
This commit is contained in:
parent
62b7cb91dc
commit
9325f6e937
|
@ -1,44 +1,34 @@
|
||||||
## Telegraf Plugin: MEM
|
# Mem Input Plugin
|
||||||
|
|
||||||
#### Description
|
The mem plugin collects system memory metrics.
|
||||||
|
|
||||||
The mem plugin collects memory metrics, defined as follows. For a more complete
|
For a more complete explanation of the difference between *used* and
|
||||||
explanation of the difference between `used` and `actual_used` RAM, see
|
*actual_used* RAM, see [Linux ate my ram](http://www.linuxatemyram.com/).
|
||||||
[Linux ate my ram](http://www.linuxatemyram.com/).
|
|
||||||
|
|
||||||
- **total**: total physical memory available
|
### Configuration:
|
||||||
- **available**: the actual amount of available memory that can be given instantly
|
```toml
|
||||||
to processes that request more memory in bytes; In linux kernel 3.14+, this
|
# Read metrics about memory usage
|
||||||
is available natively in /proc/meminfo. In other platforms, this is calculated by
|
[[inputs.mem]]
|
||||||
summing different memory values depending on the platform
|
# no configuration
|
||||||
(e.g. free + buffers + cached on Linux).
|
```
|
||||||
It is supposed to be used to monitor actual memory usage in a cross platform fashion.
|
|
||||||
- **available_percent**: Percent of memory available, `available / total * 100`
|
|
||||||
- **used**: memory used, calculated differently depending on the platform and
|
|
||||||
designed for informational purposes only.
|
|
||||||
- **free**: memory not being used at all (zeroed) that is readily available; note
|
|
||||||
that this doesn't reflect the actual memory available (use 'available' instead).
|
|
||||||
- **used_percent**: the percentage usage calculated as `used / total * 100`
|
|
||||||
|
|
||||||
## Measurements:
|
### Metrics:
|
||||||
#### Raw Memory measurements:
|
|
||||||
|
|
||||||
Meta:
|
- mem
|
||||||
- units: bytes
|
- fields:
|
||||||
- tags: `nil`
|
- active (int)
|
||||||
|
- available (int)
|
||||||
|
- buffered (int)
|
||||||
|
- cached (int)
|
||||||
|
- free (int)
|
||||||
|
- inactive (int)
|
||||||
|
- slab (int)
|
||||||
|
- total (int)
|
||||||
|
- used (int)
|
||||||
|
- available_percent (float)
|
||||||
|
- used_percent (float)
|
||||||
|
|
||||||
Measurement names:
|
### Example Output:
|
||||||
- mem_total
|
```
|
||||||
- mem_available
|
mem cached=7809495040i,inactive=6348988416i,total=20855394304i,available=11378946048i,buffered=927199232i,active=11292905472i,slab=1351340032i,used_percent=45.43883523785713,available_percent=54.56116476214287,used=9476448256i,free=1715331072i 1511894782000000000
|
||||||
- mem_used
|
```
|
||||||
- mem_free
|
|
||||||
|
|
||||||
#### Derived usage percentages:
|
|
||||||
|
|
||||||
Meta:
|
|
||||||
- units: percent (out of 100)
|
|
||||||
- tags: `nil`
|
|
||||||
|
|
||||||
Measurement names:
|
|
||||||
- mem_used_percent
|
|
||||||
- mem_available_percent
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ func (s *MemStats) Gather(acc telegraf.Accumulator) error {
|
||||||
"buffered": vm.Buffers,
|
"buffered": vm.Buffers,
|
||||||
"active": vm.Active,
|
"active": vm.Active,
|
||||||
"inactive": vm.Inactive,
|
"inactive": vm.Inactive,
|
||||||
|
"slab": vm.Slab,
|
||||||
"used_percent": 100 * float64(vm.Used) / float64(vm.Total),
|
"used_percent": 100 * float64(vm.Used) / float64(vm.Total),
|
||||||
"available_percent": 100 * float64(vm.Available) / float64(vm.Total),
|
"available_percent": 100 * float64(vm.Available) / float64(vm.Total),
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ func TestMemStats(t *testing.T) {
|
||||||
Free: 1235,
|
Free: 1235,
|
||||||
Active: 8134,
|
Active: 8134,
|
||||||
Inactive: 1124,
|
Inactive: 1124,
|
||||||
|
Slab: 1234,
|
||||||
// Buffers: 771,
|
// Buffers: 771,
|
||||||
// Cached: 4312,
|
// Cached: 4312,
|
||||||
// Wired: 134,
|
// Wired: 134,
|
||||||
|
@ -54,6 +55,7 @@ func TestMemStats(t *testing.T) {
|
||||||
"buffered": uint64(0),
|
"buffered": uint64(0),
|
||||||
"active": uint64(8134),
|
"active": uint64(8134),
|
||||||
"inactive": uint64(1124),
|
"inactive": uint64(1124),
|
||||||
|
"slab": uint64(1234),
|
||||||
}
|
}
|
||||||
acc.AssertContainsTaggedFields(t, "mem", memfields, make(map[string]string))
|
acc.AssertContainsTaggedFields(t, "mem", memfields, make(map[string]string))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue