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
commit 25c1449b91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -202,10 +202,12 @@ func (c *OSCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) (
for _, pagingFile := range pagingFiles {
fileString := strings.ReplaceAll(pagingFile, `\??\`, "")
file, err := os.Stat(fileString)
// For unknown reasons, Windows doesn't always create a page file. Continue collection rather than aborting.
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()