log_sense 1.3.5 → 1.5.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.org +46 -0
- data/Gemfile.lock +4 -4
- data/README.org +24 -10
- data/Rakefile +17 -3
- data/exe/log_sense +24 -16
- data/ip_locations/dbip-country-lite.sqlite3 +0 -0
- data/lib/log_sense/apache_data_cruncher.rb +30 -30
- data/lib/log_sense/apache_log_line_parser.rb +12 -13
- data/lib/log_sense/apache_log_parser.rb +44 -36
- data/lib/log_sense/emitter.rb +518 -15
- data/lib/log_sense/ip_locator.rb +26 -19
- data/lib/log_sense/options_parser.rb +35 -30
- data/lib/log_sense/rails_data_cruncher.rb +8 -4
- data/lib/log_sense/rails_log_parser.rb +108 -100
- data/lib/log_sense/templates/_command_invocation.html.erb +0 -4
- data/lib/log_sense/templates/_command_invocation.txt.erb +4 -3
- data/lib/log_sense/templates/_navigation.html.erb +21 -0
- data/lib/log_sense/templates/_output_table.html.erb +2 -7
- data/lib/log_sense/templates/_output_table.txt.erb +14 -0
- data/lib/log_sense/templates/_performance.html.erb +1 -1
- data/lib/log_sense/templates/_performance.txt.erb +8 -5
- data/lib/log_sense/templates/_report_data.html.erb +2 -2
- data/lib/log_sense/templates/_summary.html.erb +6 -1
- data/lib/log_sense/templates/_summary.txt.erb +11 -8
- data/lib/log_sense/templates/_warning.txt.erb +1 -0
- data/lib/log_sense/templates/apache.html.erb +14 -335
- data/lib/log_sense/templates/apache.txt.erb +22 -0
- data/lib/log_sense/templates/rails.html.erb +13 -174
- data/lib/log_sense/templates/rails.txt.erb +10 -60
- data/lib/log_sense/version.rb +1 -1
- metadata +6 -2
| @@ -1,7 +1,9 @@ | |
| 1 1 | 
             
            <!doctype html>
         | 
| 2 2 | 
             
            <html class="no-js" lang="en">
         | 
| 3 3 | 
             
              <head>
         | 
| 4 | 
            -
                <title | 
| 4 | 
            +
                <title>
         | 
| 5 | 
            +
                  <%= options[:title] || "Log Sense: #{data[:filenames].empty? ? "stdin" : data[:filenames].join(", ")}" %>
         | 
| 6 | 
            +
                </title>
         | 
| 5 7 |  | 
| 6 8 | 
             
                <meta charset="utf-8" />
         | 
| 7 9 | 
             
                <meta http-equiv="x-ua-compatible" content="ie=edge">
         | 
| @@ -150,43 +152,11 @@ | |
| 150 152 | 
             
              <body>
         | 
| 151 153 | 
             
                <div class="off-canvas-wrapper">
         | 
| 152 154 | 
             
                  <div class="off-canvas position-left" id="offCanvas" data-off-canvas>
         | 
| 153 | 
            -
                     | 
| 154 | 
            -
             | 
| 155 | 
            -
             | 
| 156 | 
            -
                            <% [ "Summary",
         | 
| 157 | 
            -
                              "Log Structure",
         | 
| 158 | 
            -
                              "Daily Distribution",
         | 
| 159 | 
            -
                              "Time Distribution",
         | 
| 160 | 
            -
                              "Most Requested Pages",
         | 
| 161 | 
            -
                              "Most Requested Resources",
         | 
| 162 | 
            -
                              "404 on HTML Files",
         | 
| 163 | 
            -
                              "404 on other Resources",
         | 
| 164 | 
            -
                              "Attacks",
         | 
| 165 | 
            -
                              "Statuses",
         | 
| 166 | 
            -
                              "Daily Statuses",
         | 
| 167 | 
            -
                              "Browsers",
         | 
| 168 | 
            -
                              "Platforms",
         | 
| 169 | 
            -
                              "Referers",
         | 
| 170 | 
            -
                              "IPs",
         | 
| 171 | 
            -
                              "Geolocation",
         | 
| 172 | 
            -
                              "Streaks",
         | 
| 173 | 
            -
                              "Command Invocation",
         | 
| 174 | 
            -
                              "Performance"
         | 
| 175 | 
            -
                        ].each do |item| %>
         | 
| 176 | 
            -
                              <li class="nav-item">
         | 
| 177 | 
            -
                                <a href="#<%= item.downcase.gsub(' ', '-') %>" data-close><%= item %></a>
         | 
| 178 | 
            -
                          </li>
         | 
| 179 | 
            -
                        <% end %>
         | 
| 180 | 
            -
                      </ul>
         | 
| 181 | 
            -
             | 
| 182 | 
            -
                      <p>
         | 
| 183 | 
            -
                        Generated by
         | 
| 184 | 
            -
                        <a href="https://github.com/avillafiorita/log_sense">LogSense</a> <br />
         | 
| 185 | 
            -
                        on <%= DateTime.now.strftime("%Y-%m-%d %H:%M") %>.<br />
         | 
| 186 | 
            -
                        <a href='https://db-ip.com'>IP Geolocation by DB-IP</a>
         | 
| 187 | 
            -
                      </p>
         | 
| 188 | 
            -
                    </nav>
         | 
| 155 | 
            +
                    <%= render "navigation.html.erb",
         | 
| 156 | 
            +
                               menus: Emitter::apache_report_specification.map { |x| x[:title] }  +
         | 
| 157 | 
            +
                               ["Streaks", "Command Invocation", "Performance"] %>
         | 
| 189 158 | 
             
                  </div>
         | 
| 159 | 
            +
                  
         | 
