Cisco Service Control Management Suite Collection Manager User Guide, Rel 3.1.6
Code Samples
Downloads: This chapterpdf (PDF - 389.0KB) The complete bookPDF (PDF - 2.35MB) | Feedback

Code Samples

Table Of Contents

Code Samples

Application Configuration

tables.xml File

tables.dtd File

Adapter Configuration

ragadapter.conf File

ragadapter.xml File


Code Samples


This appendix contains samples of files used to configure the Cisco Service Control Management Suite (SCMS) Collection Manager (CM) and the adapters that process the data that the CM receives.

Application Configuration

Adapter Configuration

Application Configuration

The following sections list part of the XML file ( tables.xml ) used to configure the database tables, and the DTD file used to verify the structure of the XML file.

tables.xml File

tables.dtd File

tables.xml File

The following is a listing of a portion of the Cisco Service Control Application for Broadband tables.xml file:

<?xml version="1.0" encoding="ISO8859_1"?>
<!DOCTYPE dbtabconf PUBLIC "-//P-Cube//Engage DB RDR Configuration 2.1.0//EN" 
"dbtables.dtd">
<dbtabconf>
   <fileversion>
      ...
   </fileversion>
   <application name="Engage" version="2.1"/>
   <dbtables>
      <rdr name="SUR" dbtabname="RPT_SUR" tag="4042321922" createtable="true">
         <fields>
            <field id="1" name="TIME_STAMP" type="TIMESTAMP">
               <options>
                  <option property="source" value="timestamp"/>
               </options>
            </field>
            <field id="2" name="RECORD_SOURCE" type="INT32">
               <options>
                  <option property="source" value="recordsource"/>
               </options>
            </field>
            <field id="3" name="SUBSCRIBER_ID" type="STRING" size="64"/>
            <field id="4" name="PACKAGE_ID" type="INT32"/>
            <field id="5" name="SERVICE_ID" type="INT32">
               <options>
                  <option property="notnull" value="true"/>
               </options>
            </field>
            <field id="6" name="MONITORED_OBJECT_ID" type="INT32"/>
            <field id="7" name="BREACH_STATE" type="INT32"/>
            <field id="8" name="REASON" type="INT32"/>
            <field id="9" name="CONFIGURED_DURATION" type="INT32"/>
            <field id="10" name="DURATION" type="INT32"/>
            <field id="11" name="END_TIME" type="INT32"/>
            <field id="12" name="UPSTREAM_VOLUME" type="UINT32"/>
            <field id="13" name="DOWNSTREAM_VOLUME" type="UINT32"/>
            <field id="14" name="SESSIONS" type="UINT32"/>
         </fields>
         <indexes>
            <index name="RPT_SUR_I1" columns="END_TIME">
               <options>
                  <option property="clustered" value="true"/>
               </options>
            </index>
         </indexes>
      </rdr>
      <rdr name="LUR" dbtabname="RPT_LUR" tag="4042321925" createtable="true">
         <fields>
            <field id="1" name="TIME_STAMP" type="TIMESTAMP">
               <options>
                  <option property="source" value="timestamp"/>
               </options>
            </field>
            <field id="2" name="RECORD_SOURCE" type="INT32">
               <options>
                  <option property="source" value="recordsource"/>
               </options>
            </field>
            <field id="3" name="LINK_ID" type="INT32"/>
            <field id="4" name="GENERATOR_ID" type="INT32"/>
            <field id="5" name="SERVICE_ID" type="INT32"/>
            <field id="6" name="CONFIGURED_DURATION" type="INT32"/>
            <field id="7" name="DURATION" type="INT32"/>
            <field id="8" name="END_TIME" type="INT32"/>
            <field id="9" name="UPSTREAM_VOLUME" type="UINT32"/>
            <field id="10" name="DOWNSTREAM_VOLUME" type="UINT32"/>
            <field id="11" name="SESSIONS" type="UINT32"/>
         </fields>
         <indexes>
            <index name="RPT_LUR_I1" columns="END_TIME">
               <options>
                  <option property="clustered" value="true"/>
                  <option property="allowduprow" value="true"/>
               </options>
            </index>
         </indexes>
      </rdr>
      <aggtable name="TOP_HOURLY" dbtabname="RPT_TOPS_PERIOD0" aggperiod="0">
         <fields>
            <field id="1" name="RECORD_SOURCE" type="INT32"/>
            <field id="2" name="METRIC_ID" type="INT8"/>
            <field id="3" name="SERVICE_ID" type="INT8"/>
            <field id="4" name="TIME_STAMP" type="TIMESTAMP"/>
            <field id="5" name="AGG_PERIOD" type="INT8"/>
            <field id="6" name="SUBSCRIBER_ID" type="STRING" size="64"/>
            <field id="7" name="CONSUMPTION" type="UINT32"/>
         </fields>
         <indexes>
            <index name="RPT_TOPS_PERIOD0_I1" columns="TIME_STAMP">
               <options>
                  <option property="clustered" value="true"/>
                  <option property="allowduprow" value="true"/>
               </options>
            </index>
         </indexes>
      </aggtable>
      <table name="TZ" dbtabname="JCONF_SE_TZ_OFFSET">
         <fields>
            <field id="1" name="TIME_STAMP" type="TIMESTAMP"/>
            <field id="2" name="OFFSET_MIN" type="INT16"/>
         </fields>
      </table>
   </dbtables>
