mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-24 21:56:36 +00:00
Merge pull request #954 from breed808/os_paging
Continue OS collector on absent paging file
This commit is contained in:
@@ -179,11 +179,7 @@ func (c *OSCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) (
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
pagingFiles, _, err := memManKey.GetStringsValue("ExistingPageFiles")
|
pagingFiles, _, pagingErr := memManKey.GetStringsValue("ExistingPageFiles")
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get build number and product name from registry
|
// Get build number and product name from registry
|
||||||
ntKey, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
|
ntKey, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
|
||||||
defer ntKey.Close()
|
defer ntKey.Close()
|
||||||
@@ -261,12 +257,21 @@ func (c *OSCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) (
|
|||||||
timezoneName,
|
timezoneName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
if pagingErr == nil {
|
||||||
c.PagingFreeBytes,
|
ch <- prometheus.MustNewConstMetric(
|
||||||
prometheus.GaugeValue,
|
c.PagingFreeBytes,
|
||||||
pfb,
|
prometheus.GaugeValue,
|
||||||
)
|
pfb,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.PagingLimitBytes,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
fsipf,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
log.Debugln("Could not find HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management key. windows_os_paging_free_bytes and windows_os_paging_limit_bytes will be omitted.")
|
||||||
|
}
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.VirtualMemoryFreeBytes,
|
c.VirtualMemoryFreeBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -300,12 +305,6 @@ func (c *OSCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) (
|
|||||||
float64(nwgi.LoggedOnUsers),
|
float64(nwgi.LoggedOnUsers),
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
|
||||||
c.PagingLimitBytes,
|
|
||||||
prometheus.GaugeValue,
|
|
||||||
fsipf,
|
|
||||||
)
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.VirtualMemoryBytes,
|
c.VirtualMemoryBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
|||||||
Reference in New Issue
Block a user