| 190 160 | 
             
                  <div class="off-canvas-content grid-container grid-x fluid" data-off-canvas-content>
         | 
| 191 161 | 
             
                    <div data-sticky-container>
         | 
| 192 162 | 
             
                      <div class="sticky" data-sticky data-margin-top="0">
         | 
| @@ -197,14 +167,14 @@ | |
| 197 167 | 
             
                    </div>
         | 
| 198 168 |  | 
| 199 169 | 
             
                    <section class="main-section">
         | 
| 200 | 
            -
                      <h1><%= options[:title] || "Log Sense | 
| 170 | 
            +
                      <h1><%= options[:title] || "Log Sense Apache Log Report" %></h1>
         | 
| 201 171 |  | 
| 202 | 
            -
                      <p><b>Input File:</b>  <%=  | 
| 172 | 
            +
                      <p><b>Input File(s):</b>  <%= data[:filenames].empty? ? "stdin" : data[:filenames].join(", ") %></p>
         | 
| 203 173 |  | 
| 204 174 | 
             
                      <div class="grid-x grid-margin-x">
         | 
| 205 175 | 
             
                        <article class="card small-12 large-6 cell">
         | 
| 206 176 | 
             
                          <div class="card-divider">
         | 
| 207 | 
            -
                            <h2 id=" | 
| 177 | 
            +
                            <h2 id="<%= Emitter::slugify "Summary" %>">Summary</h2>
         | 
| 208 178 | 
             
                          </div>
         | 
| 209 179 | 
             
                          <div class="card-section">
         | 
| 210 180 | 
             
                            <%= render "summary.html.erb", data: data %>
         | 
| @@ -213,7 +183,7 @@ | |
| 213 183 |  | 
| 214 184 | 
             
                        <article class="card cell small-12 large-6">
         | 
| 215 185 | 
             
                          <div class="card-divider">
         | 
| 216 | 
            -
                            <h2 id=" | 
| 186 | 
            +
                            <h2 id="<%= Emitter::slugify "Summary" %>">Log Structure</h2>
         | 
| 217 187 | 
             
                          </div>
         | 
| 218 188 | 
             
                          <div class="card-section">
         | 
| 219 189 | 
             
                            <%= render "log_structure.html.erb", data: data %>
         | 
| @@ -221,210 +191,11 @@ | |
| 221 191 | 
             
                        </article>
         | 
| 222 192 | 
             
                      </div>
         | 
