#!/bin/ksh ## ## SCRIPT NAME: get_ideasfe_usage ## ## Where : in $FEDIR/scripts where FEDIR=/apps/nns_com/fea ## ############################################################################ ## ## PURPOSE: Runs an egrep-sed-awk-sort-uniq pipe on an NNS SDRC/I-DEAS FLEXlm ## license log file to extract userids, product-names, and ## usage date-times -- corresponding to ## ModelSolution/Optimization/FEM/Simulation/and-other-FE ## product usage. See the FE-extract-keywords in the code below. ## ## Two reports are created: ## 1) a PRODUCT-USERID COUNTS SUMMARY report ## AND ## 2) a CHRONLOGICAL ACTIVITY report. ## ############################################################################ ## ## MAINTENANCE NOTE: ## ## When a new release of I-DEAS is installed, the version prompt ## (i.e. the FLEXLOGFILE variable), near the top of this script, ## should allow for the new version number. ## ## In 1998 the I-DEAS 6 log was in /apps/ideas_ms6/sec/logs/daemon.sgia ## ############################################################################ ## MAINTENANCE HISTORY: ## Written by: B. Montandon 14Sep98 Based on get_nas_usage. ## Updated by: B. Montandon 16Sep98 Touched up report text & script comments. ## Updated by: B. Montandon 28Oct99 Touched up comments some more. ## ############################################################################ . $FEDIR/scripts/clearnns ############################################################################ ## LICENSE SERVER (sgia) HOST CHECK. ############################################################################ # # if test ! "sgia" = "`hostname`" # then # echo " # Login to 'sgia' !!! # # For much faster build of the list of userids # from ModelSolution FLEXlm log file. # " # exit # fi ############################################################################ ## PROMPT FOR IDEAS VERSION. ############################################################################ echo "${HIbold}\ ...................................................................... IDEAS_FEA/FEM_usage: ${HIreset} This utility generates 1) A PRODUCT-USERID COUNTS SUMMARY report -- of NNS SDRC/I-DEAS ModelSolution/Optimization/FEM/and-other-IDEAS-FE usage on the 'sgia' network which is followed by an optional 2) CHRONLOGICAL FE ACTIVITY report -- of NNS I-DEAS FE Product usage. ${HIbold} ......................................................................... Do you want to inquire on I-DEAS 4 or 5 or 6? (4 or 5 or 6) 4 5 6 (mouse-)ENTER A VERSION INDICATOR NUMBER -- OR simply press ENTER to EXIT ==>${HIreset} \c" read VERNUM if test "$VERNUM" = "" then continue # break # exit fi ############################################################################ ## SET INPUT & OUTPUT FILE NAMES. ############################################################################ FLEXLOGFILE="/apps/ideas_ms${VERNUM}/sec/logs/daemon.sgia" if test "$FEDIR" = "" then export FEDIR=/apps/nns_com/fea fi ########################################################### ## TIMESTAMP=`date +%Y%b%d_%T%p` ## OUTLIST="$HOME/ModelSolution_USERIDS.LIST_${TIMESTAMP}" ## rm -f $OUTLIST ########################################################### . $FEDIR/scripts/set_localoutlist ############################################################################ ## PREPARE 'PRODUCT-USERID COUNTS' SUMMARY REPORT HEADING. ############################################################################ echo "\ .................. `date` ................... FEM/FEA PRODUCT-USERID SUMMARY COUNTS (since last boot-up of license manager): from NNS I-DEAS license log file $FLEXLOGFILE Note: You can browse the detail in the NNS I-DEAS FLEXlm log file at nnsFEAmenu option 'G L' (Geometry-modeler[I-DEAS], Licenses-status). For example, you can double-check these counts against the complete log file -- for example, by 'grep'-ing a userid. This list is prepared by a moderately complex 'awk' program (combined with 'egrep', 'sed', 'sort', & 'uniq') seen in $FEDIR/scripts/get_ideasfe_usage This report uses the user 'IN:' (license check-out) records of the log file. The date-times of the user 'OUT:' (license check-in) records can be seen in the log file. For readability, this utility re-formats the free-format 'IN:' records into columnar-format records. Names & depts corresponding to userids can be looked up via nnsFEAmenu options 'h su 0' or 'h su 1', where 'h su' is short for 'Help, SgiaUsers'. This SORTED list was put in $OUTLIST Generated at host `hostname` by nnsFEAmenu option 'h su 11'. ========================================================================= Use SDRC Count FEM/FEA Product Userid ---- ------------------------------- ------ " > $OUTLIST ############################################################################ ## USE 'awk' TO PUT USER RECS IN OUTPUT FILE. ############################################################################ ## For testing: # set -x egrep 'started on|TIMESTAMP|IN:' $FLEXLOGFILE | \ sed 's|@| |g' | \ awk '{ if ( $5 ~ "started" ) { ################################################################## ### In "started" recs: ### Field#NF (last field) =date (in parentheses) ### Sample rec: ### 6:13:31 (lmgrd) FLEXlm (v4.1) started on sgia (sgi IP19) (8/17/98) ################################################################### SAVDATE1 = $NF # SAVDATE1 = substr($NF,1,9) continue } if ( $3 ~ "TIMESTAMP" ) { ################################################################### ### In "TIMESTAMP" recs: ### Field#4=date ### Sample rec: ### 12:13:31 (lmgrd) TIMESTAMP 8/17/98 ################################################################### SAVDATE2 = $4 continue } if ( $3 ~ "IN:" ) { if ( $4 ~ "ModelSolution" || $4 ~ "Optimization" || \ $4 ~ "Simulation" || $4 ~ "FEM" || \ $4 ~ "ModelResponse" || $4 ~ "Laminate" || \ $4 ~ "SystemDynamics" || $4 ~ "TMG" || \ $4 ~ "Dynamics" || \ $4 ~ "VibroAcoustics" || $4 ~ "Rayon" || \ $4 ~ "FEA" || $4 ~ "ABAQUS" || \ $4 ~ "ANSYS" || $4 ~ "NASTRAN" ) { ################################################################### ### In "IN:" recs: ### Field#1=Time-of-day Field#4=product Field#5=userid Field#6=hostid ### Sample rec: ### 9:53:50 (sdrc_ms6) OUT: MasterModeler dmo03@iaw045 ################################################################### printf (" %-33s %-8s \n", $4, $5 ) ## printf ( "this is an IN: rec \n" ) } } } ################################################################### ### Print out date range at end of report. ### Then 'sort' the output by userid and use 'uniq' to count usage ### of each product by each userid. ################################################################### END { printf ("This is usage between %12s and %12s \n", SAVDATE1, SAVDATE2) }' | \ sort +0 -1 +1 -2 | \ uniq -c >> $OUTLIST ######################################################################## ## awk OUTPUT NOTES: ## The 'awk' output recs contain only 2 fields: Product-name and userid. ## The 'sort' sorts on Product-name first, then userid. ## The 'uniq' counts occurrences of unique Product-name & userid records. ######################################################################## ################################################################### ## SHOW/PRINT 'PRODUCT-USERID ACTIVITY' SUMMARY REPORT. ################################################################### $FEDIR/scripts/shofil $OUTLIST ######################################################################## ## ASK IF 'CHRONOLOGICAL-ACTIVITY' REPORT IS WANTED. ######################################################################## echo "${HIbold} .......................................................................... Do you want to see a *CHRONOLOGICAL-ACTIVITY* detail report, expanding the report you just saw in $OUTLIST?${HIreset} y ${HIbold} (y or null to exit) ==>${HIreset} \c" read REPORT_YN # if test "${REPORT_YN}" = "" if test ! "${REPORT_YN}" = "y" then # break continue # exit fi ########################################################################## ## SET OUTPUT FILENAME FOR 'CHRONOLOGICAL-ACTIVITY' REPORT. ########################################################################## OUTLIST2=${OUTLIST}2 ########################################################################## ## PREPARE 'CHRONOLOGICAL-ACTIVITY' REPORT HEADING. ########################################################################## echo "\ .................. `date` .................. NNS SDRC USERID FEM/FEA ACTIVITY (since last boot-up of the NNS FLEXlm license manager) -- IN ORDER BY DATE-TIME: Extracted from NNS I-DEAS license log file $FLEXLOGFILE NOTE: You can browse the full detail in the NNS I-DEAS FLEXlm log file at nnsFEAmenu option 'g l' or 'G L' (Geometry-modeler[I-DEAS], Licenses-status). This list is prepared by a moderately complex 'awk' program (combined with 'egrep') seen in $FEDIR/scripts/get_ideasfe_usage This report uses the user 'IN:' (license check-out) records of the log file. The date-times of the user 'OUT:' (license check-in) records can be seen in the log file. For readability, this utility re-formats the free-format 'IN:' records into columnar-format records. Names & depts corresponding to userids can be looked up via nnsFEAmenu options 'h su 0' or 'h su 1', where 'h su' is short for 'Help, SgiaUsers'. This SORTED list was put in $OUTLIST2 Generated at host `hostname` by nnsFEAmenu option 'h su 11'. ========================================================================= " > $OUTLIST2 ########################################################################## ## USE 'awk' TO PUT USER RECS IN OUTPUT FILE. ########################################################################## ## For testing: # set -x egrep 'started on|TIMESTAMP|IN:' $FLEXLOGFILE | \ awk '{ if ( $5 ~ "started" ) { ################################################################ ### In 'started' recs: ### Field#NF (last field) =date (in parentheses) ################################################################ SAVDATE = $NF # SAVDATE = substr($NF,1,9) continue } if ( $3 ~ "TIMESTAMP" ) { ################################################################ ### In 'TIMESTAMP' recs: ### Field#4=date ################################################################ SAVDATE = $4 continue } if ( $3 ~ "IN:" ) { if ( $4 ~ "ModelSolution" || $4 ~ "Optimization" || \ $4 ~ "Simulation" || $4 ~ "FEM" || \ $4 ~ "ModelResponse" || $4 ~ "Laminate" || \ $4 ~ "SystemDynamics" || $4 ~ "TMG" || \ $4 ~ "Dynamics" || \ $4 ~ "VibroAcoustics" || $4 ~ "Rayon" || \ $4 ~ "FEA" || $4 ~ "ABAQUS" || \ $4 ~ "ANSYS" || $4 ~ "NASTRAN" ) { ## For ModelSolution-only info: ## if ( $0 ~ "ModelSolution" ) { ################################################################ ### In 'IN:' recs: ### Field#1=Time-of-day Field#4=product Field#5=userid@hostid ################################################################ printf ("%12s %8s %-33s %-8s \n", SAVDATE, $1, $4, $5 ) ## printf (" %8s %12s %15s \n", $1, $4, $5 ) ## printf ( "this is an IN: rec \n" ) } } }' >> $OUTLIST2 ## For testing: # set - ################################################################### ## SHOW/PRINT 'CHRONOLOGICAL-ACTIVITY' REPORT. ################################################################### $FEDIR/scripts/shofil $OUTLIST2