flame: Who’s using my framestore?

Save the following as a text file named sws_info.pl in a convenient place and type:
chmod 755 ./sws_info.pl Edit the proper variables to reflect your configuration then by typing the command you’ll see which system is attached to which framestore and who is using it.

Enjoy !

 

#!/usr/bin/perl
#####################################################
# #
# sws_info.pl v0.98b (no guarantees) #
# #
# Authors: Sebastian Sylwan, Diego Cortassa #
# Company: Lumiq Studios #
# email: [email protected] #
# #
# Perl script to gather information on a discreet #
# switchable storage installation. It will scan #
# the stonefs directories on the switchable #
# storage shared area and tell #
# to which system each framestore is connected #
# and which local and remote processes are #
# accessing it. #
# #
# It relays on rsh to connect to the remote hosts #
# so be sure to have a .rhosts file in the home #
# directory of the user you are running the script #
# as (usually root). This has security caveats, so #
# please check with your sysadm before doing so. #
# #
# Change the relevant variables to fit your needs. #
# With small modifications it can be made to work #
# with non switchable storages. #
# #
# You are free to use distribute and modify this #
# script as long as you share the modifications #
# with the community and you drop the authors a #
# thank you email. #
# #
#####################################################

$myid=`id -u`;
$myid =~ s/n//;
if ($myid ne “0”) {
print “Must be root to run !!!”;
exit 0;
}
print “n”;
print “nsws_info.pl v0.98b (no guarantees)n”;
print “Authors: Sebastian Sylwan, Diego Cortassan”;
print “Lumiq Studios – [email protected]”;
$FS_ID_CMD=”/usr/discreet/sw/tools/sw_print_config |grep ‘FS Id:’ “;
$storage_dir=”/hosts/nas/data/”;
$machines=”flame inferno smoke backdraft”;
print “n*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~n”;
print “Framestore usage information for switchable storage systems:nn”, $machines, “n”;
print “n*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~n”;
foreach $machine ( split(” “, $machines) ) {
print “Machine:t”, $machine, “n”;
$FS_ID = `rsh $machine $FS_ID_CMD | awk ‘{print $3 }’ `;
$res= $!;
$FS_ID =~ s/n//;
print “Framestore Id:t”, $FS_ID, “nn”;
$stone_dir = “$storage_dir$FS_ID/clip/stonefs/”;
$ref=$stone_dir . “.ref” ;
$ref_cont=`cat $ref`;
if ( $ref_cont gt 0 ) {
$ref_log=”$stone_dir.ref.log”;
open(LOG_FILE,”){
@splitted_line = split(” “, $currline);
# print “DEBUG: “, $splitted_line[0], “t”,$splitted_line[1], “t”,$splitted_line[2], “t”,$s
plitted_line[3], “t”,$splitted_line[4],”n”;
$log_hash{$splitted_line[0].”-“.$splitted_line[1].”-“.$splitted_line[4]} = $splitted_line[3] ;
}
print “Processes apparently using framestore “, $FS_ID, ” attached to “, $machine, “:nn”;
foreach $machine_proc (keys %log_hash ) {
if ( $log_hash{$machine_proc} gt 0 ) {
@proc_details = split (“-“, $machine_proc) ;
printf(“%-23s (pid=%s) on the machine with HW-ID %sn”,$proc_details[2],$proc_details[1],$proc_deta
ils[0]);
}
}
%log_hash = ();
}
print “n*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~n”;
}

Submitter: Sebastian Sylwan