| 223 193 |  | 
| 224 | 
            -
                      <% @reports = [
         | 
| 225 | 
            -
                        { title: "Daily Distribution",
         | 
| 226 | 
            -
                          header: ["Day", "DOW", "Hits", "Visits", "Size"],
         | 
| 227 | 
            -
                          rows: data[:daily_distribution],
         | 
| 228 | 
            -
                          vega_spec: {
         | 
| 229 | 
            -
                            "layer": [
         | 
| 230 | 
            -
                              {
         | 
| 231 | 
            -
                                "mark": {
         | 
| 232 | 
            -
                                  "type": "line",
         | 
| 233 | 
            -
                                  "point": {
         | 
| 234 | 
            -
                                    "filled": false,
         | 
| 235 | 
            -
                                    "fill": "white"
         | 
| 236 | 
            -
                                  }
         | 
| 237 | 
            -
                                },
         | 
| 238 | 
            -
                                "encoding": {
         | 
| 239 | 
            -
                                  "y": {"field": "Hits", "type": "quantitative"}
         | 
| 240 | 
            -
                                }
         | 
| 241 | 
            -
                              },
         | 
| 242 | 
            -
                              {
         | 
| 243 | 
            -
                                "mark": {
         | 
| 244 | 
            -
                                  "type": "text",
         | 
| 245 | 
            -
                                  "color": "#3E5772",
         | 
| 246 | 
            -
                                  "align": "middle",
         | 
| 247 | 
            -
                                  "baseline": "top",
         | 
| 248 | 
            -
                                  "dx": -10,
         | 
| 249 | 
            -
                                  "yOffset": -15
         | 
| 250 | 
            -
                                },
         | 
| 251 | 
            -
                                "encoding": {
         | 
| 252 | 
            -
                                  "text": {"field": "Hits", "type": "quantitative"},
         | 
| 253 | 
            -
                                  "y": {"field": "Hits", "type": "quantitative"}
         | 
| 254 | 
            -
                                }
         | 
| 255 | 
            -
                              },
         | 
| 256 | 
            -
             | 
| 257 | 
            -
                              {
         | 
| 258 | 
            -
                                "mark": {
         | 
| 259 | 
            -
                                  "type": "line",
         | 
| 260 | 
            -
                                  "color": "#A52A2A",
         | 
| 261 | 
            -
                                  "point": {
         | 
| 262 | 
            -
                                    "color": "#A52A2A",
         | 
| 263 | 
            -
                                    "filled": false,
         | 
| 264 | 
            -
                                    "fill": "white",
         | 
| 265 | 
            -
                                  }
         | 
| 266 | 
            -
                                },
         | 
| 267 | 
            -
                                "encoding": {
         | 
| 268 | 
            -
                                  "y": {"field": "Visits", "type": "quantitative"}
         | 
| 269 | 
            -
                                }
         | 
| 270 | 
            -
                              },
         | 
| 271 | 
            -
             | 
| 272 | 
            -
                              {
         | 
| 273 | 
            -
                                "mark": {
         | 
| 274 | 
            -
                                  "type": "text",
         | 
| 275 | 
            -
                                  "color": "#A52A2A",
         | 
| 276 | 
            -
                                  "align": "middle",
         | 
| 277 | 
            -
                                  "baseline": "top",
         | 
| 278 | 
            -
                                  "dx": -10,
         | 
| 279 | 
            -
                                  "yOffset": -15
         | 
| 280 | 
            -
                                },
         | 
| 281 | 
            -
                                "encoding": {
         | 
| 282 | 
            -
                                  "text": {"field": "Visits", "type": "quantitative"},
         | 
| 283 | 
            -
                                  "y": {"field": "Visits", "type": "quantitative"}
         | 
| 284 | 
            -
                                }
         | 
| 285 | 
            -
                              },
         | 
| 286 | 
            -
                              
         | 
| 287 | 
            -
                            ],
         | 
| 288 | 
            -
                            "encoding": {
         | 
| 289 | 
            -
                              "x": {"field": "Day", "type": "temporal"},
         | 
| 290 | 
            -
                            }
         | 
| 291 | 
            -
                          }
         | 
| 292 | 
            -
                          
         | 
| 293 | 
            -
                        },
         | 
| 294 | 
            -
                        { title: "Time Distribution",
         | 
| 295 | 
            -
                          header: ["Hour", "Hits", "Visits", "Size"],
         | 
| 296 | 
            -
                          rows: data[:time_distribution],
         | 
| 297 | 
            -
                          vega_spec: {
         | 
| 298 | 
            -
                            "layer": [
         | 
| 299 | 
            -
                              {
         | 
| 300 | 
            -
                                "mark": "bar"
         | 
| 301 | 
            -
                              },
         | 
| 302 | 
            -
                              {
         | 
| 303 | 
            -
                                "mark": {
         | 
| 304 | 
            -
                                  "type": "text",
         | 
| 305 | 
            -
                                  "align": "middle",
         | 
| 306 | 
            -
                                  "baseline": "top",
         | 
| 307 | 
            -
                                  "dx": -10,
         | 
| 308 | 
            -
                                  "yOffset": -15
         | 
| 309 | 
            -
                                },
         | 
| 310 | 
            -
                                "encoding": {
         | 
| 311 | 
            -
                                  "text": {"field": "Hits", "type": "quantitative"},
         | 
| 312 | 
            -
                                  "y": {"field": "Hits", "type": "quantitative"}
         | 
| 313 | 
            -
                                }
         | 
| 314 | 
            -
                              },
         | 
| 315 | 
            -
                            ],
         | 
| 316 | 
            -
                            "encoding": {
         | 
| 317 | 
            -
                              "x": {"field": "Hour", "type": "nominal"},
         | 
| 318 | 
            -
                              "y": {"field": "Hits", "type": "quantitative"}
         | 
| 319 | 
            -
                            }
         | 
| 320 | 
            -
                          }
         | 
| 321 | 
            -
                        },
         | 
| 322 | 
            -
                        { title: "Most Requested Pages",
         | 
| 323 | 
            -
                          header: ["Path", "Hits", "Visits", "Size"],
         | 
| 324 | 
            -
                          rows: data[:most_requested_pages],
         | 
| 325 | 
            -
                        },
         | 
| 326 | 
            -
                        { title: "Most Requested Resources", header: ["Path", "Hits", "Visits", "Size"], rows: data[:most_requested_resources] },
         | 
| 327 | 
            -
                        { title: "404 on HTML Files", header: ["Path", "Hits", "Visits"], rows: data[:missed_pages] },
         | 
| 328 | 
            -
                        { title: "404 on other Resources", header: ["Path", "Hits", "Visits"], rows: data[:missed_resources] },
         | 
| 329 | 
            -
                        { title: "Attacks", header: ["Path", "Hits", "Visits"], rows: data[:attacks], col: "small-12 cell" },
         | 
| 330 | 
            -
                        { title: "Statuses",
         | 
| 331 | 
            -
                          header: ["Status", "Count"],
         | 
| 332 | 
            -
                          rows: data[:statuses],
         | 
| 333 | 
            -
                          vega_spec: {
         | 
| 334 | 
            -
                            "mark": "bar",
         | 
| 335 | 
            -
                            "encoding": {
         | 
| 336 | 
            -
                              "x": {"field": "Status", "type": "nominal"},
         | 
| 337 | 
            -
                              "y": {"field": "Count", "type": "quantitative"}
         | 
| 338 | 
            -
                            }
         | 
| 339 | 
            -
                          }
         | 
| 340 | 
            -
                        },
         | 
| 341 | 
            -
                        { title: "Daily Statuses",
         | 
| 342 | 
            -
                          header: ["Date", "S_2xx", "S_3xx", "S_4xx"],
         | 
| 343 | 
            -
                          rows: data[:statuses_by_day],
         | 
| 344 | 
            -
                          vega_spec: {
         | 
| 345 | 
            -
                            "transform": [ {"fold": ["S_2xx", "S_3xx", "S_4xx" ] }],
         | 
| 346 | 
            -
                            "mark": "bar",
         | 
| 347 | 
            -
                            "encoding": {
         | 
| 348 | 
            -
                              "x": {
         | 
| 349 | 
            -
                                "field": "Date",
         | 
| 350 | 
            -
                                "type": "ordinal",
         | 
| 351 | 
            -
                                "timeUnit": "day", 
         | 
| 352 | 
            -
                              },
         | 
| 353 | 
            -
                              "y": {
         | 
| 354 | 
            -
                                "aggregate": "sum",
         | 
| 355 | 
            -
                                "field": "value",
         | 
| 356 | 
            -
                                "type": "quantitative"
         | 
| 357 | 
            -
                              },
         | 
| 358 | 
            -
                              "color": {
         | 
| 359 | 
            -
                                "field": "key",
         | 
| 360 | 
            -
                                "type": "nominal",
         | 
| 361 | 
            -
                                "scale": {
         | 
| 362 | 
            -
                                  "domain": ["S_2xx", "S_3xx", "S_4xx"],
         | 
| 363 | 
            -
                                  "range": ["#228b22", "#ff8c00", "#a52a2a"]
         | 
| 364 | 
            -
                                },
         | 
| 365 | 
            -
                              }
         | 
| 366 | 
            -
                            }
         | 
| 367 | 
            -
                          }
         | 
| 368 | 
            -
                        },
         | 
| 369 | 
            -
                        { title: "Browsers",
         | 
| 370 | 
            -
                          header: ["Browser", "Hits", "Visits", "Size"],
         | 
| 371 | 
            -
                          rows: data[:browsers],
         | 
| 372 | 
            -
                          vega_spec: {
         | 
| 373 | 
            -
                            "layer": [
         | 
| 374 | 
            -
                              { "mark": "bar" },
         | 
| 375 | 
            -
                              {
         | 
| 376 | 
            -
                                "mark": {
         | 
| 377 | 
            -
                                  "type": "text",
         | 
| 378 | 
            -
                                  "align": "middle",
         | 
| 379 | 
            -
                                  "baseline": "top",
         | 
| 380 | 
            -
                                  "dx": -10,
         | 
| 381 | 
            -
                                  "yOffset": -15
         | 
| 382 | 
            -
                                },
         | 
| 383 | 
            -
                                "encoding": {
         | 
| 384 | 
            -
                                  "text": {"field": "Hits", "type": "quantitative"},
         | 
| 385 | 
            -
                                }
         | 
| 386 | 
            -
                              },
         | 
| 387 | 
            -
                            ],
         | 
| 388 | 
            -
                            "encoding": {
         | 
| 389 | 
            -
                              "x": {"field": "Browser", "type": "nominal"},
         | 
| 390 | 
            -
                              "y": {"field": "Hits", "type": "quantitative"}
         | 
| 391 | 
            -
                            }
         | 
| 392 | 
            -
                          }
         | 
| 393 | 
            -
                        },
         | 
| 394 | 
            -
                        { title: "Platforms",
         | 
| 395 | 
            -
                          header: ["Platform", "Hits", "Visits", "Size"],
         | 
| 396 | 
            -
                          rows: data[:platforms],
         | 
| 397 | 
            -
                          vega_spec: {
         | 
| 398 | 
            -
                            "layer": [
         | 
| 399 | 
            -
                              { "mark": "bar" },
         | 
| 400 | 
            -
                              {
         | 
| 401 | 
            -
                                "mark": {
         | 
| 402 | 
            -
                                  "type": "text",
         | 
| 403 | 
            -
                                  "align": "middle",
         | 
| 404 | 
            -
                                  "baseline": "top",
         | 
| 405 | 
            -
                                  "dx": -10,
         | 
| 406 | 
            -
                                  "yOffset": -15
         | 
| 407 | 
            -
                                },
         | 
| 408 | 
            -
                                "encoding": {
         | 
| 409 | 
            -
                                  "text": {"field": "Hits", "type": "quantitative"},
         | 
| 410 | 
            -
                                }
         | 
| 411 | 
            -
                              },
         | 
| 412 | 
            -
                            ],
         | 
| 413 | 
            -
                            "encoding": {
         | 
| 414 | 
            -
                              "x": {"field": "Platform", "type": "nominal"},
         | 
| 415 | 
            -
                              "y": {"field": "Hits", "type": "quantitative"}
         | 
| 416 | 
            -
                            }
         | 
| 417 | 
            -
                          }
         | 
| 418 | 
            -
                        },
         | 
| 419 | 
            -
                        { title: "IPs", header: ["IPs", "Hits", "Visits", "Size", "Country"], rows: data[:ips] },
         | 
| 420 | 
            -
                        { title: "Referers", header: ["Referers", "Hits", "Visits", "Size"], rows: data[:referers], col: "small-12 cell" },
         | 
| 421 | 
            -
                      ]
         | 
