Originally posted by Robert Milfajt
Originally posted by John Hamilton
#!/usr/bin/perl -W## cl_metric_scan.pl - script to scan Cloverleaf *.idx files to generate a# file suitable for loading into a database table with SSIS.## written: 2/9/2007 - Jim Marselle# downloaded from clovertech post # http://clovertech.infor.com/viewtopic.php?t=2234## example of normal usage:## cl_metric_scan.pl < 12023_global_super_adt.in.old.idx## The input in the *.idx file looks like this:## {# {MID {{DOMAIN 0} {HUB 0} {NUM 433654899}}}# {SRCMID {{DOMAIN {}} {HUB {}} {NUM {}}}}# {TYPE DATA}# {SOURCECONN ib_idx_adt}# {ORIGSOURCECONN ib_idx_adt}# {DESTCONN {{}}}# {ORIGDESTCONN {{}}}# {TIME 1171187991}# {PRIORITY 5120}# {DATAFMT {}}# {SAVECONTEXT inbound}# {OFFSET 0}# {LENGTH 67}# }## The output looks like this:## 433654899,ib_idx_adt,ib_idx_adt,,,2007-02-19 03:00:36,5120,,inbound,0,67## NOTE - some of this data is redundant and/or NULL and may ultimately be# be removed.while (<>) { chomp; if (/{MID/) {@flds = split; $mid = $flds[6]; $mid =~ s/}//g; next; } if (/{SRCMID/) {@flds = split; $srcmid = $flds[6]; $srcmid =~ s/[{}]//g; next; } if (/{TYPE/) { next; } if (/{SOURCECONN/) {@flds = split; $sourceconn = $flds[1]; $sourceconn =~ s/}//g; next; } if (/{ORIGSOURCECONN/) {@flds = split; $origsourceconn = $flds[1]; $origsourceconn =~ s/}//g; next; } if (/{DESTCONN/) {@flds = split; $destconn = $flds[1]; $destconn =~ s/[{}]//g; next; } if (/{ORIGDESTCONN/) {@flds = split; $origdestconn = $flds[1]; $origdestconn =~ s/[{}]//g; next; } # Convert localtime to text. if (/{TIME/) {@flds = split; $time = $flds[1]; $time =~ s/}//g; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time); $mon = (++$mon < 10 ? "0" . $mon : $mon); $mday = ($mday < 10 ? "0" . $mday : $mday); $hour = ($hour < 10 ? "0" . $hour : $hour); $min = ($min < 10 ? "0" . $min : $min); $sec = ($sec < 10 ? "0" . $sec : $sec); $year += 1900; # Clear these to suppress Perl warnings. $wday = $yday = $isdst = 0; next; } if (/{PRIORITY/) {@flds = split; $priority = $flds[1]; $priority =~ s/}//g; next; } if (/{DATAFMT/) {@flds = split; $datafmt = $flds[1]; $datafmt =~ s/[{}]//g; next; } if (/{SAVECONTEXT/) {@flds = split; $savecontext = $flds[1]; $savecontext =~ s/}//g; next; } if (/{OFFSET/) {@flds = split; $offset = $flds[1]; $offset =~ s/}//g; next; } if (/{LENGTH/) {@flds = split; $length = $flds[1]; $length =~ s/}//g; next; } if (/^}/) { # Skip records with sourceconn starting with "ob" and null destconn. if ($sourceconn =~ /^ob*/ && $destconn eq "") { next; } print "$mid,$srcmid,$sourceconn,$origsourceconn,$destconn,$origdestconn,"; print "$year-$mon-$mday $hour:$min:$sec,"; print "$priority,$datafmt,$savecontext,$offset,$lengthn"; }}
113991567,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:58:08,5120,,inbound,6776393,1947113991573,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:58:33,5120,,inbound,6778340,2370113991588,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:58:43,5120,,inbound,6780710,1762113991605,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:58:53,5120,,inbound,6782472,2384113991618,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:58:53,5120,,inbound,6784856,1947113991634,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:58:53,5120,,inbound,6786803,2572113991640,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:59:03,5120,,inbound,6789375,532113991646,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:59:18,5120,,inbound,6789907,2719113991652,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:59:28,5120,,inbound,6792626,2238113991674,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:59:29,5120,,inbound,6794864,2922113991680,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:59:29,5120,,inbound,6797786,1919113991686,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:59:39,5120,,inbound,6799705,1766113991692,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:59:39,5120,,inbound,6801471,2397113991698,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:59:39,5120,,inbound,6803868,1407113991704,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:59:39,5120,,inbound,6805275,1883113991710,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:59:49,5120,,inbound,6807158,1515113991719,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:59:49,5120,,inbound,6808673,1790113991725,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:59:50,5120,,inbound,6810463,1833113991731,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:59:50,5120,,inbound,6812296,1790113991737,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 17:59:59,5120,,inbound,6814086,1515113991746,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 18:00:14,5120,,inbound,6815601,1882113991752,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 18:00:24,5120,,inbound,6817483,2572113991762,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 18:00:24,5120,,inbound,6820055,1372113991768,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 18:00:24,5120,,inbound,6821427,1845113991774,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 18:00:40,5120,,inbound,6823272,1834113991783,,12023_global_super_adt,12023_global_super_adt,,,2007-09-27 18:01:03,5120,,inbound,6825106,2737
#!/bin/ksh#set -xv# cl_metric_scan - this script scans Cloverleaf message log files to count the number# of messages processed by each of the various interfaces. It is run daily# from cron.## written - 2/9/07 - Jim Marselle# setroot sets HCISITEDIR, which is the root of the hci directory structure.## downloaded from clovertech post # http://clovertech.infor.com/viewtopic.php?t=2234#setroot DATADIR=$HCISITEDIR/data/metricsLOADFILE=$DATADIR/loadfiletrap "rm -f /tmp/*.idx ; exit 1" INT SIGQUIT SIGHUPbasedir=$HCISITEDIR/exec/processes cd $basedir# Get the julian date for processing from a file. We run one day behind to make# sure all of the files are present for a particular julian date. So, if today is# julian date 60, we use julian date 58.julian=$(cat $DATADIR/julian_date)rm -f $LOADFILEfor dir in $(ls) do # For the inbound and outbound directories. for dir2 in Inboundsave Outboundsave do # For some reason, cd echoes the directory, so we send the output to the bit bucket. cd $dir/$dir2 > /dev/null 2>&1 # For each log file which was created today (send stderr to bit bucket in case no # files today). for file_cmprsd in $(ls *.${julian}.*.idx.Z 2>/dev/null) do file_expanded=${file_cmprsd%.Z} # Copy and uncompress the file. cp $file_cmprsd /tmp uncompress /tmp/$file_cmprsd # Don't use hard-coded paths. /home/hci/metrics/cl_metric_scan.pl < /tmp/$file_expanded >> $LOADFILE # Remove the expanded file. rm -f /tmp/$file_expanded done cd ../..donecd $basedir done# Save the julian data for the next run.# If year modulo 4==0, it's a leap year.year=$(date +%Y)rem=$(expr $year % 4)if [ $rem -eq 0 -a $julian -eq 366 -o $rem -ne 0 -a $julian -eq 365 ] then julian=1else julian=$(expr $julian + 1)fiecho $julian > $DATADIR/julian_dateexit 0