outsmain / db-main

Dashboard Main Page
1 stars 0 forks source link

Create a log parser #1 #17

Open outsmain opened 10 years ago

outsmain commented 10 years ago

Create a new controller to parse output of command "show router interface detail" using data from NE_RUN_DATA. It has parameters are

It uses this parameters to filter data from a field "NE_RUN_DATA.update_date" and use a field "NE_RUN_DATA.data" as a input for log parser.

Log Type


Interface


File Structures See sample data from "sample/show router interface detail.pdf". This file was separated into 4 parts (tags) are

ATTRIB_TYPE Mapping To mapping attribute type from "ATTRIB_TYPE" to join with "ATTRIB_LIST.attrib_type_id", it must be matched with the same brand, model or version (if specific), or match with "ALL"

ATTRIB_LIST Mapping Before insert a new tag in "ATTRIB_LIST", it must check that the tag is not exist. If found the old one (with the criterion as defined in a section "ATTRIB_TYPE Mapping") then using existing record, otherwise insert a new record as join "ATTRIB_LIST.attrib_type_id" with "ATTRIB_TYPE" where "ATTRIB_TYPE.name" = "OTHER"

Sample ATTRIB_LIST's Attribute Type Mapping

Tag Name Attribute Type
Every Group (highlight with green or blue color) GROUP
IP Addr/mask IP_ADDRESS
MAC Address MAC_ADDRESS
Gi-Addr IP_ADDRESS

After parse all tags from input text then insert data of each attribute to "NE_RUN_ATTRIB" using these data are:

and look-up query are:

Group Mapping

Parent Group Group Attribute Key Attribute Value
Interface Table (Router: Base) Interface If Name Int A
Interface Table (Router: Base) Interface Admin State Up
Interface Table (Router: Base) Interface Oper (v4/v6) Up/Down
...
Interface Details Description Connect to A
Interface Details If Index 9
outsmain commented 10 years ago

เปลี่ยนสีให้เป็นสีฟ้า เพื่อให้เป็น sub group ที่ไม่มี key และ value ครับ

tanikul commented 10 years ago

เก็บใส่ array เสร็จแล้วครับ ไม่มี table ที่จะต้องเก็บครับ

ขอบคุณครับ

tanikul commented 10 years ago

ผมมีคำถามดังนี้ครับ

  1. SELECT b.brand, b.model,b.sw_ver,a.* FROM NE_RUN_DATA a, NE_LIST b WHERE a.UPDATE_DATE BETWEEN '2013-06-06 00:00:00' AND '2013-06-06 23:00:00' AND b.ip_addr = a.IP_ADDR ผมจะได้ NE_LIST.brand, NE_LIST.model,NE_LIST.sw_ver ออกมา เอาไปเช็คกับ ATTRIB_TYPE ว่าตรงกับอันไหน พอได้ ATTRIB_TYPE ออกมาแล้ว ผมจะเอาไปทำอะไรต่อ
  2. ATTRIB_TYPE.name = "OTHER" นี้ จะใช้กับแท็กที่ highlight สีชมพูใช่มั้ยครับ สีชมพูคือ OTHER หมดหรือป่าว หรือต้องนำค่าจากข้อ 1 มา insert ลง ATTRIB_LIST.ATTRIB_TYPE_ID จะใช้ในกรณีไหนครับ OTHER
  3. and join query are: "parent_group_id" with "NE_TYPE.id" where "NE_TYPE" = "GROUP" and "NE_LIST.name" = tag name "group_id" with "NE_LIST.id" where "NE_TYPE.name" = "GROUP" and "NE_LIST.name" = tag name "attrib_type_id" with "NE_LIST.id" where "NE_TYPE.name" <> "GROUP" and "NE_LIST.name" = tag name
    • NE_TYPE คือ ATTRIB_TYPE ใช่มั้ยครับ
    • NE_LIST.name จะเก็บพวก "Interface Table (Router: Base)", "Interface", "Details"... (พวกที่มี ATTRIB_TYPE.NAME = "GROUP") ด้วยเหรอครับ แล้วถ้าใน NE_LIST ตอนนี้ไม่มีพวกนี้ ผมต้อ insert ลงด้วยมั้ยครับ แล้วจะ insert ลง field ไหนบ้างใน NE_LIST ครับ
    • NE_RUN_ATTRIB.PARRENT_GROUP_ID ของ ENTRY_ID = 2 คือ ATTRIB_LIST.ID WHERE NAME = "Network Domains Associated" ใช่มั้ยครับ

ขอบคุณครับ

