Merge pull request #1108 from breed808/os_paging

fix: Continue os collection on missing page file
This commit is contained in:
Ben Reedy
2022-12-17 16:59:01 +10:00
committed by GitHub

View File

@@ -202,11 +202,13 @@ func (c *OSCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) (
for _, pagingFile := range pagingFiles { for _, pagingFile := range pagingFiles {
fileString := strings.ReplaceAll(pagingFile, `\??\`, "") fileString := strings.ReplaceAll(pagingFile, `\??\`, "")
file, err := os.Stat(fileString) file, err := os.Stat(fileString)
// For unknown reasons, Windows doesn't always create a page file. Continue collection rather than aborting.
if err != nil { if err != nil {
return nil, err log.Debugf("Failed to read page file (reason: %s): %s\n", err, fileString)
} } else {
fsipf += float64(file.Size()) fsipf += float64(file.Size())
} }
}
gpi, err := psapi.GetPerformanceInfo() gpi, err := psapi.GetPerformanceInfo()
if err != nil { if err != nil {