| 422 | 
            -
                      %>
         | 
| 423 194 | 
             
                      <div class="grid-x grid-margin-x">
         | 
| 424 195 | 
             
                        <% @reports.each_with_index do |report, index| %>
         | 
| 425 196 | 
             
                          <article class="card cell <%= report[:col] || "small-12 large-6" %>" >
         | 
| 426 197 | 
             
                            <div class="card-divider">
         | 
| 427 | 
            -
                              <h2 id="<%= report[:title] | 
| 198 | 
            +
                              <h2 id="<%= Emitter::slugify report[:title] %>">
         | 
| 428 199 | 
             
                                <%= report[:title] %>
         | 
| 429 200 | 
             
                              </h2>
         | 
| 430 201 | 
             
                            </div>
         | 
| @@ -452,102 +223,10 @@ | |
| 452 223 | 
             
                        <% end %>
         | 
| 453 224 | 
             
                      </div>
         | 
| 454 225 |  | 
| 455 | 
            -
                      <article class="card">
         | 
| 456 | 
            -
                        <div class="card-divider">
         | 
| 457 | 
            -
                          <h2 id="geolocation">Geolocation</h2>
         | 
| 458 | 
            -
                        </div>
         | 
| 459 | 
            -
                        <div class="card-section">
         | 
| 460 | 
            -
                          <table id="geolocation-table" class="table unstriped">
         | 
| 461 | 
            -
                            <thead>
         | 
| 462 | 
            -
                              <tr>
         | 
| 463 | 
            -
                                <th>Country Code</th>
         | 
| 464 | 
            -
                                <th>Total Hits</th>
         | 
| 465 | 
            -
                                <th>Total Visits</th>
         | 
| 466 | 
            -
                                <th>IPs</th>
         | 
| 467 | 
            -
                              </tr>              
         | 
| 468 | 
            -
                            </thead>
         | 
