Reporting on Micro Focus SEE HSF

The Historical Statistical Facility (HSF) provides the ability to record statistics related to the time spent in a COBOL program and the time that parts of that program spent in CICS API commands/tasks, SQL operations and JCL jobsteps, as well as associated file and TSQ accesses.

The records contain information such as the ID of a user that initiates the task, the response time, and names of any files accessed.

Information is provided for the following resources:

  • CICS transactions
  • IMS transactions
  • Batch jobs (JCL) – for each JCL job, HSF generates a start record, an end record and one record for each step
  • Web services
  • CGI programs

Not entirely happy with the reporting capability provided “Out of the box”, I banged this together to appease the management gods.

Script executed after Online region is brought down each night via Control-M.

Does the following;

  • Copies daily hsf file
  • parses file, for WEB and CICS lines it
    • counts number entries
    • sums (RESP and Latency)
    • Calculates Averages
    • Determines Min and Max values
  • emails Service Desk and Systems mailboxes results
#!/bin/bash
#
#AUTHOR:  Alister Jupp
#SCRIPT:  hsfReport.sh
#PURPOSE: Determine Average, Min, Max Response Times
#
smtp_address=smtp.xxxx
to_address=xxxxx
function init {
starttime=$(date +%s)
echo "**** Let the process begin ****"
#Get first character of hostname to determine region name
x=$(echo `hostname` | cut -c1 | tr '[:lower:]' '[:upper:]')
rundate=$(date +%Y%m%d)
rundatex=$(date +%d-%m-%Y)
spoon='Min/Max/Avg figures quoted are in hundredths of a second.'
dontreply='This is an system generated email. Please do not reply to this email as responses will not be actioned.'
rm tempfile.csv
rm cicsAwk.tmp
#Copy to temp file
cp /var/mfcobol/es/"ICCICS${x}1"/cashsf-a.csv tempfile.csv
jobrc=0
#Test that all the required vars have been set.
i=0
for var in smtp_address to_address ; do
    if [ ! "${!var:-}" ] ; then
        echo "$var is not set"
    ((i++))
    fi
done
if [ $i -eq 0 ] ; then
    echo "**** All variables have been set. Continue."
else
    echo "**** Error in config - variables not set"
    jobrc=4
fi
}
function emailServiceDesk {
    echo "**** Send Email to Service Desk"
    subject="Enterprise Server ICCICS${x}1 Stats Report: $rundatex"
    echo " " >> cicsAwk.tmp
    echo $spoon >> cicsAwk.tmp
    echo " " >> cicsAwk.tmp
    echo $dontreply >> cicsAwk.tmp
    cat cicsAwk.tmp | /bin/mail -S smtp=$smtp_address -s "$subject" -r "[email protected]" $to_address
}
###### Shall we play a game?
echo "Shall we play a game?"
# Start - Initialise
init
# Call awk script to sum, count and calc figures
echo "**** Count and Sum Transactions"
awk -f cicsStats.awk tempfile.csv > cicsAwk.tmp 
jobrc=$?
#Email Service Desk
if [ $jobrc -eq 0 ] ; then
    emailServiceDesk
    jobrc=$?
fi
# End
if [ $jobrc -eq 0 ] ; then
    echo "**** CICS Stats Report Complete ****"
else
    echo "**** CICS Stats Report Failed! ****"
fi
endtime=$(date +%s)
duration=$(($endtime - $starttime))
echo "Finished at : " `date`
echo "Elapsed time: " `date -d "1970-1-1 0:00 $duration seconds" "+%H:%M:%S"`
exit $jobrc
 #
#AUTHOR:  Alister Jupp
#SCRIPT:  cicsStats.awk
#PURPOSE: Process the HSF file to get min, max and averages
#        
BEGIN {
    FS=""*,"*";
    min=10;
    wmin=10;
    }
$1 == "CICS" {
        x=$10+$11
    {
    sum+=x
    count+=1
    if(x>max)
    {
        max=x
    };
    if(x<min)
    {
        min=x
    };
    }
    cicsAvg=sum/count
}
$1 == "WEB " {
        x=$10+$11
    {
    wsum+=x
    wcount+=1
    if(x>wmax)
    {
        wmax=x
    };
    if(x<wmin)
    {
        wmin=x
    };
    }
    webAvg=wsum/wcount
}
END {
    printf "CICS Min value is %d. Max value is %d. Count %d. Average %d.n", min, max, count, cicsAvg
    printf "WEB  Min value is %d. Max value is %d. Count %d. Average %d.n", wmin, wmax, wcount, webAvg
    printf "Total Transaction Count %d. Overall Average %d.n", count+wcount, (sum+wsum)/(count+wcount)
}

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *