systemd_status

Types

pub type ActiveState {
  Active
  Reloading
  Inactive
  Failed
  Activating
  Deactivating
}

Constructors

  • Active
  • Reloading
  • Inactive
  • Failed
  • Activating
  • Deactivating
pub type LoadState {
  Loaded
  NotFound
  BadSetting
  LoadError
  Masked
}

Constructors

  • Loaded
  • NotFound
  • BadSetting
  • LoadError
  • Masked

A service type unit.

pub type Service {
  Service(
    id: String,
    type_: ServiceType,
    load_state: LoadState,
    active_state: ActiveState,
    sub_state: String,
    result: String,
    description: Option(String),
    main_pid: Option(Int),
    state_change_timestamp: Option(String),
    active_enter_timestamp: Option(String),
    active_exit_timestamp: Option(String),
    inactive_enter_timestamp: Option(String),
    inactive_exit_timestamp: Option(String),
  )
}

Constructors

  • Service(
      id: String,
      type_: ServiceType,
      load_state: LoadState,
      active_state: ActiveState,
      sub_state: String,
      result: String,
      description: Option(String),
      main_pid: Option(Int),
      state_change_timestamp: Option(String),
      active_enter_timestamp: Option(String),
      active_exit_timestamp: Option(String),
      inactive_enter_timestamp: Option(String),
      inactive_exit_timestamp: Option(String),
    )
pub type ServiceType {
  SimpleService
  OneshotService
  OtherServiceType(name: String)
}

Constructors

  • SimpleService
  • OneshotService
  • OtherServiceType(name: String)

Functions

pub fn parse_service(input: String) -> Result(Service, String)

Parse a property list for a service unit into a Service.

The property list can be fetched by running the command returned by the unit_property_list_command function.

If the property list is not for a service unit then it will fail to parse.

If the property list is for multiple units (that is, if it contains a double newline) only the first unit will be parsed.

pub fn unit_property_list_command(
  unit: String,
) -> #(String, List(String))

A command you can run to get the information needed by this library about a unit to be able to parse it using parse_service.

Wildcards can be used in the unit name to get information about multiple units. In this case the properties for each unit will be separated by two newlines ("\n\n").

Security

This command runs systemctl. On a machine with systemd installed this is safe, however if the executable systemctl has not been provided by systemd then this unknown executable will be run with the provided arguments, which could be harmful. Do not run commands unless you are confident it is safe to do so.

Search Document