Class: AIX::Errlog::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/aix/errlog/entry.rb

Overview

An errlog entry class. Used to parse the raw errlog_entry_t struct into a more useful Ruby object.

You shouldn’t need to invoke this class directly; it is generated by the Errlog#forward_each and Errlog#reverse_each.

Unfortunately, the retreived detail and symptom fields aren’t horribly useful, and IBM has presented no API for parsing these correctly, so the only canonical path to getting the correct detail and symptom data is through a call to the errpt command.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Entry

Returns a new instance of Entry.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/aix/errlog/entry.rb', line 23

def initialize(raw)
  @magic = raw[:el_magic]
  @sequence = raw[:el_sequence]
  @label = raw[:el_label].to_s.freeze
  @timestamp = Time.at(raw[:el_timestamp]).freeze
  @crcid = raw[:el_crcid]
  @errdiag = raw[:el_errdiag]
  @machineid = raw[:el_machineid].to_s.freeze
  @nodeid = raw[:el_nodeid].to_s.freeze
  @class = raw[:el_class].to_s.freeze
  @type = raw[:el_type].to_s.freeze
  @resource = raw[:el_resource].to_s.freeze
  @rclass = raw[:el_rclass].to_s.freeze
  @rtype = raw[:el_rtype].to_s.freeze
  @vpd_ibm = raw[:el_vpd_ibm].to_s.freeze
  @vpd_user = raw[:el_vpd_user].to_s.freeze
  @in = raw[:el_in].to_s
  @connwhere = raw[:el_connwhere].to_s.freeze
  @flags = raw[:el_flags]
  length = raw[:el_detail_length]
  @raw_detail = raw[:el_detail_data].to_ptr.get_bytes(0, length).freeze
  length = raw[:el_symptom_length]
  @raw_symptom = raw[:el_symptom_data].to_ptr.get_bytes(0, length).freeze
  @dup_count = raw[:el_errdup][:ed_dupcount]
  @dup_time1 = Time.at(raw[:el_errdup][:ed_time1]).freeze
  @dup_time2 = Time.at(raw[:el_errdup][:ed_time2]).freeze
  @wparid = raw[:el_wparid].to_s.freeze
end

Instance Attribute Details

#classObject (readonly)

Returns the value of attribute class.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def class
  @class
end

#connwhereObject (readonly)

Returns the value of attribute connwhere.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def connwhere
  @connwhere
end

#crcidObject (readonly)

Returns the value of attribute crcid.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def crcid
  @crcid
end

#dup_countObject (readonly)

Returns the value of attribute dup_count.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def dup_count
  @dup_count
end

#dup_time1Object (readonly)

Returns the value of attribute dup_time1.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def dup_time1
  @dup_time1
end

#dup_time2Object (readonly)

Returns the value of attribute dup_time2.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def dup_time2
  @dup_time2
end

#errdiagObject (readonly)

Returns the value of attribute errdiag.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def errdiag
  @errdiag
end

#flagsObject (readonly)

Returns the value of attribute flags.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def flags
  @flags
end

#inObject (readonly)

Returns the value of attribute in.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def in
  @in
end

#labelObject (readonly)

Returns the value of attribute label.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def label
  @label
end

#machineidObject (readonly)

Returns the value of attribute machineid.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def machineid
  @machineid
end

#magicObject (readonly)

Returns the value of attribute magic.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def magic
  @magic
end

#nodeidObject (readonly)

Returns the value of attribute nodeid.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def nodeid
  @nodeid
end

#raw_detailObject (readonly)

Returns the value of attribute raw_detail.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def raw_detail
  @raw_detail
end

#raw_symptomObject (readonly)

Returns the value of attribute raw_symptom.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def raw_symptom
  @raw_symptom
end

#rclassObject (readonly)

Returns the value of attribute rclass.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def rclass
  @rclass
end

#resourceObject (readonly)

Returns the value of attribute resource.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def resource
  @resource
end

#rtypeObject (readonly)

Returns the value of attribute rtype.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def rtype
  @rtype
end

#sequenceObject (readonly)

Returns the value of attribute sequence.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def sequence
  @sequence
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def timestamp
  @timestamp
end

#typeObject (readonly)

Returns the value of attribute type.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def type
  @type
end

#vpd_ibmObject (readonly)

Returns the value of attribute vpd_ibm.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def vpd_ibm
  @vpd_ibm
end

#vpd_userObject (readonly)

Returns the value of attribute vpd_user.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def vpd_user
  @vpd_user
end

#wparidObject (readonly)

Returns the value of attribute wparid.



21
22
23
# File 'lib/aix/errlog/entry.rb', line 21

def wparid
  @wparid
end

Instance Method Details

#detailObject



66
67
68
69
# File 'lib/aix/errlog/entry.rb', line 66

def detail
  parse_errpt unless @parsed
  @detail 
end

#errptObject



52
53
54
# File 'lib/aix/errlog/entry.rb', line 52

def errpt
  @errpt ||= %x(errpt -al#{@sequence}).freeze
end

#parse_errptObject



56
57
58
59
60
61
62
63
64
65
# File 'lib/aix/errlog/entry.rb', line 56

def parse_errpt
  unless @parsed
    @detail, @symptom = errpt.match(PARSE_REGEX).captures
    @detail ||= ''.freeze
    @symptom ||= ''.freeze
    @detail.freeze
    @symptom.freeze
    @parsed = true
  end
end

#symptomObject



70
71
72
73
# File 'lib/aix/errlog/entry.rb', line 70

def symptom
  parse_errpt unless @parsed
  @symptom 
end