Skip to content
This repository has been archived by the owner. It is now read-only.

Handle Fragmentation, small fixes #5

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -56,11 +56,31 @@ graphite_connection.on("error", function() {
throw new Error("Connection error");
});

var fragment = ""

var request_handler = function(request, response) {
var putval_re = /^PUTVAL ([^ ]+)(?: ([^ ]+=[^ ]+)?) ([0-9.]+)(:.*)/;
request.addListener("data", function(chunk) {
metrics = chunk.toString().split("\n");
for (var i in metrics) {
metrics = chunk.toString().split("\r\n");

if ( fragment.length > 0 ) {
// Discard the fragment if the new line is well formed
// I have never seen this, but it may be possible
if ( String(metrics[0]).indexOf("PUTVAL") < 0 ) {
metrics[0] = fragment.concat(metrics[0])
}
fragment = ""
}
// If the last line is not empty, then this chunk is likely split
// in two. So, we will store the fragment for the next round
// The fragment is not used in this run, as it is corrupted and may
// actaully pass the regex (and mess up the DB)
if ( String(metrics[metrics.length-1]).length != 0 ) {
fragment = metrics[metrics.length-1]
metrics[metrics.length-1] = ""
}

for (var i=0; i<metrics.length; i++) {
var m = putval_re.exec(metrics[i]);
if (!m) {
continue;
@@ -81,8 +101,9 @@ var request_handler = function(request, response) {
var name_parts = name.replace(/\./g, "_").replace(/\//g, ".").split(".");

// Start to construct the new name
var rebuild = ["agents"]
var rebuild = ["hosts"]

// Strip off the domain name of the host
var host = name_parts[0].split(/_/)[0]
rebuild = rebuild.concat(host)

187 types.db

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.