Merge pull request #1317 from DiniFarb/os_rev_num

feat(#1300): add revision to windows_os_info
This commit is contained in:
Ben Reedy 2023-11-12 14:45:51 +10:00 committed by GitHub
commit 569f5450cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,7 +53,7 @@ func newOSCollector(logger log.Logger) (Collector, error) {
OSInformation: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "info"),
"OperatingSystem.Caption, OperatingSystem.Version",
[]string{"product", "version", "major_version", "minor_version", "build_number"},
[]string{"product", "version", "major_version", "minor_version", "build_number", "revision"},
nil,
),
PagingLimitBytes: prometheus.NewDesc(
@ -199,6 +199,11 @@ func (c *OSCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) (
return nil, err
}
revision, _, err := ntKey.GetIntegerValue("UBR")
if err != nil {
return nil, err
}
var fsipf float64
for _, pagingFile := range pagingFiles {
fileString := strings.ReplaceAll(pagingFile, `\??\`, "")
@ -242,6 +247,7 @@ func (c *OSCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) (
fmt.Sprintf("%d", nwgi.VersionMajor), // Major Version
fmt.Sprintf("%d", nwgi.VersionMinor), // Minor Version
bn, // Build number
fmt.Sprintf("%d", revision), // Revision
)
ch <- prometheus.MustNewConstMetric(