github.com/netdata/go.d.plugin@v0.58.1/modules/windows/collect_memory.go (about)

     1  // SPDX-License-Identifier: GPL-3.0-or-later
     2  
     3  package windows
     4  
     5  import (
     6  	"github.com/netdata/go.d.plugin/pkg/prometheus"
     7  )
     8  
     9  const (
    10  	metricMemAvailBytes                      = "windows_memory_available_bytes"
    11  	metricMemCacheFaultsTotal                = "windows_memory_cache_faults_total"
    12  	metricMemCommitLimit                     = "windows_memory_commit_limit"
    13  	metricMemCommittedBytes                  = "windows_memory_committed_bytes"
    14  	metricMemModifiedPageListBytes           = "windows_memory_modified_page_list_bytes"
    15  	metricMemPageFaultsTotal                 = "windows_memory_page_faults_total"
    16  	metricMemSwapPageReadsTotal              = "windows_memory_swap_page_reads_total"
    17  	metricMemSwapPagesReadTotal              = "windows_memory_swap_pages_read_total"
    18  	metricMemSwapPagesWrittenTotal           = "windows_memory_swap_pages_written_total"
    19  	metricMemSwapPageWritesTotal             = "windows_memory_swap_page_writes_total"
    20  	metricMemPoolNonPagedBytesTotal          = "windows_memory_pool_nonpaged_bytes"
    21  	metricMemPoolPagedBytes                  = "windows_memory_pool_paged_bytes"
    22  	metricMemStandbyCacheCoreBytes           = "windows_memory_standby_cache_core_bytes"
    23  	metricMemStandbyCacheNormalPriorityBytes = "windows_memory_standby_cache_normal_priority_bytes"
    24  	metricMemStandbyCacheReserveBytes        = "windows_memory_standby_cache_reserve_bytes"
    25  )
    26  
    27  func (w *Windows) collectMemory(mx map[string]int64, pms prometheus.Series) {
    28  	if !w.cache.collection[collectorMemory] {
    29  		w.cache.collection[collectorMemory] = true
    30  		w.addMemoryCharts()
    31  	}
    32  
    33  	if pm := pms.FindByName(metricMemAvailBytes); pm.Len() > 0 {
    34  		mx["memory_available_bytes"] = int64(pm.Max())
    35  	}
    36  	if pm := pms.FindByName(metricMemCacheFaultsTotal); pm.Len() > 0 {
    37  		mx["memory_cache_faults_total"] = int64(pm.Max())
    38  	}
    39  	if pm := pms.FindByName(metricMemCommitLimit); pm.Len() > 0 {
    40  		mx["memory_commit_limit"] = int64(pm.Max())
    41  	}
    42  	if pm := pms.FindByName(metricMemCommittedBytes); pm.Len() > 0 {
    43  		mx["memory_committed_bytes"] = int64(pm.Max())
    44  	}
    45  	if pm := pms.FindByName(metricMemModifiedPageListBytes); pm.Len() > 0 {
    46  		mx["memory_modified_page_list_bytes"] = int64(pm.Max())
    47  	}
    48  	if pm := pms.FindByName(metricMemPageFaultsTotal); pm.Len() > 0 {
    49  		mx["memory_page_faults_total"] = int64(pm.Max())
    50  	}
    51  	if pm := pms.FindByName(metricMemSwapPageReadsTotal); pm.Len() > 0 {
    52  		mx["memory_swap_page_reads_total"] = int64(pm.Max())
    53  	}
    54  	if pm := pms.FindByName(metricMemSwapPagesReadTotal); pm.Len() > 0 {
    55  		mx["memory_swap_pages_read_total"] = int64(pm.Max())
    56  	}
    57  	if pm := pms.FindByName(metricMemSwapPagesWrittenTotal); pm.Len() > 0 {
    58  		mx["memory_swap_pages_written_total"] = int64(pm.Max())
    59  	}
    60  	if pm := pms.FindByName(metricMemSwapPageWritesTotal); pm.Len() > 0 {
    61  		mx["memory_swap_page_writes_total"] = int64(pm.Max())
    62  	}
    63  	if pm := pms.FindByName(metricMemPoolNonPagedBytesTotal); pm.Len() > 0 {
    64  		mx["memory_pool_nonpaged_bytes_total"] = int64(pm.Max())
    65  	}
    66  	if pm := pms.FindByName(metricMemPoolPagedBytes); pm.Len() > 0 {
    67  		mx["memory_pool_paged_bytes"] = int64(pm.Max())
    68  	}
    69  	if pm := pms.FindByName(metricMemStandbyCacheCoreBytes); pm.Len() > 0 {
    70  		mx["memory_standby_cache_core_bytes"] = int64(pm.Max())
    71  	}
    72  	if pm := pms.FindByName(metricMemStandbyCacheNormalPriorityBytes); pm.Len() > 0 {
    73  		mx["memory_standby_cache_normal_priority_bytes"] = int64(pm.Max())
    74  	}
    75  	if pm := pms.FindByName(metricMemStandbyCacheReserveBytes); pm.Len() > 0 {
    76  		mx["memory_standby_cache_reserve_bytes"] = int64(pm.Max())
    77  	}
    78  }