#!/usr/bin/perl # seti progress perl script... aka 'prog' # # version 1.1, finished 2003.10.22 # # by Thirteenth Shore Productions # # www.thirteenthshore.com # ### change setidir as necessary $setidir = "/Applications/seti"; # without trailing '/' ### end user settings use Term::ANSIColor; # gather CPU time and progress time $cpu = `grep 'cpu=' $setidir/state.sah`; $prog = `grep 'prog=' $setidir/state.sah`; # change CPU time to hours, one demical $cpu =~ s/cpu=//; $cpu /= 3600; $cpu = int($cpu * 10) / 10; # change progress to percentage, two decimals $prog =~ s/prog=//; $prog = int($prog * 1000) / 10; # gather total results, total cpu time, and last result submitted $nresults = `grep 'nresults=' $setidir/user_info.sah`; $totalcpu = `grep 'total_cpu=' $setidir/user_info.sah`; $lastresult = `grep 'last_result_time=' $setidir/user_info.sah`; # configure total results, total cpu time, last result $nresults =~ s/nresults=//; chop($nresults); $totalcpu =~ s/total_cpu=//; $lastresult =~ s/\((.*)\)//; $lastresult = $1; # configure average cpu time per result $ave = $totalcpu / $nresults; $ave /= 3600; $ave_hours = int($ave); $ave -= $ave_hours; $ave *= 60; $ave_mins = int($ave); $ave -= $ave_mins; $ave *= 60; $ave = int($ave * 10) / 10; # find projected time in hours # catch division by 0 if progress is 0% if ($prog != 0) { $projected = (100 / $prog) * $cpu; $projected = int($projected * 10) / 10; } else { $projected = $ave_hours; } # configure total cpu time, breakdown into days hours mins seconds # may not be entirely accurate, but really, what does it matter? $totalcpu /= 3600; $totalcpu /= 24; $totalcpu /= 365; $total_years = int($totalcpu); $totalcpu -= $total_years; $totalcpu *= 365; $total_days = int($totalcpu); $totalcpu -= $total_days; $totalcpu *= 24; $total_hours = int($totalcpu); $totalcpu -= $total_hours; $totalcpu *= 60; $total_mins = int($totalcpu); $totalcpu -= $total_mins; $totalcpu *= 60; $totalcpu = int($totalcpu * 100) / 100; # output the results! print "\n"; print ">>> " . localtime(time()) . " <<<"; $pid = `cat $setidir/pid.sah`; $ps = `ps -p $pid`; if ($ps !~ /setiathome/) { print color 'bold'; print " >>> SETI NOT CURRENTLY RUNNING <<<\n\n"; print color 'reset'; } else { print "\n\n"; } print "Last workunit submitted $lastresult.\n\n"; print "Current SETI\@home workunit: \%$prog done. CPU time is $cpu hours. Projected unit time is $projected hours.\n"; print "$nresults units completed in $total_years years, $total_days days, $total_hours hours, "; print "$total_mins minutes, $totalcpu seconds.\n"; print "Average workunit time is $ave_hours hours, $ave_mins minutes, $ave seconds.\n"; print "\n"; exit(0);