Method: NewRelic::Agent::SystemInfo.boot_id

Defined in:
lib/new_relic/agent/system_info.rb

.boot_idObject

[View source]

324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/new_relic/agent/system_info.rb', line 324

def self.boot_id
  return nil unless linux?

  if bid = proc_try_read('/proc/sys/kernel/random/boot_id')
    bid.chomp!

    if bid.ascii_only?
      if bid.empty?
        ::NewRelic::Agent.logger.debug('boot_id not found in /proc/sys/kernel/random/boot_id')
        ::NewRelic::Agent.increment_metric('Supportability/utilization/boot_id/error')
        nil

      elsif bid.bytesize == 36
        bid

      else
        ::NewRelic::Agent.logger.debug("Found boot_id with invalid length: #{bid}")
        ::NewRelic::Agent.increment_metric('Supportability/utilization/boot_id/error')
        bid[0, 128]

      end
    else
      ::NewRelic::Agent.logger.debug("Found boot_id with non-ASCII characters: #{bid}")
      ::NewRelic::Agent.increment_metric('Supportability/utilization/boot_id/error')
      nil

    end
  else
    ::NewRelic::Agent.logger.debug('boot_id not found in /proc/sys/kernel/random/boot_id')
    ::NewRelic::Agent.increment_metric('Supportability/utilization/boot_id/error')
    nil

  end
end