Script to Write Files

From Observer GigaFlow Support | VIAVI Solutions Inc.
Jump to: navigation, search

var ress= actions.getDatabaseManager().getVectorFromDBprepared("select distinct(srcadd) from flowsec where firstseen > gettimeimmutable('2 hours');",[]);

var BigInteger = Java.type("java.math.BigInteger");
var rosutils = Java.type('ros.CROSUtils');
var PrintWriter = Java.type('java.io.PrintWriter');
var writer = new PrintWriter("./resources/webapps/static/ips.txt", "UTF-8");
log.warn(ress.size());
var ip;
for (var i = 0; i < ress.size(); i++) {
	ip = rosutils.inet_btoa(new BigInteger(ress.get(i)[0]))
    if (ip.match("^172\..*\.102$")){
       	log.warn(ip)
    	writer.println(ip);
	}
}
writer.close();

Report will then be available from http://serverip:port/static/ips.txt