forked from olark/hashmonitor
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do not require coffeescript to be installed globally
- Loading branch information
Showing
4 changed files
with
63 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,4 @@ | ||
#!/usr/bin/env coffee | ||
#!/usr/bin/env node | ||
|
||
HashMonitor = require('../lib/hashmonitor').HashMonitor | ||
HttpAccessLogParser = require('../lib/inputs/httpaccess').HttpAccessLogParser | ||
|
||
DEFAULT_MILLISECONDS_FOR_SINGLE_STATS_WINDOW = 30 * 1000 | ||
|
||
# Initialize the HashMonitor collector that will contain all the | ||
# parsed log lines and calculated statistics. | ||
monitor = new HashMonitor() | ||
|
||
# Keep a list of pre-parsers | ||
preParsers = [] | ||
|
||
# Parse most HTTP log formats into plaintext strings. This should | ||
# be safe for non-HTTP log lines, but probably should make this configurable | ||
# instead configurat | ||
if '--parse-http-access' in process.argv | ||
preParsers.push(new HttpAccessLogParser()) | ||
|
||
# Listen for data on standard input (default input for log lines). | ||
# TODO: add other input options | ||
process.stdin.resume() | ||
process.stdin.setEncoding('utf8') | ||
process.stdin.on 'data', (line) -> | ||
for parser in preParsers | ||
line = parser.parse(line) | ||
monitor.parse(line) | ||
|
||
# Periodically output the statistics for this monitor as JSON dictionaries | ||
# so that other scripts can send these stats into other systems. | ||
setInterval( | ||
-> | ||
# TODO: add other output options | ||
console.log(monitor.calculate()) | ||
monitor.reset() | ||
, DEFAULT_MILLISECONDS_FOR_SINGLE_STATS_WINDOW | ||
) | ||
require('coffee-script') | ||
require('../lib/commandline').run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
HashMonitor = require('./hashmonitor').HashMonitor | ||
HttpAccessLogParser = require('./inputs/httpaccess').HttpAccessLogParser | ||
|
||
DEFAULT_MILLISECONDS_FOR_SINGLE_STATS_WINDOW = 30 * 1000 | ||
|
||
run = -> | ||
|
||
# Initialize the HashMonitor collector that will contain all the | ||
# parsed log lines and calculated statistics. | ||
monitor = new HashMonitor() | ||
|
||
# Keep a list of pre-parsers | ||
preParsers = [] | ||
|
||
# Parse most HTTP log formats into plaintext strings. This should | ||
# be safe for non-HTTP log lines, but probably should make this configurable | ||
# instead configurat | ||
if '--parse-http-access' in process.argv | ||
preParsers.push(new HttpAccessLogParser()) | ||
|
||
# Listen for data on standard input (default input for log lines). | ||
# TODO: add other input options | ||
process.stdin.resume() | ||
process.stdin.setEncoding('utf8') | ||
process.stdin.on 'data', (line) -> | ||
for parser in preParsers | ||
line = parser.parse(line) | ||
monitor.parse(line) | ||
|
||
# Periodically output the statistics for this monitor as JSON dictionaries | ||
# so that other scripts can send these stats into other systems. | ||
setInterval( | ||
-> | ||
# TODO: add other output options | ||
console.log(monitor.calculate()) | ||
monitor.reset() | ||
, DEFAULT_MILLISECONDS_FOR_SINGLE_STATS_WINDOW | ||
) | ||
|
||
exports.run = run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "hashmonitor", | ||
"version": "0.0.1", | ||
"author": "Matt Pizzimenti", | ||
"description": "Turn logs into metrics like a boss", | ||
"repository": { | ||
"url": "https://github.com/olark/hashmonitor" | ||
}, | ||
"main": "lib/hashmonitor", | ||
"dependencies": { | ||
"coffee-script": "*" | ||
}, | ||
"devDependencies": { | ||
"nodeunit": "*" | ||
}, | ||
"scripts": { | ||
"prepublish": "coffee -c lib" | ||
} | ||
} |