78 IBM Tivoli Netcool Service Quality Manager Data Mediation Gateway Development
Sample output CSV file
The sample output CSV file from the gateway conforms to the 3GPP naming
convention A20081010.1500-20081010.1515_1_GGSN.csv. Example A-3 shows
the sample content of the CSV file.
Example: A-3 Sample output CSV file
GGSNNAME,APN,PDPCREATE_SUCCESSES,PDPCREATE_FAILURES,MSINIT_PDPDELETE_SUCCESSES,
MSINIT_PDPDELETE_FAILURES,NWINIT_PDPDELETE_SUCCESSES,NWINIT_PDPDELETE_FAILURES
gs1-ggsn-3,212.47.101.248:46,0,0,0,0,,
gs1-ggsn-3,212.47.101.248:3,1661,2,700,0,,
gs1-ggsn-3,212.47.101.248:1000,0,0,0,0,,
gs1-ggsn-3,212.47.101.248:253,56,0,19,0,,
gs1-ggsn-3,212.47.101.248:1,0,0,0,0,,
CSV_Writer_ITSO.pm
As noted in 3.5, “Developing the post parser configuration for Motorola GGSN”
on page 58, the CSV_Writer.pm must be modified to suppress the comments at
the beginning and ending of the output file. The modified CSV_Writer_ITSO.pm is
shown in Example A-4.
Example: A-4 Modified CSV_Writer.pm
#
#------------------------------------------------------------
# %Z% %M% %I% %G% %Z%
#------------------------------------------------------------
#
# File: CSV_Writer_ITSO.pm
#
# Desc: this package contains the fucntions that are used to write the
# information out in Comma Separated Value (CSV).
#
# (c) Copyright IBM Corporation 1998, 2008. All rights reserved.
#
package CSV_Writer_ITSO;
use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
require Exporter;
require AutoLoader;
Appendix A. Sample data and programs listing for gateways 79
@ISA = qw(Exporter AutoLoader);
# Items to export into callers namespace by default. Note: do not
export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
@EXPORT = qw( );
$VERSION = '0.02';
use GenUtils;
use RecordsUtils;
use FileHandle;
use AudLog;
############################################################
#
# Sub: New
#
# Desc: Creates the output object instance
#
# Params: None
#
# Returns: The created object
############################################################
sub New {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {@_};
# create records object when record entries exists
if ( exists($self->{OUTPUT_RECORD_KEY}) ) {
$self->{records_obj} = RecordsUtils->get_records_object(
OUTPUT_RECORD_KEY => $self->{OUTPUT_RECORD_KEY},
OUTPUT_RECORD_KEY_DELIMITER =>
$self->{OUTPUT_RECORD_KEY_DELIMITER},
);
}
$self->{filename} = undef;
$self->{filehandle} = undef;
$self->{store} = "";
bless ($self, $class);
return $self;
}
80 IBM Tivoli Netcool Service Quality Manager Data Mediation Gateway Development
############################################################
#
# Sub: Open
#
# Desc: Open a output file
#
# Params: $file - the name of the output file
#
# Returns: Nothing
############################################################
sub Open($) {
my $self = shift;
my $filename = shift;
# temp filename?
if ($filename =~ /.pt$/){
$self->{filename} = $self->{tmp_file} = $filename;
$self->{filename} =~ s/(\.pt)$/\.csv/;
}
else {
$self->{filename} = $self->{tmp_file} = $filename;
$self->{tmp_file} .= ".pt";
}
if( -e $self->{filename} ) {
LogMess("CSV_Writer: WARNING: $self->{filename} already exists,
overwriting", 3);
}
$self->{tmp_file} = $self->{filename} . ".pt";
$self->{filehandle} = new FileHandle;
$self->{filehandle}->open("> $self->{tmp_file}")
or LogMess("Can't open $self->{filename} for output", 1);
# Write header lines to the file.
#$self->{store} .= "# CSV Output File Start\n";
}
############################################################
#
# Sub: Open_Block
#
# Desc: Open a block in the output file. In the case of CSV
Appendix A. Sample data and programs listing for gateways 81
# output nothing happens
#
# Params: $name - name of the block to open
#
# Returns: Nothing
#
############################################################
sub Open_Block() {
}
############################################################
#
# Sub: WriteToFile
#
# Desc: Writes the cached output to file
#
# Params: none;
#
# Returns: Nothing
#
############################################################
sub WriteToFile() {
my $self = shift;
$self->{filehandle}->print( $self->{store} );
$self->{store} = "";
return;
}
############################################################
#
# Sub: Write_Comment
#
# Desc: Writes out a comment to the output file
#
# Params: $comment - the comment to write
#
# Returns: nothing
#
############################################################
sub Write_Comment() {
(shift)->{store} .= "# ".(shift)."\n";
return;
}
82 IBM Tivoli Netcool Service Quality Manager Data Mediation Gateway Development
############################################################
#
# Sub: Block_Info
#
# Desc: This function prints all the elements of a hash to the
# output string. The reference is supplied as an argument.
# It checks if the value of the hash element has any length.
# If there is no length then nothing is printed.
#
# Params: $href - reference to a counter=value hash
# $counter_order - optional array specifying counter output
order
#
# Returns: Nothing
############################################################
sub Block_Info() {
my ($self, $href, $counter_order) = @_;
# save the header data as it's output per line
if (defined($counter_order) && scalar(@$counter_order)){
@{$self->{HEADER_NAMES}} = @$counter_order;
@{$self->{HEADER_VALUES}} = map { (defined $href->{$_}) ?
$href->{$_} :
$self->{DEFAULT_NULL_VALUE}
} @$counter_order;
}
else {
@{$self->{HEADER_NAMES}} = keys %$href;
@{$self->{HEADER_VALUES}} = values %$href;
}
$self->{CREATE_BLOCK} = undef;
return;
}
############################################################
#
# Sub: Create_Block
#
# Desc: This function opens, writes the information and closes
# the block.
#
# Params: $block - the name of the block
# $cref - reference to counter=value hash
# $counter_order - order of the data counters (optional)
#

Get IBM Tivoli Netcool Service Quality Manager Data Mediation Gateway Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.