# # netconfig - front end to all the other funtions# netcfgLoad - Load the netconfig# netcfgModified - Has NetConfig been modified# netcfgGetVersion - Get the file format version# netcfgGetConnList - Get the list of connections# netcfgGetConnCount - Get count of connections# netcfgGetGroupList - Get the list of groups# netcfgGetGroupCount - Get count of groups# netcfgGetProcList - Get the list of processes# netcfgGetProcCount - Get count of processes# netcfgGetConnData - Get data for a connection# netcfgGetProcData - Get data for a process# netcfgGetProcConns - Get the connections within a process# netcfgGetGroupConns - Get the connections within a group# netcfgIsConnInProcess - See if a connection is in a process# netcfgIsConnInGroup - See if a connection is in a group#
#!/usr/bin/ksh# this line to escape the next line from the tcl interpreter exec hcitcl "$0" "$@"# Begin Module Header ==============================================================================##------# Name:#------## cycle_all_SMAT.tcl##--------- # Purpose:#--------- ## in/out cycle save SMAT for all threads defined in $HCISITEDIR/NetConfig##--------# Inputs:#--------## none##-------# Notes:#-------## The HUB team standards require each SMAT file be named as follows:## ${thread}.in (for inbound SMAT files)# ${thread}.out (for outbound SMAT files)## The desired environment should be set before invoking this script.## At the time I wrote this script, the source code for the# hci proprietary TCL procs were loacted in file# $HCIROOT/tcl/lib/cloverleaf/nci.tlib##---------# History:#---------## 2001.02.28 Russ Ross# - wrote initial version## 2002.07.19 Russ Ross# - added logic to prevent cycling the SMAT files twice in a row before# the old SMAT files have been archived## 2003.05.04 RussRoss# - added logic to handle threads that are dead or do not exist anymore.## 2004.06.22 Russ Ross# - added logic to check that SMAT files are inactive for 7 days before assuming they are obsolete.### 2005.12.28 Russ Ross# - add logic to exit this script if no $HciSiteDir/monitorShmemFile exits## End of Module Header =============================================================================#--------------------------------------------------------------------------------# exit this script if the shared memory pointer/file does not exist# because running msiAttach without the existance of a shared memory pointer/file# has a history of causing shared memory conflicts#--------------------------------------------------------------------------------if { [lsearch -exact [ls $HciSiteDir/exec] monitorShmemFile] == -1 } { exit }msiAttachnetcfgLoadforeach proc [netcfgGetProcList] { foreach thread [lsort [netcfgGetProcConns $proc]] { set klist_msiTocEntry_connection [msiTocEntry $thread] set thread_alive [keylget klist_msiTocEntry_connection ALIVE] #---------------------------------------------------------------------------- # cycle inbound and outbound SMAT if thread is running and no old SMAT exists #---------------------------------------------------------------------------- if { $thread_alive } { if ![file exists $HciProcessesDir/$proc/${thread}.in.old.idx] { catch {exec hcicmd -p $proc -c "$thread save_cycle in" 2>/dev/null} } if ![file exists $HciProcessesDir/$proc/${thread}.out.old.idx] { catch {exec hcicmd -p $proc -c "$thread save_cycle out" 2>/dev/null} } } #------------------------------------------------------------------------------------- # rename the inbound and outbound SMAT if thread is not running and no old SMAT exists #------------------------------------------------------------------------------------- if { !$thread_alive } { if {[file exists $HciProcessesDir/$proc/${thread}.in.idx] & ![file exists $HciProcessesDir/$proc/${thread}.in.old.idx]} { catch {exec mv $HciProcessesDir/$proc/${thread}.in.idx $HciProcessesDir/$proc/${thread}.in.old.idx 2>/dev/null} catch {exec mv $HciProcessesDir/$proc/${thread}.in.msg $HciProcessesDir/$proc/${thread}.in.old.msg 2>/dev/null} } if {[file exists $HciProcessesDir/$proc/${thread}.out.idx] & ![file exists $HciProcessesDir/$proc/${thread}.out.old.idx]} { catch {exec mv $HciProcessesDir/$proc/${thread}.out.idx $HciProcessesDir/$proc/${thread}.out.old.idx 2>/dev/null} catch {exec mv $HciProcessesDir/$proc/${thread}.out.msg $HciProcessesDir/$proc/${thread}.out.old.msg 2>/dev/null} } } }; # end of thread loop #--------------------------------------------------------------------------------- # rename any inbound SMAT for threads that have been inactive for more than 7 days #--------------------------------------------------------------------------------- set obsolete_smat_list [exec find $HciProcessesDir/$proc/ -type f -mtime +7 -name "*.in.idx"] foreach idx_file $obsolete_smat_list { regsub ".in.idx$" $idx_file {.in.msg} msg_file regsub ".in.idx$" $idx_file {.in.old.idx} old_idx_file regsub ".in.idx$" $idx_file {.in.old.msg} old_msg_file if ![file exists $old_idx_file] { catch {exec mv $idx_file $old_idx_file 2>/dev/null} catch {exec mv $msg_file $old_msg_file 2>/dev/null} } } #---------------------------------------------------------------------------------- # rename any outbound SMAT for threads that have been inactive for more than 7 days #---------------------------------------------------------------------------------- set obsolete_smat_list [exec find $HciProcessesDir/$proc/ -type f -mtime +7 -name "*.out.idx"] foreach idx_file $obsolete_smat_list { regsub ".out.idx$" $idx_file {.out.msg} msg_file regsub ".out.idx$" $idx_file {.out.old.idx} old_idx_file regsub ".out.idx$" $idx_file {.out.old.msg} old_msg_file if ![file exists $old_idx_file] { catch {exec mv $idx_file $old_idx_file 2>/dev/null} catch {exec mv $msg_file $old_msg_file 2>/dev/null} } }}; # end of process loop
Originally posted by garry r fisher