Move InfluxDB to if-block
This commit is contained in:
		
							parent
							
								
									1012001312
								
							
						
					
					
						commit
						c09c6c29fb
					
				
							
								
								
									
										11
									
								
								src/main.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/main.js
									
									
									
									
									
								
							@ -14,6 +14,7 @@ const { RegexBlockStream } = require("./streamHandler/RegexBlockStream.js");
 | 
			
		||||
const { PacketStreamFactory } = require("./streamHandler/PacketStreamFactory.js");
 | 
			
		||||
const { PacketInfluxPointFactory } = require("./streamHandler/PacketInfluxPointFactory.js");
 | 
			
		||||
const { InfluxPointWriter } = require("./streamHandler/InfluxPointWriter.js");
 | 
			
		||||
const { InfluxDbLineProtocolWriter } = require("./streamHandler/InfluxDbLineProtocolWriter.js");
 | 
			
		||||
 | 
			
		||||
const userHelper = require("./helper/userHelper.js");
 | 
			
		||||
 | 
			
		||||
@ -42,6 +43,8 @@ if(errorMsg){
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
(async function() {
 | 
			
		||||
    let pointWriter;
 | 
			
		||||
    if(!env.USE_INFLUXDB_LINEPROTOCOL){
 | 
			
		||||
        logger.info("Setup Influx..");
 | 
			
		||||
        const influxDb = new InfluxDB({url: env.INFLUX_URL, token: env.INFLUX_TOKEN});
 | 
			
		||||
 | 
			
		||||
@ -66,7 +69,15 @@ if(errorMsg){
 | 
			
		||||
        logger.debug("Get WriteApi & set default-hostname to", `'${env.HOSTNAME}'`);
 | 
			
		||||
        const influxWriteApi = influxDb.getWriteApi(env.INFLUX_ORG, env.INFLUX_BUCKET, "us");
 | 
			
		||||
        //influxWriteApi.useDefaultTags({"hostname": env.HOSTNAME});
 | 
			
		||||
 | 
			
		||||
        pointWriter = new InfluxPointWriter(influxWriteApi);
 | 
			
		||||
 | 
			
		||||
        logger.info("Influx ok");
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        logger.info("Setup Influxdb-LineProtocol..");
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    logger.info("Starting tcpdump..");
 | 
			
		||||
    const TCPDUMP_BASECMD = "tcpdump -vvv -e -n -X -s0 -i";
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user