| 469 | 
            -
                            <tbody>
         | 
| 470 | 
            -
                              <%# IP, Hits, Visits Size, Country%>
         | 
| 471 | 
            -
                              <% data[:ips].group_by { |x| x[4] }.each do |k, v| %>
         | 
| 472 | 
            -
                                <tr>
         | 
| 473 | 
            -
                                  <td class="country"><%= k %></td>
         | 
| 474 | 
            -
                                  <td class="total-hits"><%= v.map { |x| x[1] }.inject(&:+) %></td>
         | 
| 475 | 
            -
                                  <td class="total-visits"><%= v.map { |x| x[2] }.inject(&:+) %></td>
         | 
| 476 | 
            -
                                  <td class="ips">
         | 
| 477 | 
            -
                                    <%= v.map { |x| "<a href=\"https://whatismyipaddress.com/ip/#{x[0]}\">#{x[0]}</a>" }.join(", ") %>
         | 
| 478 | 
            -
                                  </td>
         | 
| 479 | 
            -
                                </tr>
         | 
| 480 | 
            -
                              <% end %>
         | 
| 481 | 
            -
                            </tbody>
         | 
| 482 | 
            -
                          </table>
         | 
| 483 | 
            -
                        </div>
         | 
| 484 | 
            -
                      </article>
         | 
| 485 | 
            -
             | 
| 486 | 
            -
                      <article class="card">
         | 
| 487 | 
            -
                        <div class="card-divider">
         | 
| 488 | 
            -
                          <h2 id="streaks">Streaks</h2>
         | 
| 489 | 
            -
                        </div>
         | 
| 490 | 
            -
                        <div class="card-section">
         | 
| 491 | 
            -
                          <table id="streaks-table" class="table data-table streaks">
         | 
| 492 | 
            -
                            <thead>
         | 
| 493 | 
            -
                              <tr>
         | 
| 494 | 
            -
                                <th>IP</th>
         | 
| 495 | 
            -
                                <th>
         | 
| 496 | 
            -
                                  <div class="grid-x grid-margin-x">
         | 
| 497 | 
            -
                                    <div class="col-2 cell">
         | 
| 498 | 
            -
                                      Day
         | 
| 499 | 
            -
                                    </div>
         | 
| 500 | 
            -
                                    <div class="col-10 cell">
         | 
| 501 | 
            -
                                      Resources
         | 
| 502 | 
            -
                                    </div>
         | 
| 503 | 
            -
                                  </div>
         | 
| 504 | 
            -
                                </th>
         | 
| 505 | 
            -
                              </tr>
         | 
| 506 | 
            -
                            </thead>
         | 
| 507 | 
            -
                            <tbody>
         | 
| 508 | 
            -
                              <% data[:streaks].group_by(&:first).each do |ip, date_urls| %>
         | 
| 509 | 
            -
                                <tr>
         | 
| 510 | 
            -
                                  <td class="ip">
         | 
| 511 | 
            -
                                    <a href="https://whatismyipaddress.com/ip/<%= ip %>"><%= ip %></a>
         | 
| 512 | 
            -
                                  </td>
         | 
| 513 | 
            -
                                  <td class="streaks">
         | 
| 514 | 
            -
                                    <div class="grid-x grid-margin-x">
         | 
| 515 | 
            -
                                      <% date_urls.group_by { |x| x[1] }.each do |date, urls| %>
         | 
| 516 | 
            -
                                        <div class="col-2 cell">
         | 
| 517 | 
            -
                                          <span class="date"><%= date %></span>
         | 
| 518 | 
            -
                                        </div>
         | 
| 519 | 
            -
                                        <div class="col-10 cell grid-x">
         | 
| 520 | 
            -
                                          <div class="small-12 medium-6 cell">
         | 
| 521 | 
            -
                                            <span class="res-title">HTML:</span>
         | 
| 522 | 
            -
                                            <ul>
         | 
| 523 | 
            -
                                              <% urls.map { |x| x[2] }.compact.select { |x| x.match /.*\.html?/ }.each do |url| %>
         | 
| 524 | 
            -
                                                <li><%= url %></li>
         | 
| 525 | 
            -
                                              <% end %>
         | 
| 526 | 
            -
                                            </ul>
         | 
| 527 | 
            -
                                          </div>                              
         | 
| 528 | 
            -
                                          <div class=" small-12 medium-6 cell">
         | 
| 529 | 
            -
                                            <span class="res-title small-12 medium-6 cell">Other Resources:</span>
         | 
| 530 | 
            -
                                            <ul>
         | 
| 531 | 
            -
                                              <% urls.map { |x| x[2] }.compact.sort.select { |x| x and not x.match /.*\.html?/ }.each do |url| %>
         | 
| 532 | 
            -
                                                <li><%= url %></li>
         | 
| 533 | 
            -
                                              <% end %>
         | 
| 534 | 
            -
                                            </ul>
         | 
| 535 | 
            -
                                          </div>
         | 
| 536 | 
            -
                                        </div>
         | 
| 537 | 
            -
                                      <% end %>
         | 
| 538 | 
            -
                                    </div>
         | 
| 539 | 
            -
                                  </td>
         | 
| 540 | 
            -
                                </tr>
         | 
| 541 | 
            -
                              <% end %>
         | 
| 542 | 
            -
                            </tbody>
         | 
| 543 | 
            -
                          </table>
         | 
| 544 | 
            -
                        </div>
         | 
| 545 | 
            -
                      </article>
         | 
| 546 | 
            -
             | 
| 547 226 | 
             
                      <div class="grid-x grid-margin-x">
         | 
| 548 227 | 
             
                        <div class="cell small-12 large-6">
         | 
| 549 228 | 
             
                          <article>
         | 
| 550 | 
            -
                            <h2 id=" | 
