Module: VmScanItemNteventlog

Defined in:
lib/metadata/ScanProfile/modules/VmScanItemNteventlog.rb

Instance Method Summary collapse

Instance Method Details

#parse_data(vm, data, &_blk) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/metadata/ScanProfile/modules/VmScanItemNteventlog.rb', line 10

def parse_data(vm, data, &_blk)
  if data.nil?
    d = scan_definition
    if d[:data].nil?
      if vm.rootTrees[0].guestOS == "Windows"
        begin
          st = Time.now
          $log.info "Scanning [Profile-EventLogs] information."
          yield({:msg => 'Scanning Profile-EventLogs'}) if block_given?
          ntevent = Win32EventLog.new(vm.rootTrees[0])
          ntevent.readAllLogs(d['content'])
        rescue MiqException::NtEventLogFormat
          $log.warn $!.to_s
        rescue => err
          $log.error "Win32EventLog: #{err}"
          $log.error err.backtrace.join("\n")
        ensure
          d[:data] = ntevent.xmlDoc
          $log.info "Scanning [Profile-EventLogs] information ran for [#{Time.now - st}] seconds."
        end
      end
    end
  end
end

#to_xmlObject



2
3
4
5
6
7
8
# File 'lib/metadata/ScanProfile/modules/VmScanItemNteventlog.rb', line 2

def to_xml
  xml = @xml_class.newNode('scan_item')
  xml.add_attributes('guid' => @params['guid'], 'name' => @params['name'], 'item_type' => @params['item_type'])
  d = scan_definition
  xml.root << d[:data] if d[:data]
  xml
end