outsmain commented 10 years ago
  1. เมื่อได้ brand, model, version แล้ว ต้องเอาไป query ATTRIB_LIST join กับ ATTRIB_TYPE สำหรับ ip_addr นั้นเพือเตรียมเก็บไว้หลังจาก parse แล้ว ว่ามีค่าใน ATTRIB_TYPE แล้วหรือไม่ ถ้ายังไม่มีก็ต้อง insert เพิ่มลงใน ATTRIB_TYPE โดยให้ type เป็น OTHER ก่อนที่สุดท้ายจะทำ ATTRIB_TYPE.id (ทีมีอยู่เดิมหรือจากที่ insert ใหม่) และ ค่า (highlight สีเทา) ไป insert ใน NE_RUN_ATTRIB
  2. ชื่อของค่าสีชมพูทั้งหมดเป็น OTHER ถ้าไม่ตรงกับชื่อของค่าที่ได้จากข้อ 1 (ค่าที่ query ได้ครั้งแรก ก่อนที่ insert เพิ่มใน ATTRIB_LIST) แต่ถ้ามีอยู่เดิมแล้ว ก็จะได้ type เดิมตามที่มีอยู่

3.เปลี่ยน NE_LIST เป็น ATTRIB_LIST ทั้งหมดครับ ผมแก้ให้ใน issue แล้ว


Interface


ครั้งที่ 2 ครับ

แต่ NE_RUN_ATTRIB.PARRENT_GROUP_ID จะมาจาก ATTRIB_LIST.ID WHERE NAME = "Network Domains Associated" ถูกแล้วครับ ซึ่งไม่เกี่ยวกับว่า entry_id จะเป็นเท่าไร

tanikul commented 10 years ago

ตรงอื่นคิดว่าได้หมดแล้วครับ แต่ยังติดตรงข้อ 1 ครับ คือผม

SELECT b.brand, b.model,b.sw_ver,a.* FROM NE_RUN_DATA a, NE_LIST b WHERE a.UPDATE_DATE BETWEEN '2013-06-06 00:00:00' AND '2013-06-06 23:00:00' AND b.ip_addr = a.IP_ADDR

ผมจะได้ NE_LIST.brand, NE_LIST.model,NE_LIST.sw_ver ออกมาเป็นงี้ครับ

brandmodelsw_ver
ALUNULLNULL

เสร็จแล้วผมเอาไปหาใน ATTRIB_TYPE ได้ผลออกมาดังนี้

IDBRANDMODELVERSION
6ALUALLALL

เสร็จแล้วผมจะต้องเอา ID, BRAND, MODEL, VERSION ของ table ATTRIB_TYPE ไปทำอะไรครับ

" เมื่อได้ brand, model, version แล้ว ต้องเอาไป query ATTRIB_LIST join กับ ATTRIB_TYPE สำหรับ ip_addr นั้นเพือเตรียมเก็บไว้หลังจาก parse แล้ว ว่ามีค่าใน ATTRIB_TYPE แล้วหรือไม่ ถ้ายังไม่มีก็ต้อง insert เพิ่มลงใน ATTRIB_TYPE โดยให้ type เป็น OTHER "

ATTRIB_TYPE ไม่ต้อง insert ไม่ใช่เหรอครับ

ขอบคุณครับ

outsmain commented 10 years ago

ขอโทษครับ แก้ ATTRIB_TYPE เป็น ATTRIB_LIST ครับ

ค่า brand, model, ver ใช้สำหรับนำมาใช้ตอน query ATTRIB_LIST ทึ่ join กับ ATTRIB_TYPE เท่านั้นครับ

tanikul commented 10 years ago
  1. ที่ทำทั้งหมดนี้มีการ join กับ NE_LIST หรือเปล่าครับ
  2. "ค่า brand, model, ver ใช้สำหรับนำมาใช้ตอน query ATTRIB_LIST ทึ่ join กับ ATTRIB_TYPE เท่านั้น"

หมายความว่า เอา ATTRIB_LIST.ATTRIB_TYPE _ID JOIN ATTRIB_TYPE.ID ใช่มั้ยครับ

ถ้า query ออกมาเจอก็ผ่านไป แต่ถ้าไม่เจอก็ insert ลง ATTRIB_LIST โดยที่ ATTRIB_LIST.ATTRIB_TYPE_ID = ATTRIB_TYPE.ID และ ATTRIB_LIST.NAME = NE_LIST.NAME

หรือเปล่าครับ ขอบคุณครับ

outsmain commented 10 years ago
  1. join แค่ตอนแรกกับ NE_RUN_DATA
    • ถ้าไม่เจอให้ ATTRIB_LIST.ATTRIB_TYPE_ID = ATTRIB_TYPE.ID เมื่อ ATTRIB_TYPE.name = "OTHER"
    • ATTRIB_LIST.NAME เป็นชื่อของค่าที่ highlight สีเขียว, ฟ้า และชมพู ครับ