Changeset 43 for sample/hadoop-0.16/tw/org/nchc/code/SnortUploadHbase.java
- Timestamp:
- Jul 23, 2008, 5:08:53 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sample/hadoop-0.16/tw/org/nchc/code/SnortUploadHbase.java
r33 r43 3 3 * Editor: Waue Chen 4 4 * From : NCHC. Taiwn 5 * Last Update Date: 07/ 02/20085 * Last Update Date: 07/23/2008 6 6 */ 7 7 8 8 /** 9 9 * 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". 13 12 * 14 13 * 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) 20 15 21 16 * Check Result: 22 17 * Go to hbase console, type : 23 * hql > select * from t1_table;18 * hql > select * from snort; 24 19 25 20 … … 46 41 import org.apache.hadoop.mapred.lib.IdentityReducer; 47 42 43 import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException; 44 48 45 public class SnortUploadHbase { 49 46 /* Major parameter */ … … 56 53 57 54 // table name 58 final static String table_name = "Snort Table";55 final static String table_name = "Snort"; 59 56 60 57 // separate char … … 62 59 63 60 // data source tmp 64 final static String text_tmp = "/tmp/ HBaseRecord.text.tmp";61 final static String text_tmp = "/tmp/alert_my"; 65 62 66 63 // on this sample, map is nonuse, we use reduce to handle … … 71 68 72 69 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;"; 75 72 76 73 // extract cf data … … 124 121 * Runs the demo. 125 122 */ 126 public static void main(String[] args) throws IOException {123 public static void main(String[] args) throws IOException,ParseException,Exception { 127 124 128 125 String[] col_family = {column_family}; … … 131 128 // setup.parseFirstLine(source_file, text_tmp); 132 129 // System.out.println(first_line); 133 new SnortParser(source_file,text_tmp); 130 SnortParser sp = new SnortParser(source_file,text_tmp); 131 sp.parseToLine(); 134 132 135 133
Note: See TracChangeset
for help on using the changeset viewer.