| 229 | 
            +
                            <h2 id="<%= Emitter::slugify "Command Invocation" %>">Command Invocation</h2>
         | 
| 551 230 |  | 
| 552 231 | 
             
                            <%= render "command_invocation.html.erb", data: data, options: options %>
         | 
| 553 232 | 
             
                          </article>
         | 
| @@ -555,7 +234,7 @@ | |
| 555 234 |  | 
| 556 235 | 
             
                        <div class="small-12 large-6 cell">
         | 
| 557 236 | 
             
                          <article>
         | 
| 558 | 
            -
                            <h2 id=" | 
| 237 | 
            +
                            <h2 id="<%= Emitter::slugify "Performance" %>">Performance</h2>
         | 
| 559 238 |  | 
| 560 239 | 
             
                            <%=  render "performance.html.erb", data: data %>
         | 
| 561 240 | 
             
                          </article>
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            * Apache Log Analysis
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            <%= render "warning.txt.erb" %>
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ** Summary
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            <%= render "summary.txt.erb", data: data %>
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            <% @reports.reject { |x| x[:report] == :html }.each do |report| %>
         | 
| 10 | 
            +
            ** <%= report[:title] %>
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            <%= render "output_table.txt.erb", report: report, data: data %>
         | 
| 13 | 
            +
            <% end %>
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            ** Command Invocation
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            <%= render 'command_invocation.txt.erb', data: data %>
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            ** Performance
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            <%= render 'performance.txt.erb', data: data %>
         | 
| 22 | 
            +
             | 
| @@ -1,7 +1,9 @@ | |
| 1 1 | 
             
            <!doctype html>
         | 
| 2 2 | 
             
            <html class="no-js" lang="en">
         | 
| 3 3 | 
             
              <head>
         | 
| 4 | 
            -
                <title | 
| 4 | 
            +
                <title>
         | 
| 5 | 
            +
                  <%= options[:title] || "Log Sense: #{data[:filenames].empty? ? "stdin" : data[:filenames].join(", ")}" %>
         | 
| 6 | 
            +
                </title>
         | 
| 5 7 |  | 
| 6 8 | 
             
                <meta charset="utf-8" />
         | 
| 7 9 | 
             
                <meta http-equiv="x-ua-compatible" content="ie=edge">
         | 
| @@ -150,36 +152,8 @@ | |
| 150 152 | 
             
              <body>
         | 
| 151 153 | 
             
                <div class="off-canvas-wrapper">
         | 
| 152 154 | 
             
                  <div class="off-canvas position-left" id="offCanvas" data-off-canvas>
         | 
| 153 | 
            -
                     | 
| 154 | 
            -
             | 
| 155 | 
            -
                      <ul class="no-bullet">
         | 
| 156 | 
            -
                        <% [
         | 
| 157 | 
            -
                          "Summary",
         | 
| 158 | 
            -
                          "Log Structure",
         | 
| 159 | 
            -
                          "Daily Distribution",
         | 
| 160 | 
            -
                          "Time Distribution",
         | 
| 161 | 
            -
                          "Statuses",
         | 
| 162 | 
            -
                          "Rails Performance",
         | 
| 163 | 
            -
                          "Fatal Events",
         | 
| 164 | 
            -
                          "Internal Server Errrors",
         | 
| 165 | 
            -
                          "Errors",
         | 
| 166 | 
            -
                          "IPs",
         | 
| 167 | 
            -
                          "Command Invocation",
         | 
| 168 | 
            -
                          "Performance"
         | 
| 169 | 
            -
                        ].each do |item| %>
         | 
| 170 | 
            -
                          <li class="nav-item">
         | 
| 171 | 
            -
                            <a href="#<%= item.downcase.gsub(' ', '-') %>" data-close><%= item %></a>
         | 
| 172 | 
            -
                          </li>
         | 
| 173 | 
            -
                        <% end %>
         | 
| 174 | 
            -
                      </ul>
         | 
| 175 | 
            -
             | 
| 176 | 
            -
                      <p>
         | 
| 177 | 
            -
                        Generated by
         | 
| 178 | 
            -
                        <a href="https://github.com/avillafiorita/log_sense">LogSense</a> <br />
         | 
| 179 | 
            -
                        on <%= DateTime.now.strftime("%Y-%m-%d %H:%M") %>.<br />
         | 
| 180 | 
            -
                        <a href='https://db-ip.com'>IP Geolocation by DB-IP</a>
         | 
| 181 | 
            -
                      </p>
         | 
| 182 | 
            -
                    </nav>
         | 
| 155 | 
            +
                    <%= render "navigation.html.erb",
         | 
| 156 | 
            +
                               menus: Emitter::rails_report_specification.map { |x| x[:title] } %>
         | 
| 183 157 | 
             
                  </div>
         | 
| 184 158 | 
             
                  <div class="off-canvas-content grid-container grid-x fluid" data-off-canvas-content>
         | 
| 185 159 | 
             
                    <div data-sticky-container>
         | 
| @@ -191,14 +165,14 @@ | |
| 191 165 | 
             
                    </div>
         | 
| 192 166 |  | 
| 193 167 | 
             
                    <section class="main-section">
         | 
| 194 | 
            -
                      <h1><%= options[:title] || "Log Sense | 
| 168 | 
            +
                      <h1><%= options[:title] || "Log Sense Rails Log Report" %></h1>
         | 
| 195 169 |  | 
| 196 | 
            -
                      <p><b>Input File:</b>  <%=  | 
| 170 | 
            +
                      <p><b>Input File(s):</b>  <%= data[:filenames].empty? ? "stdin" : data[:filenames].join(", ") %></p>
         | 
| 197 171 |  | 
| 198 172 | 
             
                      <div class="grid-x grid-margin-x">
         | 
