=================================================================== RCS file: /cvs/wpscripts/zlist/zlist,v retrieving revision 1.3 retrieving revision 1.9 diff -u -r1.3 -r1.9 --- wpscripts/zlist/zlist 2011/07/19 16:49:24 1.3 +++ wpscripts/zlist/zlist 2012/02/02 07:41:05 1.9 @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: zlist,v 1.3 2011/07/19 16:49:24 yason Exp $ +# $Id: zlist,v 1.9 2012/02/02 07:41:05 yason Exp $ use DBI; use Term::ANSIColor qw(:constants); use Time::HiRes qw(gettimeofday tv_interval); @@ -38,11 +38,11 @@ my $time2 = [gettimeofday]; -print GREEN "Время отклика от базы данных: " . tv_interval($time1, $time2) . " секунд\n". RESET; +print GREEN "DB response time: " . tv_interval($time1, $time2) . " seconds\n". RESET; if( ! -e "/var/run/ztransfer.lock") { - print YELLOW "ztransfer сейчас не запущен\n" . RESET; + print YELLOW "ztransfer is not running\n" . RESET; } else { @@ -59,43 +59,82 @@ print "DEBUG: $file $action\n"; - print YELLOW "ztransfer выполняется [ " . ($action eq 'rar' ? "сжимается " : "копируется ") . "$file ]\n" . RESET; + print YELLOW "ztransfer is running [ " . ($action eq 'rar' ? "compressing " : "copying ") . "$file ]\n" . RESET; } else { - print YELLOW "ztransfer выполняется\n" . RESET; + print YELLOW "ztransfer is running\n" . RESET; } } # print out zayavki info -print BOLD WHITE ON_BLUE "Очередь заявок". RESET . " ($#numcard штук) :\n"; +print BOLD WHITE ON_BLUE "Zayavki queue". RESET . " ($#numcard pcs.) :\n"; $i = 0; while( ($numcard[$i]) ) { - print "$numcard[$i]\t[ оформлено $time[$i], приоритет=$pri[$i], файл=$path[$i] (размер=$size[$i]), счётчик передач=$tx_count[$i] ]\n"; + print "$numcard[$i]\t[ executed $time[$i], priority=$pri[$i], file=$path[$i] (size=$size[$i]), transfer counter=$tx_count[$i] ]\n"; $i++; $total++; } print "\n"; - # fetch probas - db_fetch(2); +# fetch probas +db_fetch(1); -# print "****** probas ($#numcard) ******\n"; - print BOLD WHITE ON_BLUE "Очередь цветопроб". RESET . " ($#numcard штук) :\n"; +#print "****** probas ($#numcard) ******\n"; +print BOLD WHITE ON_BLUE "Probas queue". RESET . " ($#numcard pcs.) :\n"; $i = 0; while( ($numcard[$i]) ) { - print "$numcard[$i]\t[ оформлено $time[$i], приоритет=$pri[$i], файл=$path[$i] (размер=$size[$i]) ]\n"; + print "$numcard[$i]\t[ executed $time[$i], priority=$pri[$i], file=$path[$i] (size=$size[$i]) ]\n"; $i++; $total++; } - print "\n"; +print "\n"; +# fetch TT +db_fetch(2); +print BOLD WHITE ON_BLUE "TT queue". RESET . " ($#numcard pcs.) :\n"; + $i = 0; + while( ($numcard[$i]) ) + { + print "$numcard[$i]\t[ executed $time[$i], priority=$pri[$i], file=$path[$i] (size=$size[$i]) ]\n"; + $i++; + $total++; + } +print "\n"; + +# fetch zayavki_ +db_fetch(3); + +print BOLD WHITE ON_BLUE "zayavki_ queue". RESET . " ($#numcard pcs.) :\n"; + $i = 0; + while( ($numcard[$i]) ) + { + print "$numcard[$i]\t[ executed $time[$i], priority=$pri[$i], file=$path[$i] (size=$size[$i]) ]\n"; + $i++; + $total++; + } +print "\n"; + +# fetch proba_ +db_fetch(4); + +print BOLD WHITE ON_BLUE "proba_ queue". RESET . " ($#numcard pcs.) :\n"; + $i = 0; + while( ($numcard[$i]) ) + { + print "$numcard[$i]\t[ executed $time[$i], priority=$pri[$i], file=$path[$i] (size=$size[$i]) ]\n"; + $i++; + $total++; + } +print "\n"; + + # print summary information -print BOLD WHITE . "Всего: " . RESET . "$total файлов в очереди на копирование в Заборье.\n"; +print BOLD WHITE . "Total: " . RESET . "$total files in queue.\n"; # close connection db_disconnect(); @@ -140,25 +179,24 @@ $searchpath = substr($path[$i], 13); # hardcoded -# $path[$i] = substr($path[$i], 30) if ($type_file == 0); -# $path[$i] = substr($path[$i], 34) if ($type_file == 1); -# $path[$i] = substr($path[$i], 34) if ($type_file == 2); + # remove first symbols to get only filename (i.e. \\fileserver\zayavki\ - 21 symbols) + $path[$i] = substr($path[$i], 21) if ($type_file == 0); #zayavki + $path[$i] = substr($path[$i], 19) if ($type_file == 1); #proba + $path[$i] = substr($path[$i], 16) if ($type_file == 2); #TT + $path[$i] = substr($path[$i], 22) if ($type_file == 3); #zayavki_ + $path[$i] = substr($path[$i], 19) if ($type_file == 4); #proba_ # make local file path $searchpath =~ tr/\\/\//; - #$searchpath = '/mnt/maket/' . $searchpath; + $searchpath = '/mnt/maket/' . $searchpath; - -# # follow symlink to achieve real path -# chomp( $_ = `dirname $searchpath | xargs /usr/bin/readlink` ); chomp( $searchpath = $_ . '/' . `basename $searchpath` ); - # finally, get file size $size[$i] = -s $searchpath; $size[$i] = ($size[$i] > 1048576 ? int($size[$i] / 1024 / 1024) . " MB" : int($size[$i] / 1024) . " KB"); # this should work fine - $size[$i] = WHITE ON_RED . "файл не найден" . RESET if (! -e $searchpath); + $size[$i] = WHITE ON_RED . "File not found" . RESET if (! -e $searchpath); $i++; }