| 433 | } |
| 434 | |
| 435 | func (c *systemdCollector) collectSystemState(conn *dbus.Conn, ch chan<- prometheus.Metric) error { |
| 436 | systemState, err := conn.GetManagerProperty("SystemState") |
| 437 | if err != nil { |
| 438 | return fmt.Errorf("couldn't get system state: %w", err) |
| 439 | } |
| 440 | isSystemRunning := 0.0 |
| 441 | if systemState == `"running"` { |
| 442 | isSystemRunning = 1.0 |
| 443 | } |
| 444 | ch <- prometheus.MustNewConstMetric(c.systemRunningDesc, prometheus.GaugeValue, isSystemRunning) |
| 445 | return nil |
| 446 | } |
| 447 | |
| 448 | func newSystemdDbusConn() (*dbus.Conn, error) { |
| 449 | if *systemdPrivate { |