Class: Risu::Templates::MSWSUSFindingsTemplate

Inherits:
Base::TemplateBase show all
Defined in:
lib/risu/templates/ms_wsus_findings.rb

Instance Attribute Summary

Attributes inherited from Base::TemplateBase

#output, #template_info

Instance Method Summary collapse

Methods inherited from Base::TemplateBase

inherited

Constructor Details

#initializeMSWSUSFindingsTemplate

Initializes the template loading meta-data



27
28
29
30
31
32
33
34
35
36
# File 'lib/risu/templates/ms_wsus_findings.rb', line 27

def initialize
	@template_info =
	{
		:name => "ms_wsus_findings",
		:author => "hammackj",
		:version => "0.0.2",
		:renderer => "PDF",
		:description => "Generates a report based on the findings of the Patch Management: WSUS Report plugin"
	}
end

Instance Method Details

#render(output) ⇒ Object

Called during the rendering process



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/risu/templates/ms_wsus_findings.rb', line 40

def render output
	output.text Report.classification.upcase, :align => :center
	output.text "\n"

	output.font_size(22) { output.text Report.title, :align => :center }
	output.font_size(18) {
		output.text "Patch Management: WSUS Report", :align => :center
		output.text "\n"
		output.text "This report was prepared by\n#{Report.author}", :align => :center
	}

	output.text "\n\n\n"

	output.font_size 12

	results = Item.where(:plugin_id => 58133)

	results.each do |item|
		if item.plugin_output == nil
			next
		end

		if item.plugin_output =~ /This system is not managed by or has not yet reported to the WSUS server./
			next
		end

		item.plugin_output.scan(/\+ WSUS Computer Information \r?\n?\r?\n?\r?\n?    FQDN : (.*)\r?\n?    IP Address : (.*)\r?\n?    Last Sync Time : (.*)\r?\n?    Last Reported Status : (.*)\r?\n?    Last Sync Result : (.*)$/).each do
			|fqdn, ip, last_sync_time, last_reported_status, last_sync_result|

			output.text "Host: #{ip} (#{fqdn})"
			output.text "Last Sync Time: #{last_sync_time}"
			output.text "Last Reported Status: #{last_reported_status}"
			output.text "Last Sync Result: #{last_sync_result}"
		end

		output.text "\n"

		output.font_size 10

		item.plugin_output.scan(/^\d* :(.*)\n    Patch State : (.*)\n    Microsoft KB : (.*)\n    severity : (.*)\n    Bulletin Date : (.*)\n    Patch Link : (.*)\n    Description : (.*)\n\r?\n?/).each do
			|name, patch_state, kb, severity, date, link, description|
			output.text "Name: #{name}"
			output.text "State: #{patch_state}"
			output.text "Severity: #{severity}"
			output.text "Release date: #{date}"
			output.text "Link: #{link}"
			output.text "Description: #{description}"
			output.text "\n"
		end
	end
end