mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-21 17:10:58 +01:00
collector/systemd: use regexp to extract systemd version (#1647)
Signed-off-by: paulfantom <pawel@krupa.net.pl>
This commit is contained in:
parent
a57f246579
commit
1771fc87d9
@ -469,7 +469,8 @@ func getSystemdVersion(logger log.Logger) int {
|
||||
level.Warn(logger).Log("msg", "Unable to get systemd version property, defaulting to 0")
|
||||
return 0
|
||||
}
|
||||
version = strings.Replace(version, "\"", "", 2)
|
||||
re := regexp.MustCompile(`[0-9][0-9][0-9]`)
|
||||
version = re.FindString(version)
|
||||
v, err := strconv.Atoi(version)
|
||||
if err != nil {
|
||||
level.Warn(logger).Log("msg", "Got invalid systemd version", "version", version)
|
||||
|
Loading…
Reference in New Issue
Block a user