diff --git a/src/main.js b/src/main.js index 512b8a4..12f2f69 100644 --- a/src/main.js +++ b/src/main.js @@ -62,12 +62,15 @@ if(errorMsg){ let proc = exec(cmd); logger.debug("Creating & Attaching streams.."); let regexBlockStream = new RegexBlockStream(/^\d{2}:\d{2}:\d{2}.\d{6}.*(\n( {4,8}|\t\t?).*)+\n/gm); + let packetStreamFactory = new PacketStreamFactory(); + let packetInfluxPointFactory = new PacketInfluxPointFactory(); + let influxPointWriter = new InfluxPointWriter(influxDb, env.INFLUX_ORG, env.INFLUX_BUCKET); proc.stdout .setEncoding("utf8") .pipe(regexBlockStream) - .pipe(new PacketStreamFactory()) - .pipe(new PacketInfluxPointFactory()) - .pipe(new InfluxPointWriter(influxDb, env.INFLUX_ORG, env.INFLUX_BUCKET)); + .pipe(packetStreamFactory) + .pipe(packetInfluxPointFactory) + .pipe(influxPointWriter); logger.debug("Attaching error-logger.."); const loggerTcpdump = logFactory("tcpdump");