Skip to content
Permalink
Browse files

Fixes hit parser

  • Loading branch information
davidmerfield committed Nov 26, 2019
1 parent dbbd59d commit 255ae5112fe1bba904592188011baaca46167bff
Showing with 6 additions and 8 deletions.
  1. +6 −8 app/scheduler/daily/hits.js
@@ -1,13 +1,12 @@
var moment = require("moment");
var helper = require("helper");
var lineReader = helper.lineReader;
var numberWithCommas = helper.prettyNumber;

function main(callback) {
var hits = 0;
var responseTimes = [];
lineReader
.eachLine(helper.rootDir + "/logs/nginx.log", function(line, last) {
.eachLine(helper.rootDir + "/logs/nginx.log", function(line) {
// Last line of file is often empty
if (!line) return true;

@@ -29,14 +28,13 @@ function main(callback) {
if (!date.isValid()) return true;

var components = line.slice(line.indexOf("]") + 2).split(" ");
var status = parseInt(components[0]);
var responseTime = parseFloat(components[1]);
var serverName = components[2];
var uri = components.slice(3).join(" ");
var responseTime = parseFloat(components[2]);

if (date.isAfter(moment().subtract(1, "day"))) {
hits++;
responseTimes.push(responseTime);
if (!isNaN(responseTime)) {
hits++;
responseTimes.push(responseTime);
}
return true;
} else {
// older than a day

0 comments on commit 255ae51

Please sign in to comment.
You can’t perform that action at this time.