2016-06-08 54 views
0

我有一個TSV文件的網絡掃描,其中包含類似於下面的示例arangoimp從CSV圖形文件

source IP  target IP  source port target port 
192.168.84.3 192.189.42.52 5868   1214 
192.168.42.52 192.189.42.19 1214   5968 
192.168.4.3 192.189.42.52 60680   22 
.... 
192.189.42.52 192.168.4.3  22    61969 

形式的數據是否有一個簡單的方法來導入此使用arangoimp入(預創建)邊緣收集網絡數據?

回答

1

如果不會轉換IP(固定在ArangoDB 3.0中),您可以合併the TSV importer,因此您需要多一點轉換邏輯才能獲得有效的CSV。在導入過程中,將使用ede attribute conversion option將前兩列轉換爲有效的_from_to屬性。

你不應該在其中指定空白的列主題,它應該是標籤或一個固定數量的列。我們需要在主題行中指定_from_to字段。

爲了使其工作,你會管上面通過sed得到有效CSV和適當的列名這樣的:

cat /tmp/test.tsv | \ 
    sed -e "s;source IP;_from;g;" \ 
     -e "s;target IP;_to;" \ 
     -e "s; port;Port;g" \ 
     -e 's; *;",";g' \ 
     -e 's;^;";' \ 
     -e 's;$;";' | \ 
    arangoimp --file - \ 
     --type csv \ 
     --from-collection-prefix sourceHosts \ 
     --to-collection-prefix targetHosts \ 
     --collection "ipEdges" \ 
     --create-collection true \ 
     --create-collection-type edge 

桑達與這些正則表達式將創建一箇中間表示看起來就像是:

"_from","_to","sourcePort","targetPort" 
"192.168.84.3","192.189.42.52","5868","1214" 

生成的邊緣看起來就像是:

{ 
    "_key" : "21056", 
    "_id" : "ipEdges/21056", 
    "_from" : "sourceHosts/192.168.84.3", 
    "_to" : "targetHosts/192.189.42.52", 
    "_rev" : "21056", 
    "sourcePort" : "5868", 
    "targetPort" : "1214" 
} 
+0

謝謝你。有Arangodb 3.0發佈日期嗎? (我知道它目前處於測試階段。) – Guido

+0

本週晚些時候我們會談談。 RC3剛剛發佈。 – dothebart