node_exporter icon indicating copy to clipboard operation
node_exporter copied to clipboard

Feature request: add os version for Mac OS (Darwin)

Open tomaszn opened this issue 2 years ago • 7 comments

Can be obtained with sw_vers:

$ sw_vers --help
Usage: sw_vers [-productName|-productVersion|-buildVersion]

$ sw_vers 
ProductName:	macOS
ProductVersion:	12.1
BuildVersion:	21C52

$ sw_vers 
ProductName:	Mac OS X
ProductVersion:	10.13.3
BuildVersion:	17D102

tomaszn avatar Jan 26 '22 09:01 tomaszn

We don't allow executing commands in the node-exporter but if there is a syscall or stdlib function to get that, we'd be open to including this.

discordianfish avatar Jan 26 '22 11:01 discordianfish

Let me share a link to the sw_vers source code.

tomaszn avatar Jan 27 '22 16:01 tomaszn

Yeah looks like they are all available via CFDictionaryGetValue. So unless this needs root permissions it should be fine to add it here.

discordianfish avatar Jan 31 '22 11:01 discordianfish

Similar values are in sysctl:

$ sysctl -a | grep kern.os
kern.ostype: Darwin
kern.osrelease: 17.4.0
kern.osrevision: 199506
kern.osversion: 17D102

$ sysctl -a | grep kern.os
kern.ostype: Darwin
kern.osrelease: 19.6.0
kern.osrevision: 199506
kern.osversion: 19H15
kern.osproductversion: 10.15.7

$ sysctl -a | grep kern.os
kern.ostype: Darwin
kern.osrelease: 21.2.0
kern.osrevision: 199506
kern.osversion: 21C52
kern.osproductversion: 12.1
kern.osproductversioncompat: 10.16
kern.osreleasetype: User

tomaszn avatar Feb 01 '22 16:02 tomaszn

I would like to work on this.

pradeepnnv avatar Jun 26 '22 05:06 pradeepnnv

I think this is already implemented.

curl http://localhost:9100/metrics |grep version

# HELP node_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which node_exporter was built.
node_exporter_build_info{branch="master",goversion="go1.18",revision="26e377dfd530655381085edb1cb3c4db9b12c816",version="1.3.1"} 1
node_uname_info{domainname="local",machine="x86_64",nodename="xxxxxxxx",release="21.2.0",sysname="Darwin",version="Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:54 PST 2021; root:xnu-8019.61.5~1/RELEASE_X86_64"} 1

Please let me know if this is still required.

pradeepnnv avatar Jun 26 '22 05:06 pradeepnnv

It's about node_os_info and node_os_version metrics implemented for Linux in #1574 (after a discussion of it's needed).

tomaszn avatar Jun 26 '22 10:06 tomaszn

This issue can be closed since the feature has been implemented with https://github.com/prometheus/node_exporter/pull/2471

maltelehmann avatar Mar 24 '24 12:03 maltelehmann