FANDOM


Les dejo un script en Java para convertir al log de las AP en flexlm en archivos delimitados por coma y poder verlos desde excel y generar reportes


 import java.io.BufferedReader;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
    public class ParserColussi
    public static void main(String[] args) throws FileNotFoundException, IOException {
       String pattern = "TIMESTAMP ([0-9]+\\/[0-9]+\\/[0-9]+)";
       String pattern2 = "([0-9]+:[0-9]+:[0-9]+) (.+) IN: (\\S+) (\\S+)";
       String pattern3 = "([0-9]+:[0-9]+:[0-9]+) (.+) OUT: (\\S+) (\\S+)";
       String pattern4 = "([0-9]+:[0-9]+:[0-9]+) (.+) UNSUPPORTED: (\\S+) \\S+\\s+\\) (\\S+)";
       Pattern r = Pattern.compile(pattern);
       Pattern r2 = Pattern.compile(pattern2);
       Pattern r3 = Pattern.compile(pattern3);
       Pattern r4 = Pattern.compile(pattern4);
       String time = "";
        try(BufferedReader br = new BufferedReader(new FileReader(args[0]))) {
           for(String line; (line = br.readLine()) != null; ) {
               Matcher m = r.matcher(line);
               Matcher m2 = r2.matcher(line);
               Matcher m3 = r3.matcher(line);
               Matcher m4 = r4.matcher(line);
               if (m.find()) {
                   time = m.group(1);
               } else if (m2.find()) {
                   System.out.println(time + "," + m2.group(1) + "," + m2.group(2) + ",IN," + m2.group(3) + "," + m2.group(4));
               } else if (m3.find()) {
                   System.out.println(time + "," + m3.group(1) + "," + m3.group(2) + ",OUT," + m3.group(3) + "," + m3.group(4));
               } else if (m4.find()) {
                   System.out.println(time + "," + m4.group(1) + "," + m4.group(2) + ",UNSUPPORTED," + m4.group(3) + "," + m4.group(4));
               }
           }
       }
   }
}