Module: Systemd::Id128

Defined in:
lib/systemd/id128.rb

Overview

Provides access to the 128-bit IDs for various items in the systemd ecosystem, such as the machine id and boot id.

Defined Under Namespace

Modules: Native

Class Method Summary collapse

Class Method Details

.boot_idString

Get the 128-bit hex string identifying the current system’s current boot. Can be used to filter a journal to show only messages originating from the current boot.

Examples:

Filter journal to the current boot.

j = Systemd::Journal.new
j.filter(_boot_id: Systemd::Id128.boot_id)

Returns:

  • (String)

    128-bit hex string representing the current boot.



25
26
27
# File 'lib/systemd/id128.rb', line 25

def self.boot_id
  @boot_id ||= read_id128(:sd_id128_get_boot)
end

.machine_idString

Get the 128-bit hex string identifying the current machine. Can be used to filter a journal to show only messages originating from this machine.

Examples:

Filter journal to the current machine.

j = Systemd::Journal.new
j.filter(_machine_id: Systemd::Id128.machine_id)

Returns:

  • (String)

    128-bit hex string representing the current machine.



14
15
16
# File 'lib/systemd/id128.rb', line 14

def self.machine_id
  @machine_id ||= read_id128(:sd_id128_get_machine)
end

.randomString

Get a random 128-bit hex string.

Returns:

  • (String)

    128-bit random hex string.



31
32
33
# File 'lib/systemd/id128.rb', line 31

def self.random
  read_id128(:sd_id128_randomize)
end