MCPcopy
hub / github.com/prometheus/node_exporter / collectSystemState

Method collectSystemState

collector/systemd_linux.go:435–446  ·  view source on GitHub ↗
(conn *dbus.Conn, ch chan<- prometheus.Metric)

Source from the content-addressed store, hash-verified

433}
434
435func (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
448func newSystemdDbusConn() (*dbus.Conn, error) {
449 if *systemdPrivate {

Callers 1

UpdateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected