kube_auto_analyzer 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ <html>
2
+ <head>
3
+ <script src="chartkick.js"></script>
4
+ <script src="highcharts.js"></script>
5
+ </head>
6
+ <body>
7
+ <div id="chart-1" style="height: 300px"></div>
8
+ <script>new Chartkick.LineChart("chart-1", {"2013-02-10 00:00:00 -0800": 11, "2013-02-11 00:00:00 -0800": 6})</script>
9
+
10
+ </body>
11
+ </html>
@@ -1,4 +1,5 @@
1
1
  module KubeAutoAnalyzer
2
+
2
3
  def self.report
3
4
  @log.debug("Starting Report")
4
5
  @report_file.puts "Kubernetes Analyzer"
@@ -51,6 +52,7 @@ module KubeAutoAnalyzer
51
52
  end
52
53
 
53
54
  def self.html_report
55
+
54
56
  logo_path = File.join(__dir__, "data-logo.b64")
55
57
  logo = File.open(logo_path).read
56
58
  @log.debug("Starting HTML Report")
@@ -99,15 +101,88 @@ module KubeAutoAnalyzer
99
101
  padding: 6px 6px 6px 12px;
100
102
  color: #333333;
101
103
  }
104
+ .container{
105
+ display: flex;
106
+ }
107
+ .fixed{
108
+ width: 300px;
109
+ }
110
+ .flex-item{
111
+ flex-grow: 1;
112
+ }
102
113
  </style>
103
114
  </head>
104
115
  <body>
105
116
 
106
117
  '
118
+ chartkick_path = File.join(__dir__, "js_files/chartkick.js")
119
+ chartkick = File.open(chartkick_path).read
120
+ highcharts_path = File.join(__dir__, "js_files/highcharts.js")
121
+ highcharts = File.open(highcharts_path).read
122
+ @html_report_file.puts "<script>#{chartkick}</script>"
123
+ @html_report_file.puts "<script>#{highcharts}</script>"
107
124
  @html_report_file.puts '<img width="100" height="100" align="right"' + " src=#{logo} />"
108
125
  @html_report_file.puts "<h1>Kubernetes Auto Analyzer</h1>"
109
126
  @html_report_file.puts "<br><b>Server Reviewed : </b> #{@options.target_server}"
110
127
  @html_report_file.puts '<br><br><div class="master-node"><h2>Master Node Results</h2><br>'
128
+ #Charting setup counts for the passes and fails
129
+ api_server_pass = 0
130
+ api_server_fail = 0
131
+ @results[@options.target_server]['api_server'].each do |test, result|
132
+ if result == "Pass"
133
+ api_server_pass = api_server_pass + 1
134
+ elsif result == "Fail"
135
+ api_server_fail = api_server_fail + 1
136
+ end
137
+ end
138
+
139
+ #Not a lot of point in scheduler when there's only one check...
140
+ #scheduler_pass = 0
141
+ #scheduler_fail = 0
142
+ #@results[@options.target_server]['scheduler'].each do |test, result|
143
+ # if result == "Pass"
144
+ # scheduler_pass = scheduler_pass + 1
145
+ # elsif result == "Fail"
146
+ # scheduler_fail = scheduler_fail + 1
147
+ # end
148
+ #end
149
+
150
+ controller_manager_pass = 0
151
+ controller_manager_fail = 0
152
+ @results[@options.target_server]['controller_manager'].each do |test, result|
153
+ if result == "Pass"
154
+ controller_manager_pass = controller_manager_pass + 1
155
+ elsif result == "Fail"
156
+ controller_manager_fail = controller_manager_fail + 1
157
+ end
158
+ end
159
+
160
+ etcd_pass = 0
161
+ etcd_fail = 0
162
+ @results[@options.target_server]['etcd'].each do |test, result|
163
+ if result == "Pass"
164
+ etcd_pass = etcd_pass + 1
165
+ elsif result == "Fail"
166
+ etcd_fail = etcd_fail + 1
167
+ end
168
+ end
169
+
170
+ #Start of Chart Divs
171
+ @html_report_file.puts '<div class="container">'
172
+ #API Server Chart
173
+ @html_report_file.puts '<div class="fixed" id="chart-1" style="height: 300px; width: 300px; text-align: center; color: #999; line-height: 300px; font-size: 14px;font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;"></div>'
174
+ @html_report_file.puts '<script>new Chartkick.PieChart("chart-1", {"pass": ' + api_server_pass.to_s + ', "fail": ' + api_server_fail.to_s + '}, {"colors":["green","red"], "library":{"title":{"text":"API Server Results"},"chart":{"backgroundColor":"#F5F5F5"}}})</script>'
175
+ #Scheduler Chart
176
+ #@html_report_file.puts '<div class="flex-item" id="chart-2" style="height: 300px; width: 300px; text-align: center; color: #999; line-height: 300px; font-size: 14px;font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;"></div>'
177
+ #@html_report_file.puts '<script>new Chartkick.PieChart("chart-2", {"pass": ' + scheduler_pass.to_s + ', "fail": ' + scheduler_fail.to_s + '}, {"colors":["green","red"], "library":{"title":{"text":"Scheduler Results"},"chart":{"backgroundColor":"#F5F5F5"}}})</script>'
178
+ #Controller Manager Chart
179
+ @html_report_file.puts '<div class="fixed" id="chart-2" style="height: 300px; width: 300px; text-align: center; color: #999; line-height: 300px; font-size: 14px;font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;"></div>'
180
+ @html_report_file.puts '<script>new Chartkick.PieChart("chart-2", {"pass": ' + controller_manager_pass.to_s + ', "fail": ' + controller_manager_fail.to_s + '}, {"colors":["green","red"], "library":{"title":{"text":"Controller Manager Results"},"chart":{"backgroundColor":"#F5F5F5"}}})</script>'
181
+ #etcd Chart
182
+ @html_report_file.puts '<div class="fixed" id="chart-3" style="height: 300px; width: 300px; text-align: center; color: #999; line-height: 300px; font-size: 14px;font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;"></div>'
183
+ @html_report_file.puts '<script>new Chartkick.PieChart("chart-3", {"pass": ' + etcd_pass.to_s + ', "fail": ' + etcd_fail.to_s + '}, {"colors":["green","red"], "library":{"title":{"text":"etcd Results"},"chart":{"backgroundColor":"#F5F5F5"}}})</script>'
184
+ #End of Chart Divs
185
+ @html_report_file.puts '</div>'
111
186
  @html_report_file.puts "<h2>API Server</h2>"
