os: further improve naming. use original WMI names as help text

This commit is contained in:
Martin Lindhe
2016-08-26 14:19:08 +02:00
parent 7a8add3bd8
commit 92744d71fb
2 changed files with 60 additions and 60 deletions

View File

@@ -13,88 +13,89 @@ import (
// A OSCollector is a Prometheus collector for WMI Win32_OperatingSystem metrics // A OSCollector is a Prometheus collector for WMI Win32_OperatingSystem metrics
type OSCollector struct { type OSCollector struct {
FreePhysicalMemoryBytes *prometheus.Desc PhysicalMemoryFreeBytes *prometheus.Desc
FreeSpaceInPagingFilesBytes *prometheus.Desc PagingFreeBytes *prometheus.Desc
FreeVirtualMemoryBytes *prometheus.Desc VirtualMemoryFreeBytes *prometheus.Desc
ProcessesMax *prometheus.Desc ProcessesMax *prometheus.Desc
ProcessMemoryBytesBytes *prometheus.Desc ProcessMemoryMaxBytes *prometheus.Desc
Processes *prometheus.Desc Processes *prometheus.Desc
Users *prometheus.Desc Users *prometheus.Desc
SizeStoredInPagingFilesBytes *prometheus.Desc PagingMaxBytes *prometheus.Desc
VirtualMemoryBytesTotal *prometheus.Desc VirtualMemoryBytes *prometheus.Desc
VisibleMemoryBytesTotal *prometheus.Desc VisibleMemoryBytes *prometheus.Desc
} }
// NewOSCollector ... // NewOSCollector ...
func NewOSCollector() *OSCollector { func NewOSCollector() *OSCollector {
return &OSCollector{ return &OSCollector{
FreePhysicalMemoryBytes: prometheus.NewDesc(
prometheus.BuildFQName(wmiNamespace, "os", "free_physical_memory_bytes"), PagingMaxBytes: prometheus.NewDesc(
"Physical memory currently unused and available.", prometheus.BuildFQName(wmiNamespace, "os", "paging_max_bytes"),
"SizeStoredInPagingFiles",
nil, nil,
nil, nil,
), ),
FreeSpaceInPagingFilesBytes: prometheus.NewDesc( PagingFreeBytes: prometheus.NewDesc(
prometheus.BuildFQName(wmiNamespace, "os", "free_space_in_paging_files_bytes"), prometheus.BuildFQName(wmiNamespace, "os", "paging_free_bytes"),
"Number of bytes that can be mapped into the operating system paging files without causing any other pages to be swapped out.", "FreeSpaceInPagingFiles",
nil, nil,
nil, nil,
), ),
FreeVirtualMemoryBytes: prometheus.NewDesc( PhysicalMemoryFreeBytes: prometheus.NewDesc(
prometheus.BuildFQName(wmiNamespace, "os", "free_virtual_memory_bytes"), prometheus.BuildFQName(wmiNamespace, "os", "physical_memory_free_bytes"),
"Virtual memory currently unused and available.", "FreePhysicalMemory",
nil,
nil,
),
ProcessesMax: prometheus.NewDesc(
prometheus.BuildFQName(wmiNamespace, "os", "processes_max"),
"Maximum number of process contexts the operating system can support.",
nil,
nil,
),
ProcessMemoryBytesBytes: prometheus.NewDesc(
prometheus.BuildFQName(wmiNamespace, "os", "process_memory_bytes_max"),
"Maximum bytes of memory that can be allocated to a process.",
nil, nil,
nil, nil,
), ),
Processes: prometheus.NewDesc( Processes: prometheus.NewDesc(
prometheus.BuildFQName(wmiNamespace, "os", "processes"), prometheus.BuildFQName(wmiNamespace, "os", "processes"),
"Number of process contexts currently loaded or running on the operating system.", "NumberOfProcesses",
nil,
nil,
),
ProcessesMax: prometheus.NewDesc(
prometheus.BuildFQName(wmiNamespace, "os", "processes_max"),
"MaxNumberOfProcesses",
nil,
nil,
),
ProcessMemoryMaxBytes: prometheus.NewDesc(
prometheus.BuildFQName(wmiNamespace, "os", "process_memory_max_bytes"),
"MaxProcessMemorySize",
nil, nil,
nil, nil,
), ),
Users: prometheus.NewDesc( Users: prometheus.NewDesc(
prometheus.BuildFQName(wmiNamespace, "os", "users"), prometheus.BuildFQName(wmiNamespace, "os", "users"),
"Number of user sessions for which the operating system is storing state information currently.", "NumberOfUsers",
nil, nil,
nil, nil,
), ),
SizeStoredInPagingFilesBytes: prometheus.NewDesc( VirtualMemoryBytes: prometheus.NewDesc(
prometheus.BuildFQName(wmiNamespace, "os", "size_stored_in_paging_files_bytes"), prometheus.BuildFQName(wmiNamespace, "os", "virtual_memory_bytes"),
"Total number of bytes that can be stored in the operating system paging files.", "TotalVirtualMemorySize",
nil, nil,
nil, nil,
), ),
VirtualMemoryBytesTotal: prometheus.NewDesc( VisibleMemoryBytes: prometheus.NewDesc(
prometheus.BuildFQName(wmiNamespace, "os", "virtual_memory_bytes_total"), prometheus.BuildFQName(wmiNamespace, "os", "visible_memory_bytes"),
"Total amount of virtual memory.", "TotalVisibleMemorySize",
nil, nil,
nil, nil,
), ),
VisibleMemoryBytesTotal: prometheus.NewDesc( VirtualMemoryFreeBytes: prometheus.NewDesc(
prometheus.BuildFQName(wmiNamespace, "os", "visible_memory_bytes_total"), prometheus.BuildFQName(wmiNamespace, "os", "virtual_memory_free_bytes"),
"Total amount of physical memory available to the operating system.", "FreeVirtualMemory",
nil, nil,
nil, nil,
), ),
@@ -114,16 +115,16 @@ func (c *OSCollector) Collect(ch chan<- prometheus.Metric) {
// The corresponding metric values are sent separately. // The corresponding metric values are sent separately.
func (c *OSCollector) Describe(ch chan<- *prometheus.Desc) { func (c *OSCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- c.FreePhysicalMemoryBytes ch <- c.PhysicalMemoryFreeBytes
ch <- c.FreeSpaceInPagingFilesBytes ch <- c.PagingFreeBytes
ch <- c.FreeVirtualMemoryBytes ch <- c.VirtualMemoryFreeBytes
ch <- c.ProcessesMax ch <- c.ProcessesMax
ch <- c.ProcessMemoryBytesBytes ch <- c.ProcessMemoryMaxBytes
ch <- c.Processes ch <- c.Processes
ch <- c.Users ch <- c.Users
ch <- c.SizeStoredInPagingFilesBytes ch <- c.PagingMaxBytes
ch <- c.VirtualMemoryBytesTotal ch <- c.VirtualMemoryBytes
ch <- c.VisibleMemoryBytesTotal ch <- c.VisibleMemoryBytes
} }
type Win32_OperatingSystem struct { type Win32_OperatingSystem struct {
@@ -137,8 +138,6 @@ type Win32_OperatingSystem struct {
SizeStoredInPagingFiles uint64 SizeStoredInPagingFiles uint64
TotalVirtualMemorySize uint64 TotalVirtualMemorySize uint64
TotalVisibleMemorySize uint64 TotalVisibleMemorySize uint64
//NumberOfLicensedUsers *uint32 // XXX returns 0 on Win7
//TotalSwapSpaceSize *uint64 // XXX returns 0 on Win7
} }
func (c *OSCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, error) { func (c *OSCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, error) {
@@ -149,19 +148,19 @@ func (c *OSCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, er
} }
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.FreePhysicalMemoryBytes, c.PhysicalMemoryFreeBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].FreePhysicalMemory*1024), // KiB -> bytes float64(dst[0].FreePhysicalMemory*1024), // KiB -> bytes
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.FreeSpaceInPagingFilesBytes, c.PagingFreeBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].FreeSpaceInPagingFiles*1024), // KiB -> bytes float64(dst[0].FreeSpaceInPagingFiles*1024), // KiB -> bytes
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.FreeVirtualMemoryBytes, c.VirtualMemoryFreeBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].FreeVirtualMemory*1024), // KiB -> bytes float64(dst[0].FreeVirtualMemory*1024), // KiB -> bytes
) )
@@ -173,7 +172,7 @@ func (c *OSCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, er
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.ProcessMemoryBytesBytes, c.ProcessMemoryMaxBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].MaxProcessMemorySize*1024), // KiB -> bytes float64(dst[0].MaxProcessMemorySize*1024), // KiB -> bytes
) )
@@ -191,19 +190,19 @@ func (c *OSCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, er
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.SizeStoredInPagingFilesBytes, c.PagingMaxBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].SizeStoredInPagingFiles*1024), // KiB -> bytes float64(dst[0].SizeStoredInPagingFiles*1024), // KiB -> bytes
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.VirtualMemoryBytesTotal, c.VirtualMemoryBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].TotalVirtualMemorySize*1024), // KiB -> bytes float64(dst[0].TotalVirtualMemorySize*1024), // KiB -> bytes
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.VisibleMemoryBytesTotal, c.VisibleMemoryBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].TotalVisibleMemorySize*1024), // KiB -> bytes float64(dst[0].TotalVisibleMemorySize*1024), // KiB -> bytes
) )

View File

@@ -1,3 +1,4 @@
// returns data points from Win32_PerfRawData_PerfDisk_LogicalDisk
// https://msdn.microsoft.com/en-us/windows/hardware/aa394307(v=vs.71) - Win32_PerfRawData_PerfDisk_LogicalDisk class // https://msdn.microsoft.com/en-us/windows/hardware/aa394307(v=vs.71) - Win32_PerfRawData_PerfDisk_LogicalDisk class
package collectors package collectors