</dbtabconf>

For each table (either an RDR table, an aggregation table, or an extra table), the fields, indexes, and so on are listed.


Note A table, an index, or fields can have arbitrary free text options that can be accessed in the templates.


The XML file is verified at runtime against a simple DTD, reproduced in the following section.

tables.dtd File

The following is a listing of the DTD file used to verify the tables.xml definition file:

<?xml version="1.0" encoding="ISO8859_1"?>

<!ELEMENT dbtabconf (fileversion, application, db?, dbtables)>
<!ELEMENT fileversion (#PCDATA)>
<!ELEMENT application EMPTY>
<!ATTLIST application
   name CDATA #REQUIRED
   version CDATA #REQUIRED
>
<!ELEMENT db (options)>
<!ELEMENT dbtables (rdr*, aggtable*, table*)>
<!ELEMENT table (options?, fields, indexes?)>
<!ATTLIST table
   name CDATA #REQUIRED
   dbtabname CDATA #REQUIRED
   createtable (true | false) "true"
   inserttodb (true | false) "false"
>
<!ELEMENT aggtable (options?, fields, indexes?)>
<!ATTLIST aggtable
   name CDATA #REQUIRED
   dbtabname CDATA #REQUIRED
   aggperiod CDATA #REQUIRED
   createtable (true | false) "true"
>
<!ELEMENT rdr (options?, fields, indexes?)>
<!ATTLIST rdr
   name CDATA #REQUIRED
   dbtabname CDATA #REQUIRED
   tag 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 -->
<!ATTLIST field
   id CDATA #REQUIRED
   name CDATA #REQUIRED
   type CDATA #REQUIRED
   size CDATA #IMPLIED
>
<!ELEMENT indexes (index+)>
<!ELEMENT index (options?)>
<!ATTLIST index
   name CDATA #REQUIRED
   columns CDATA #REQUIRED
   create (true | false) "true"
>
<!ELEMENT options (option+)>
<!ELEMENT option EMPTY>
<!ATTLIST option
   property CDATA #REQUIRED
   value CDATA #REQUIRED
>

The location and name of the DTD and XML files can be set separately for each adapter in the adapter's configuration file.

Adapter Configuration

The following sections list the configuration file (ragadapter.conf) and the associated XML file (ragadapter.xml) used to configure the real-time aggregating (RAG) adapter.

The configuration files of the other adapters are similar to the RAG adapter configuration file. Only the RAG adapter has an associated XML file.

ragadapter.conf File

ragadapter.xml File

ragadapter.conf File

To perform RAG adapter general maintenance, use the file ~scmscm/cm/config/ragadapter.conf. The following is a sample of the RAG adapter configuration file:

# 
# RAGAdapter main configuration file 
# 
[config] 
xml_filename = ~/cm/config/ragadapter.xml 
[housekeeper] 
interval_sec = 10 
[db] 
operations_timeout = 60 
batch_size = 10 
transaction_size = 15 
commit_interval = 6 
blocking_connects = true 
db_template_file = main.vm 
db_template_dir = dbpacks/sybase/ase12.5.1 
[app] 
app_conf_file = dbtables.xml 
app_dtd_file = dbtables.dtd 
app_conf_dir = apps/scasbb/3.1.0

ragadapter.xml File

The sample ragadapter.xml file listed below defines two aggregations for the incoming NUR RDRs (intag="4042321920").

1. Aggregates RDRs with the RDR tag 71070 (outtag="71070") and persists them into CSV files (sinkid="csv1").

The CSV file definition is located in the <sinks> section under the <csvsink id="csv1"> tag. This defines the output file name and directory. This also defines the rate at which new files are opened; either every five minutes, or when the current file reaches 1000 lines. Each field in the file is enclosed by quotes (").

The buckets aggregate the data by two NUR fields: 0 and 2. These fields correspond to the SUBSCRIBER_ID and the SUBS_USG_CNT_ID. The buckets' identifiers are similar to the fields appearing in the SQL "GROUP BY" clause.

There are two closures defined for these two fields. For field 0, if the SUBSCRIBER_ID is RonK, OmerT, or GuyM it is reported as GuyM. If the SUBSCRIBER_ID is NimrodR, YossiO, or LironL it is reported as OdedE. For field 2, if the SUBS_USG_CNT_ID is 5, 6, or 7 it is reported as 15. This functionality is similar to the Oracle SQL "DECODE" function.

Fields 8, 9, and 10, which correspond to up, down, and sessions, are accumulated inside the buckets.

Four monitors are then defined:

Two <maxmonitor> monitors are defined as checkpoints for the fields 8 (up) and 9 (down). When the accumulated value for either of these fields reaches 10,000, that bucket is flushed to the CSV file.

The third <timeoutmonitor> monitor is a checkpoint to flush all buckets to the file every 60 seconds.

The last <changemonitor> monitor triggers a warning to both the RAG adapter log and to the user log when an RDR arrives that contains a new value for DURATION (field 6).

2. Aggregates RDRs with the RDR tag 71071 (outtag="71071") and persists them into a database table (sinkid="dbsink1").

The database definition is located in the <sinks> section under the <dbsink id="dbsink1"> tag.

The table definition is located in the tables configuration file: tables.xml. The definition is of the following format:

<ragtable ragsinkid="dbsink1" 
dbtabname="RPT_AGG_NUR" 
name="AGGNUR" 
ragouttag="71071">

The following code is a sample of the configuration possibilities of the RAG adapter.

<?xml version="1.0"?>
<!DOCTYPE ragadapterconf [
   <!ELEMENT ragadapterconf (fileversion, config)>
   <!ELEMENT fileversion (#PCDATA)>
   <!ELEMENT config (aggregations, sinks)>
   <!ELEMENT aggregations (aggregation+)>
   <!ELEMENT aggregation (bucketident, closures, accumulators, monitors)>
   <!ATTLIST aggregation
     id CDATA #REQUIRED
     intag CDATA #REQUIRED
     outtag CDATA #REQUIRED
     sinkid CDATA #REQUIRED
   >
   <!ELEMENT bucketident (field | metafield)+>
   <!ELEMENT closures (closure*)>
   <!ELEMENT closure (closurespec+)>
   <!ATTLIST closure
     field CDATA #REQUIRED
   >
   <!ELEMENT closurespec (equivvalue+)>
   <!ATTLIST closurespec
     type (string | int | long | double) #REQUIRED
     primaryvalue CDATA #REQUIRED
   >
   <!ELEMENT equivvalue EMPTY>
   <!ATTLIST equivvalue
     val CDATA #REQUIRED
   >
   <!ELEMENT accumulators (field+)>
   <!ELEMENT monitors (changemonitor | maxmonitor | timeoutmonitor)*>
   <!ELEMENT changemonitor EMPTY>
   <!ATTLIST changemonitor
     action (warn | checkpoint) #REQUIRED
     field CDATA #REQUIRED
     active (true | false) #REQUIRED
   >
   <!ELEMENT maxmonitor EMPTY>
   <!ATTLIST maxmonitor
     action (warn | checkpoint) #REQUIRED
     field CDATA #REQUIRED
     maxvalue CDATA #REQUIRED
     active (true | false) #REQUIRED
   >
   <!ELEMENT timeoutmonitor EMPTY>
   <!ATTLIST timeoutmonitor
     action (warn | checkpoint) #REQUIRED
     maxsec CDATA #REQUIRED
     active (true | false) #REQUIRED
   >
   <!ELEMENT field EMPTY>
   <!ATTLIST field
     index CDATA #REQUIRED
     type (string | int | long | double) #REQUIRED
   >
   <!ELEMENT sinks (csvsink | dbsink | generalsink)+>
   <!ELEMENT csvsink EMPTY>
   <!ATTLIST csvsink
     id CDATA #REQUIRED
     classname CDATA #REQUIRED
     filenameformat CDATA #REQUIRED
     dirname CDATA #REQUIRED
     maxagesec CDATA #REQUIRED
     maxlines CDATA #REQUIRED
     usequotes (true | false) #REQUIRED
     active (true | false) #REQUIRED
   >
   <!ELEMENT dbsink EMPTY>
   <!ATTLIST dbsink
     id CDATA #REQUIRED
     classname CDATA #REQUIRED
     active (true | false) #REQUIRED
   >
   <!ELEMENT generalsink EMPTY>
   <!ATTLIST generalsink
     id CDATA #REQUIRED
     classname CDATA #REQUIRED
     active (true | false) #REQUIRED
   >
]>
<ragadapterconf>
   <fileversion>
      $File: ragadapter.xml $ $Revision: #3 $
      $Author: ronv $
      $DateTime: 2005/08/15 15:48:23 $
   </fileversion>
   <config>
      <aggregations>
         <aggregation id="NUR's by subscriber and subs usage counter"
          intag="4042321920" outtag="71070" sinkid="csv1">
            <bucketident>
               <!-- SUBSCRIBER_ID=0, SUBS_USG_CNT_ID=2 -->
               <field index="0" type="string"/>
               <field index="2" type="int"/>
            </bucketident>
            <closures>
               <closure field="0">
                  <closurespec type="string" primaryvalue="GuyM">
                     <equivvalue val="RonK"/>
                     <equivvalue val="OmerT"/>
                     <equivvalue val="GuyM"/>
                  </closurespec>
                  <closurespec type="string" primaryvalue="OdedE">
                     <equivvalue val="NimrodR"/>
                     <equivvalue val="YossiO"/>
                     <equivvalue val="LironL"/>
                  </closurespec>
               </closure>
               <closure field="2">
                  <closurespec type="int" primaryvalue="15">
                     <equivvalue val="5"/>
                     <equivvalue val="6"/>
                     <equivvalue val="7"/>
                  </closurespec>
               </closure>
            </closures>
            <accumulators>
               <!-- up=8, down=9, sessions=10 -->
               <field index="8" type="long"/>
               <field index="9" type="long"/>
               <field index="10" type="long"/>
            </accumulators>
            <!-- nothing to monitor for change in NUR really.
                 For sake of testing, let's warn if DURATION changes. -->
            <monitors>
               <maxmonitor action="checkpoint" field="8" maxvalue="10000" active="true"/>
               <maxmonitor action="checkpoint" field="9" maxvalue="10000" active="true"/>
               <changemonitor action="warn" field="6" active="true"/>
               <timeoutmonitor action="checkpoint" maxsec="60" active="true"/>
            </monitors>
         </aggregation>
         <aggregation id="NUR's by subscriber only, per SCE"
          intag="4042321920" outtag="71071" sinkid="dbsink1">
            <bucketident>
               <field index="0" type="string"/>
               <metafield source="record-source" type="int"/>
            </bucketident>
            <closures/>
            <accumulators>
               <field index="8" type="long"/>
               <field index="9" type="long"/>
               <field index="10" type="long"/>
            </accumulators>
            <monitors>
               <timeoutmonitor action="checkpoint" maxsec="60" active="true"/>
            </monitors>
         </aggregation>
      </aggregations>

      <sinks>
         <csvsink id="csv1"
          classname="com.cisco.scmscm.adapters.rag.sinks.CSVSink"
          filenameformat="yyyy-MM-dd_HH-mm-ss-SSS'.csv'"
          dirname="~/cm/adapters/RAGAdapter/csvfiles"
          maxagesec="300" maxlines="1000" usequotes="true" active="true"/>
         <dbsink id="dbsink1"
          classname="com.cisco.scmscm.adapters.rag.sinks.JDBCSink" active="false"/>
      </sinks>
   </config>
</ragadapterconf>