diff --git a/systemd/systemd.go b/systemd/systemd.go index 94bc672..942b343 100644 --- a/systemd/systemd.go +++ b/systemd/systemd.go @@ -44,7 +44,6 @@ var ( systemdUser = kingpin.Flag("systemd.collector.user", "Connect to the user systemd instance.").Bool() enableRestartsMetrics = kingpin.Flag("systemd.collector.enable-restart-count", "Enables service restart count metrics. This feature only works with systemd 235 and above.").Bool() enableIPAccountingMetrics = kingpin.Flag("systemd.collector.enable-ip-accounting", "Enables service ip accounting metrics. This feature only works with systemd 235 and above.").Bool() - bootTimeRE = regexp.MustCompile(`\d+`) ) var unitStatesName = []string{"active", "activating", "deactivating", "inactive", "failed"} @@ -366,15 +365,12 @@ func (c *Collector) collectBootStageTimestamps(conn *dbus.Conn, ch chan<- promet stageMonotonic := strings.TrimPrefix(strings.TrimSuffix(stageMonotonicValue, `"`), `"`) stageTimestamp := strings.TrimPrefix(strings.TrimSuffix(stageTimestampValue, `"`), `"`) - parsedStageMonotonic := bootTimeRE.FindString(stageMonotonic) - parsedStageTime := bootTimeRE.FindString(stageTimestamp) - - vMonotonic, err := strconv.ParseFloat(parsedStageMonotonic, 64) + vMonotonic, err := strconv.ParseFloat(strings.TrimLeft(stageMonotonic, "@t "), 64) if err != nil { return err } - vTimestamp, err := strconv.ParseFloat(parsedStageTime, 64) + vTimestamp, err := strconv.ParseFloat(strings.TrimLeft(stageTimestamp, "@t "), 64) if err != nil { return err }