Code Samples
Introduction
This appendix contains samples of files used to configure the adapters that process the data that the Collection Manager receives.
•
Application Configuration
Application Configuration
The following sections list part of the XML file (nf-dbtables.xml) used to configure the database tables, and the DTD file used to verify the structure of the XML file.
•
CM:NetFlow nf-dbtables.xml File
CM:NetFlow nf-dbtables.xml File
The XML file is verified at runtime against a simple DTD, which is reproduced in the following section:
<?xml version="1.0" encoding="ISO8859_1"?>
<!DOCTYPE dbtabconf PUBLIC "-//P-Cube//Engage DB RDR Configuration 2.1.0//EN"
"dbtables.dtd">
<application name="NetFlow" version="3.7.0"/>
<rdr name="USAGE_NF" dbtabname="RPT_USAGE_NF" tag="Usage"
<field id="1" name="TIME_STAMP" type="TIMESTAMP">
<option property="source" value="timestamp" />
<field id="2" name="NF_HEAD_TIME_STAMP" type="INT32">
<option property="source" value="nf_timestamp" />
<field id="3" name="NF_HEAD_SOURCE_ID" type="UINT32">
<option property="source"
value="recordsource" />
<field id="4" name="NF_CLASS_ID" type="UINT32" /> <!-- For
Future Releases-->
<field id="5" name="NF_APPLICATION_ID" type="INT32DIG10"
/>
<field id="6" name="NF_INGRESS_IF" type="UINT32" />
<field id="7" name="NF_EGRESS_IF" type="UINT32" />
<field id="8" name="NF_FLOW_DIRECTION" type="UINT8" />
<field id="9" name="NF_FLOW_START_SYSUP_TIME"
type="UINT32" />
<field id="10" name="NF_FLOW_END_SYSUP_TIME" type="UINT32"
/>
<field id="11" name="NF_IN_PKTS" type="UINT64" >
<option property="source" value="unsigned64" />
<field id="12" name="NF_IN_BYTES" type="UINT64" >
<option property="source" value="unsigned64" />
<field id="13" name="NF_CONNECTION_COUNT_NEW"
type="UINT32" />
<field id="14" name="NF_CONN_SUM_DURATION" type="UINT64" >
<option property="source" value="unsigned64" />
<index name="RPT_USAGE_NF_I1"
columns="NF_HEAD_TIME_STAMP">
<option property="clustered" value="true"
/>
<option property="allowduprow"
value="true" />
<rdr name="TRANSACTION_NF" dbtabname="RPT_TRANSACTION_NF"
tag="Transaction"
<field id="1" name="TIME_STAMP" type="TIMESTAMP">
<option property="source" value="timestamp" />
<field id="2" name="NF_HEAD_TIME_STAMP" type="INT32">
<option property="source"
value="nf_timestamp" />
<field id="3" name="NF_HEAD_SRC_ID" type="UINT32">
<option property="source" value="recordsource" />
<field id="4" name="NF_CONN_TX_ID" type="UINT64" >
<option property="source" value="unsigned64" />
<field id="5" name="NF_APPLICATION_ID" type="INT32DIG10"
/>
<field id="6" name="NF_INGRESS_IF" type="UINT32" />
<field id="7" name="NF_EGRESS_IF" type="UINT32" />
<field id="8" name="NF_FLOW_DIRECTION" type="UINT8" />
<field id="9" name="NF_FLOW_START_SYSUP_TIME"
type="UINT32" />
<field id="10" name="NF_FLOW_END_SYSUP_TIME" type="UINT32"
/>
<field id="11" name="NF_IN_PKTS" type="UINT64" >
<option property="source" value="unsigned64" />
<field id="12" name="NF_IN_BYTES" type="UINT64" >
<option property="source" value="unsigned64" />
<field id="13" name="NF_SRC_IPV4_ADDR" type="IPADDRDIG10"
>
<option property="source"
value="ipaddress"/>
<field id="14" name="NF_SRC_PORT" type="UINT16" />
<field id="15" name="NF_DST_IPV4_ADDR" type="IPADDRDIG10"
>
<option property="source"
value="ipaddress"/>
<field id="16" name="NF_DST_PORT" type="UINT16" />
<field id="17" name="NF_PROTOCOL_ID" type="UINT8" />
<field id="18" name="NF_FLOW_ID" type="UINT64" > <!-- Not
used in 3.7. Reserver for future use-->
<option property="source" value="unsigned64" />
<field id="19" name="NF_FLOW_END_REASON" type="UINT8" />
<field id="20" name="NF_BIFLOW_DIRECTION" type="UINT8" />
<index name="RPT_TRANSACTION_NF_I1"
columns="NF_HEAD_TIME_STAMP">
<option property="clustered" value="true"
/>
<option property="allowduprow"
value="true" />
<table name="NF_INI_VALUES" dbtabname="NF_INI_VALUES">
<field id="1" name="TIME_STAMP" type="TIMESTAMP"/>
<field id="2" name="NF_IP" type="STRING" size="20"/>
<field id="3" name="VALUE_TYPE" type="INT16"/>
<field id="4" name="VALUE_KEY" type="STRING" size="255"/>
<field id="5" name="VALUE" type="INT32"/>
tables.dtd File
The following sample code represents the DTD file used to verify the nf-dbtables.xml definition file:
<?xml version="1.0" encoding="ISO8859_1"?>
<!ELEMENT dbtabconf (fileversion, application, db?, dbtables)>
<!ELEMENT fileversion (#PCDATA)>
<!ELEMENT application EMPTY>
<!ELEMENT dbtables (rdr*, aggtable*, table*)>
<!ELEMENT table (options?, fields, indexes?)>
dbtabname CDATA #REQUIRED
createtable (true | false) "true"
inserttodb (true | false) "false"
<!ELEMENT aggtable (options?, fields, indexes?)>
dbtabname CDATA #REQUIRED
aggperiod CDATA #REQUIRED
createtable (true | false) "true"
<!ELEMENT rdr (options?, fields, indexes?)>
dbtabname CDATA #REQUIRED
createtable (true | false) "true"
inserttodb (true | false) "true"
<!ELEMENT fields (field+)>
<!ELEMENT field (options?)>
<!-- the id attribute below is presumably a numeric index, but it is for future
use, we currently don't look at it, as the order is imposed in the XML -->
<!ELEMENT indexes (index+)>
<!ELEMENT index (options?)>
create (true | false) "true"
<!ELEMENT options (option+)>
You can set the location and name of the DTD and XML files separately for each adapter in the adapter configuration file.