Ignore:
Timestamp:
Jul 23, 2008, 5:08:53 PM (16 years ago)
Author:
waue
Message:

HBaseRecordPro.java -> only modified for debuging SnortUploadHbase?.java

SnortParser?.java -> catch a bug and fix it

SnortUploadHbase?.java -> it can run finally ..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sample/hadoop-0.16/tw/org/nchc/code/SnortUploadHbase.java

    r33 r43  
    33 * Editor: Waue Chen
    44 * From :  NCHC. Taiwn
    5  * Last Update Date: 07/02/2008
     5 * Last Update Date: 07/23/2008
    66 */
    77
    88/**
    99 * Purpose :
    10  *  First, program would parse your record and create Hbase.\
    11  *  Then it sets the first line as column qualify \
    12  *  Finally it stores in HBase automatically.
     10 *  The program will parse the log of snort (/var/log/snort/alert)
     11 *    into Hbase table "snort".
    1312 *
    1413 * HowToUse :
    15  *  Make sure two thing :
    16  *  1. source_file must be regular as follow:
    17  *    first line: qualify1:qualify2:...:qualifyN
    18  *    other line: records1:records2:...:recordsN
    19  *  2. source_file path must be correct.
     14 *  Run by eclipse ! (dependency by SnortParser.java)
    2015
    2116 * Check Result:
    2217 *  Go to hbase console, type :
    23  *    hql > select * from t1_table;
     18 *    hql > select * from snort;
    2419
    2520
     
    4641import org.apache.hadoop.mapred.lib.IdentityReducer;
    4742
     43import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException;
     44
    4845public class SnortUploadHbase {
    4946  /* Major parameter */
     
    5653
    5754  // table name
    58   final static String table_name = "SnortTable";
     55  final static String table_name = "Snort";
    5956
    6057  // separate char
     
    6259 
    6360  // data source tmp
    64   final static String text_tmp = "/tmp/HBaseRecord.text.tmp";
     61  final static String text_tmp = "/tmp/alert_my";
    6562
    6663  // on this sample, map is nonuse, we use reduce to handle
     
    7168
    7269      String first_line = "gid;sid;version;alert name;" +
    73           "class;priority;year;month;day;hour;min;second;source;" +
    74           "destination;type;ttl;tos;id; iplen;dgmlen";
     70          "class;priority;month;day;hour;min;second;source;" +
     71          "destination;type;ttl;tos;id; iplen;dgmlen;";
    7572
    7673      // extract cf data
     
    124121   * Runs the demo.
    125122   */
    126   public static void main(String[] args) throws IOException {
     123  public static void main(String[] args) throws IOException,ParseException,Exception {
    127124   
    128125    String[] col_family = {column_family};
     
    131128//    setup.parseFirstLine(source_file, text_tmp);
    132129//    System.out.println(first_line);
    133     new SnortParser(source_file,text_tmp);
     130    SnortParser sp = new SnortParser(source_file,text_tmp);
     131    sp.parseToLine();
    134132   
    135133   
Note: See TracChangeset for help on using the changeset viewer.