112
187
  @html_report_file.puts "<table><thead><tr><th>Check</th><th>result</th></tr></thead>"
113
188
  @results[@options.target_server]['api_server'].each do |test, result|
@@ -167,6 +242,32 @@ module KubeAutoAnalyzer
167
242
  @html_report_file.puts "</table></div>"
168
243
  if @options.agent_checks
169
244
  @html_report_file.puts '<br><br><div class="worker-node"><h2>Worker Node Results</h2>'
245
+
246
+ #Start of Chart Divs
247
+ @html_report_file.puts '<div class="container">'
248
+ @results[@options.target_server]['kubelet_checks'].each do |node, results|
249
+ node_kubelet_pass = 0
250
+ node_kubelet_fail = 0
251
+ results.each do |test, result|
252
+ if result == "Fail"
253
+ node_kubelet_fail = node_kubelet_fail + 1
254
+ elsif result == "Pass"
255
+ node_kubelet_pass = node_kubelet_pass + 1
256
+ end
257
+ end
258
+
259
+
260
+ #Create the Chart
261
+ @html_report_file.puts '<div class="fixed" id="' + node + '" style="height: 300px; width: 300px; text-align: center; color: #999; line-height: 300px; font-size: 14px;font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;"></div>'
262
+ @html_report_file.puts '<script>new Chartkick.PieChart("' + node + '", {"pass": ' + node_kubelet_pass.to_s + ', "fail": ' + node_kubelet_fail.to_s + '}, {"colors":["green","red"], "library":{"title":{"text":"' + node + ' Kubelet Results"},"chart":{"backgroundColor":"#F5F5F5"}}})</script>'
263
+
264
+ end
265
+
266
+
267
+
268
+ #End of Chart Divs
269
+ @html_report_file.puts '</div>'
270
+
170
271
  @results[@options.target_server]['kubelet_checks'].each do |node, results|
171
272
  @html_report_file.puts "<br><b>#{node} Kubelet Checks</b>"
172
273
  @html_report_file.puts "<table><thead><tr><th>Check</th><th>result</th></tr></thead>"
@@ -1,3 +1,3 @@
1
1
  module KubeAutoAnalyzer
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kube_auto_analyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rory McCune
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-23 00:00:00.000000000 Z
11
+ date: 2017-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -69,6 +69,9 @@ files:
69
69
  - lib/kube_auto_analyzer/agent_checks/process_checks.rb
70
70
  - lib/kube_auto_analyzer/api_checks/master_node.rb
71
71
  - lib/kube_auto_analyzer/data-logo.b64
72
+ - lib/kube_auto_analyzer/js_files/chartkick.js
73
+ - lib/kube_auto_analyzer/js_files/highcharts.js
74
+ - lib/kube_auto_analyzer/js_files/test.html
72
75
  - lib/kube_auto_analyzer/reporting.rb
73
76
  - lib/kube_auto_analyzer/utility/network.rb
74
77
  - lib/kube_auto_analyzer/version.rb