fix: Continue os collection on missing page file

Signed-off-by: Ben Reedy <breed808@breed808.com>
This commit is contained in:
Ben Reedy 2022-12-16 21:57:44 +10:00
parent 1493a20262
commit 29086368ac
No known key found for this signature in database
GPG Key ID: 235C15B6086C9D7E

View File

@ -202,11 +202,13 @@ 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())
}
}
gpi, err := psapi.GetPerformanceInfo()
if err != nil {