| 199 173 | 
             
                        <article class="card small-12 large-6 cell">
         | 
| 200 174 | 
             
                          <div class="card-divider">
         | 
| 201 | 
            -
                            <h2 id=" | 
| 175 | 
            +
                            <h2 id="<%= Emitter::slugify "Summary" %>">Summary</h2>
         | 
| 202 176 | 
             
                          </div>
         | 
| 203 177 | 
             
                          <div class="card-section">
         | 
| 204 178 | 
             
                            <%= render "summary.html.erb", data: data %>
         | 
| @@ -207,7 +181,7 @@ | |
| 207 181 |  | 
| 208 182 | 
             
                        <article class="card cell small-12 large-6">
         | 
| 209 183 | 
             
                          <div class="card-divider">
         | 
| 210 | 
            -
                            <h2 id=" | 
| 184 | 
            +
                            <h2 id="<%= Emitter::slugify "Log Structure" %>">Log Structure</h2>
         | 
| 211 185 | 
             
                          </div>
         | 
| 212 186 | 
             
                          <div class="card-section">
         | 
| 213 187 | 
             
                            <%= render "log_structure.html.erb", data: data %>
         | 
| @@ -215,143 +189,6 @@ | |
| 215 189 | 
             
                        </article>
         | 
| 216 190 | 
             
                      </div>
         | 
| 217 191 |  | 
| 218 | 
            -
                      <% @reports = [
         | 
| 219 | 
            -
                        { title: "Daily Distribution",
         | 
| 220 | 
            -
                          header: ["Day", "DOW", "Hits"],
         | 
| 221 | 
            -
                          rows: data[:daily_distribution],
         | 
| 222 | 
            -
                          vega_spec: {
         | 
| 223 | 
            -
                            "encoding": {
         | 
| 224 | 
            -
                              "x": {"field": "Day", "type": "temporal"},
         | 
| 225 | 
            -
                              "y": {"field": "Hits", "type": "quantitative"}
         | 
| 226 | 
            -
                            },
         | 
| 227 | 
            -
                            "layer": [
         | 
| 228 | 
            -
                              {
         | 
| 229 | 
            -
                                "mark": {
         | 
| 230 | 
            -
                                  "type": "line",
         | 
| 231 | 
            -
                                  "point": {
         | 
| 232 | 
            -
                                    "filled": false,
         | 
| 233 | 
            -
                                    "fill": "white"
         | 
| 234 | 
            -
                                  }
         | 
| 235 | 
            -
                                }
         | 
| 236 | 
            -
                              },
         | 
| 237 | 
            -
                              {
         | 
| 238 | 
            -
                                "mark": {
         | 
| 239 | 
            -
                                  "type": "text",
         | 
| 240 | 
            -
                                  "align": "left",
         | 
| 241 | 
            -
                                  "baseline": "middle",
         | 
| 242 | 
            -
                                  "dx": 5
         | 
| 243 | 
            -
                                },
         | 
| 244 | 
            -
                                "encoding": {
         | 
| 245 | 
            -
                                  "text": {"field": "Hits", "type": "quantitative"}
         | 
| 246 | 
            -
                                }
         | 
| 247 | 
            -
                              }
         | 
| 248 | 
            -
                            ]
         | 
| 249 | 
            -
                          }
         | 
| 250 | 
            -
                        },
         | 
| 251 | 
            -
                        { title: "Time Distribution",
         | 
| 252 | 
            -
                          header: ["Hour", "Hits"],
         | 
| 253 | 
            -
                          rows: data[:time_distribution],
         | 
| 254 | 
            -
                          vega_spec: {
         | 
| 255 | 
            -
                            "layer": [
         | 
| 256 | 
            -
                              {
         | 
| 257 | 
            -
                                "mark": "bar",
         | 
| 258 | 
            -
                              },
         | 
| 259 | 
            -
                              {
         | 
| 260 | 
            -
                                "mark": {
         | 
| 261 | 
            -
                                  "type": "text",
         | 
| 262 | 
            -
                                  "align": "middle",
         | 
| 263 | 
            -
                                  "baseline": "top",
         | 
| 264 | 
            -
                                  "dx": -10,
         | 
| 265 | 
            -
                                  "yOffset": -15
         | 
| 266 | 
            -
                                },
         | 
| 267 | 
            -
                                "encoding": {
         | 
| 268 | 
            -
                                  "text": {"field": "Hits", "type": "quantitative"}
         | 
| 269 | 
            -
                                }
         | 
| 270 | 
            -
                              }
         | 
| 271 | 
            -
                            ],
         | 
| 272 | 
            -
                            "encoding": {
         | 
| 273 | 
            -
                              "x": {"field": "Hour", "type": "nominal"},
         | 
| 274 | 
            -
                              "y": {"field": "Hits", "type": "quantitative"}
         | 
| 275 | 
            -
                            }
         | 
| 276 | 
            -
                          }
         | 
| 277 | 
            -
                        },
         | 
| 278 | 
            -
                        { title: "Statuses",
         | 
| 279 | 
            -
                          header: ["Status", "Count"],
         | 
| 280 | 
            -
                          rows: data[:statuses],
         | 
| 281 | 
            -
                          vega_spec: {
         | 
| 282 | 
            -
                            "layer": [
         | 
| 283 | 
            -
                              {
         | 
| 284 | 
            -
                                "mark": "bar"
         | 
| 285 | 
            -
                              },
         | 
| 286 | 
            -
                              {
         | 
| 287 | 
            -
                                "mark": {
         | 
| 288 | 
            -
                                  "type": "text",
         | 
| 289 | 
            -
                                  "align": "left",
         | 
| 290 | 
            -
                                  "baseline": "top",
         | 
| 291 | 
            -
                                  "dx": -10,
         | 
| 292 | 
            -
                                  "yOffset": -20
         | 
| 293 | 
            -
                                },
         | 
| 294 | 
            -
                                "encoding": {
         | 
| 295 | 
            -
                                  "text": {"field": "Count", "type": "quantitative"}
         | 
| 296 | 
            -
                                }
         | 
| 297 | 
            -
                              }
         | 
| 298 | 
            -
                            ],
         | 
| 299 | 
            -
                            "encoding": {
         | 
| 300 | 
            -
                              "x": {"field": "Status", "type": "nominal"},
         | 
| 301 | 
            -
                              "y": {"field": "Count", "type": "quantitative"}
         | 
| 302 | 
            -
                            }
         | 
| 303 | 
            -
                          }
         | 
| 304 | 
            -
                        },
         | 
| 305 | 
            -
                        { title: "Rails Performance",
         | 
| 306 | 
            -
                          header: ['Controller', 'Hits', 'Min', 'Avg', 'Max'],
         | 
| 307 | 
            -
                          rows: @data[:performance],
         | 
| 308 | 
            -
                          vega_spec: {
         | 
| 309 | 
            -
                            "layer": [
         | 
| 310 | 
            -
                              {
         | 
| 311 | 
            -
                                "mark": {
         | 
| 312 | 
            -
                                  "type": "point",
         | 
| 313 | 
            -
                                  "name": "data_points"
         | 
| 314 | 
            -
                                }
         | 
| 315 | 
            -
                              },
         | 
| 316 | 
            -
                              {
         | 
| 317 | 
            -
                                "mark": {
         | 
| 318 | 
            -
                                  "name": "label",
         | 
| 319 | 
            -
                                  "type": "text",
         | 
| 320 | 
            -
                                  "align": "left",
         | 
| 321 | 
            -
                                  "baseline": "middle",
         | 
| 322 | 
            -
                                  "dx": 5,
         | 
| 323 | 
            -
                                  "yOffset": 0
         | 
| 324 | 
            -
                                },
         | 
| 325 | 
            -
                                "encoding": {
         | 
| 326 | 
            -
                                  "text": {"field": "Controller"},
         | 
| 327 | 
            -
                                  "fontSize": {"value": 8}
         | 
| 328 | 
            -
                                },
         | 
| 329 | 
            -
                              },
         | 
| 330 | 
            -
                            ],
         | 
| 331 | 
            -
                            "encoding": {
         | 
| 332 | 
            -
                              "x": {"field": "Avg", "type": "quantitative"},
         | 
| 333 | 
            -
                              "y": {"field": "Hits", "type": "quantitative"}
         | 
| 334 | 
            -
                            },
         | 
| 335 | 
            -
                          }
         | 
| 336 | 
            -
                        },
         | 
| 337 | 
            -
                        { title: "Fatal Events",
         | 
| 338 | 
            -
                          header: ['Date', 'IP', 'URL', 'Description', 'Log ID'], rows: @data[:fatal],
         | 
| 339 | 
            -
                          col: "small-12 cell"
         | 
| 340 | 
            -
                        },
         | 
| 341 | 
            -
                        { title: "Internal Server Errors",
         | 
| 342 | 
            -
                          header: ['Date', 'Status', 'IP', 'URL', 'Description', 'Log ID'], rows: @data[:internal_server_error],
         | 
| 343 | 
            -
                          col: "small-12 cell"
         | 
| 344 | 
            -
                        },
         | 
| 345 | 
            -
                        { title: "Errors",
         | 
| 346 | 
            -
                          header: ['Log ID', 'Context', 'Description', 'Count'], rows: @data[:error],
         | 
| 347 | 
            -
                          col: "small-12 cell"
         | 
| 348 | 
            -
                        },
         | 
| 349 | 
            -
                        { title: "IPs",
         | 
| 350 | 
            -
                          header: ["IPs", "Hits", "Country"],
         | 
| 351 | 
            -
                          rows: data[:ips]
         | 
| 352 | 
            -
                        },
         | 
| 353 | 
            -
                      ]
         | 
