diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f66771af..da2b41a5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ time before a new metric is included by the plugin. ### Features - [#1164](https://github.com/influxdata/telegraf/pull/1164): conntrack input plugin. Thanks @robinpercy! +- [#1165](https://github.com/influxdata/telegraf/pull/1165): vmstat input plugin. Thanks @jshim-xm! - [#1247](https://github.com/influxdata/telegraf/pull/1247): rollbar input plugin. Thanks @francois2metz and @cduez! - [#1208](https://github.com/influxdata/telegraf/pull/1208): Standardized AWS credentials evaluation & wildcard CloudWatch dimensions. Thanks @johnrengelman! - [#1264](https://github.com/influxdata/telegraf/pull/1264): Add SSL config options to http_response plugin. diff --git a/README.md b/README.md index 5adcdb39d..7366d5986 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,7 @@ Currently implemented sources: * swap * processes * kernel (/proc/stat) + * kernel (/proc/vmstat) Telegraf can also collect metrics via the following service plugins: diff --git a/plugins/inputs/system/KERNEL_VMSTAT_README.md b/plugins/inputs/system/KERNEL_VMSTAT_README.md index c16f23aab..7235e2f2b 100644 --- a/plugins/inputs/system/KERNEL_VMSTAT_README.md +++ b/plugins/inputs/system/KERNEL_VMSTAT_README.md @@ -1,12 +1,11 @@ # Kernel VMStat Input Plugin -This plugin is only available on Linux. +The kernel_vmstat plugin gathers virtual memory statistics +by reading /proc/vmstat. For a full list of available fields see the +/proc/vmstat section of the [proc man page](http://man7.org/linux/man-pages/man5/proc.5.html). +For a better idea of what each field represents, see the +[vmstat man page](http://linux.die.net/man/8/vmstat). -The kernel_vmstat plugin gathers info about the kernel that doesn't fit into other -plugins. In general, it is the statistics available in `/proc/vmstat` that are -not covered by other plugins. - -The metrics are documented in `man proc` under the `/proc/vmstat` section. ``` /proc/vmstat diff --git a/plugins/inputs/system/kernel_vmstat.go b/plugins/inputs/system/kernel_vmstat.go index c40a437c0..93c822789 100644 --- a/plugins/inputs/system/kernel_vmstat.go +++ b/plugins/inputs/system/kernel_vmstat.go @@ -13,102 +13,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -// /proc/vmstat file line prefixes to gather stats on. -// This is currently not being used as we are retrieving all the stats. Left here for references. -var ( - nr_free_pages = []byte("nr_free_pages") - nr_inactive_anon = []byte("nr_inactive_anon") - nr_active_anon = []byte("nr_active_anon") - nr_inactive_file = []byte("nr_inactive_file") - nr_active_file = []byte("nr_active_file") - nr_unevictable = []byte("nr_unevictable") - nr_mlock = []byte("nr_mlock") - nr_anon_pages = []byte("nr_anon_pages") - nr_mapped = []byte("nr_mapped") - nr_file_pages = []byte("nr_file_pages") - nr_dirty = []byte("nr_dirty") - nr_writeback = []byte("nr_writeback") - nr_slab_reclaimable = []byte("nr_slab_reclaimable") - nr_slab_unreclaimable = []byte("nr_slab_unreclaimable") - nr_page_table_pages = []byte("nr_page_table_pages") - nr_kernel_stack = []byte("nr_kernel_stack") - nr_unstable = []byte("nr_unstable") - nr_bounce = []byte("nr_bounce") - nr_vmscan_write = []byte("nr_vmscan_write") - nr_writeback_temp = []byte("nr_writeback_temp") - nr_isolated_anon = []byte("nr_isolated_anon") - nr_isolated_file = []byte("nr_isolated_file") - nr_shmem = []byte("nr_shmem") - numa_hit = []byte("numa_hit") - numa_miss = []byte("numa_miss") - numa_foreign = []byte("numa_foreign") - numa_interleave = []byte("numa_interleave") - numa_local = []byte("numa_local") - numa_other = []byte("numa_other") - nr_anon_transparent_hugepages = []byte("nr_anon_transparent_hugepages") - pgpgin = []byte("pgpgin") - pgpgout = []byte("pgpgout") - pswpin = []byte("pswpin") - pswpout = []byte("pswpout") - pgalloc_dma = []byte("pgalloc_dma") - pgalloc_dma32 = []byte("pgalloc_dma32") - pgalloc_normal = []byte("pgalloc_normal") - pgalloc_movable = []byte("pgalloc_movable") - pgfree = []byte("pgfree") - pgactivate = []byte("pgactivate") - pgdeactivate = []byte("pgdeactivate") - pgfault = []byte("pgfault") - pgmajfault = []byte("pgmajfault") - pgrefill_dma = []byte("pgrefill_dma") - pgrefill_dma32 = []byte("pgrefill_dma32") - pgrefill_normal = []byte("pgrefill_normal") - pgrefill_movable = []byte("pgrefill_movable") - pgsteal_dma = []byte("pgsteal_dma") - pgsteal_dma32 = []byte("pgsteal_dma32") - pgsteal_normal = []byte("pgsteal_normal") - pgsteal_movable = []byte("pgsteal_movable") - pgscan_kswapd_dma = []byte("pgscan_kswapd_dma") - pgscan_kswapd_dma32 = []byte("pgscan_kswapd_dma32") - pgscan_kswapd_normal = []byte("pgscan_kswapd_normal") - pgscan_kswapd_movable = []byte("pgscan_kswapd_movable") - pgscan_direct_dma = []byte("pgscan_direct_dma") - pgscan_direct_dma32 = []byte("pgscan_direct_dma32") - pgscan_direct_normal = []byte("pgscan_direct_normal") - pgscan_direct_movable = []byte("pgscan_direct_movable") - zone_reclaim_failed = []byte("zone_reclaim_failed") - pginodesteal = []byte("pginodesteal") - slabs_scanned = []byte("slabs_scanned") - kswapd_steal = []byte("kswapd_steal") - kswapd_inodesteal = []byte("kswapd_inodesteal") - kswapd_low_wmark_hit_quickly = []byte("kswapd_low_wmark_hit_quickly") - kswapd_high_wmark_hit_quickly = []byte("kswapd_high_wmark_hit_quickly") - kswapd_skip_congestion_wait = []byte("kswapd_skip_congestion_wait") - pageoutrun = []byte("pageoutrun") - allocstall = []byte("allocstall") - pgrotated = []byte("pgrotated") - compact_blocks_moved = []byte("compact_blocks_moved") - compact_pages_moved = []byte("compact_pages_moved") - compact_pagemigrate_failed = []byte("compact_pagemigrate_failed") - compact_stall = []byte("compact_stall") - compact_fail = []byte("compact_fail") - compact_success = []byte("compact_success") - htlb_buddy_alloc_success = []byte("htlb_buddy_alloc_success") - htlb_buddy_alloc_fail = []byte("htlb_buddy_alloc_fail") - unevictable_pgs_culled = []byte("unevictable_pgs_culled") - unevictable_pgs_scanned = []byte("unevictable_pgs_scanned") - unevictable_pgs_rescued = []byte("unevictable_pgs_rescued") - unevictable_pgs_mlocked = []byte("unevictable_pgs_mlocked") - unevictable_pgs_munlocked = []byte("unevictable_pgs_munlocked") - unevictable_pgs_cleared = []byte("unevictable_pgs_cleared") - unevictable_pgs_stranded = []byte("unevictable_pgs_stranded") - unevictable_pgs_mlockfreed = []byte("unevictable_pgs_mlockfreed") - thp_fault_alloc = []byte("thp_fault_alloc") - thp_fault_fallback = []byte("thp_fault_fallback") - thp_collapse_alloc = []byte("thp_collapse_alloc") - thp_collapse_alloc_failed = []byte("thp_collapse_alloc_failed") - thp_split = []byte("thp_split") -) - type KernelVmstat struct { statFile string } @@ -118,7 +22,7 @@ func (k *KernelVmstat) Description() string { } func (k *KernelVmstat) SampleConfig() string { - return `[[inputs.kernel_vmstat]]` + return "" } func (k *KernelVmstat) Gather(acc telegraf.Accumulator) error { @@ -132,7 +36,8 @@ func (k *KernelVmstat) Gather(acc telegraf.Accumulator) error { dataFields := bytes.Fields(data) for i, field := range dataFields { - // dataFields is an array of {"stat1_name", "stat1_value", "stat2_name", "stat2_value", ...} + // dataFields is an array of {"stat1_name", "stat1_value", "stat2_name", + // "stat2_value", ...} // We only want the even number index as that contain the stat name. if i%2 == 0 { // Convert the stat value into an integer.