| 354 | 
            -
                      %>
         | 
| 355 192 | 
             
                      <div class="grid-x grid-margin-x">
         | 
| 356 193 | 
             
                        <% @reports.each_with_index do |report, index| %>
         | 
| 357 194 | 
             
                          <article class="card cell <%= report[:col] || "small-12 large-6" %>" >
         | 
| @@ -386,7 +223,9 @@ | |
| 386 223 | 
             
                      <div class="grid-x grid-margin-x">
         | 
| 387 224 | 
             
                        <div class="cell small-12 large-6">
         | 
| 388 225 | 
             
                          <article>
         | 
| 389 | 
            -
                            <h2 id=" | 
| 226 | 
            +
                            <h2 id="<%= Emitter::slugify "Command Invocation" %>">
         | 
| 227 | 
            +
                              Command Invocation
         | 
| 228 | 
            +
                            </h2>
         | 
| 390 229 |  | 
| 391 230 | 
             
                            <%= render "command_invocation.html.erb", data: data, options: options %>
         | 
| 392 231 | 
             
                          </article>
         | 
| @@ -394,7 +233,7 @@ | |
| 394 233 |  | 
| 395 234 | 
             
                        <div class="small-12 large-6 cell">
         | 
| 396 235 | 
             
                          <article>
         | 
| 397 | 
            -
                            <h2 id=" | 
| 236 | 
            +
                            <h2 id="<%= Emitter::slugify "Performance" %>"> Performance</h2>
         | 
| 398 237 |  | 
| 399 238 | 
             
                            <%=  render "performance.html.erb", data: data %>
         | 
| 400 239 | 
             
                          </article>
         |