diff --git a/setistats.pl b/setistats.pl index a1cbabe..a51c95a 100644 --- a/setistats.pl +++ b/setistats.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# SETI@home stats 1.0 - shows current status of a running SETI-client in your browser +# SETI@home stats 1.1 - shows current status of a SETI-client in your browser # Copyright (C)1999 by Markus Birth - GPL v2 # http://www.webwriters.de/mbirth/ @@ -19,21 +19,37 @@ use CGI::Carp qw(fatalsToBrowser); -$VERSION = "1.0"; -$IMGDIR = "/cgi-data/setistats"; -$SETIDIR = "/opt/SETI"; +$IMGDIR = "/cgi-data/setistats"; # The httpd-path to the images + # this is that, what you would write in the + # -tag .... if your IMG-tag is like + # + # then you would change this line to + # $IMGDIR = "../bla/bli"; + +$SETIDIR = "/opt/SETI"; # The local path to your SETI-directory + # (the place, where all the .txt-files are stored in) + +$T_BOR = "black"; # Table border +$T_DBG = "#ffff80"; # Table description (left column) background +$T_VBG = "#ffffc0"; # Table value (right column) background + +### END OF CONFIGURATION SECTION! ### +$VERSION = "1.1"; + $ST = "$SETIDIR/state.txt"; $UI = "$SETIDIR/user_info.txt"; $WU = "$SETIDIR/work_unit.txt"; $VI = "$SETIDIR/version.txt"; +$BIN = "$SETIDIR/setiathome"; -$T_BOR = "black"; # Table border -$T_DBG = "#ffff80"; # Table descr. background -$T_VBG = "#ffffc0"; # Table value background +open (GPID, "/sbin/pidof $BIN|"); +$pid = ; +close GPID; +chomp $pid; $QS = $ENV{"QUERY_STRING"}; -print "Content-type: text/html\n"; +print "Content-type: text/html\n\n"; # print "Expires: Thu Jan 01 00:00:00 1970 GMT\n\n"; # client version: version.txt @@ -83,8 +99,9 @@ sub UserInfo { } &TableItem("Postal code", &Read($UI, "postal_code")); &TableItem("Country", &Read($UI, "country")); - &TableItem("Register time (GMT)", &JD2HMS(&Read($UI, "register_time"))); - &TableItem("Register time (JD)", &ExtrJD(&Read($UI, "register_time"))); + &TableItem("Register time", &JD2HMS(&Read($UI, "register_time")) . " (JD " . &ExtrJD(&Read($UI, "register_time")) . ")"); + &TableItem("Received last WU", &JD2HMS(&Read($UI, "last_wu_time")) . " (JD " . &ExtrJD(&Read($UI, "last_wu_time")) . ")"); + &TableItem("Sent last WU", &JD2HMS(&Read($UI, "last_result_time")) . " (JD " . &ExtrJD(&Read($UI, "last_result_time")) . ")"); &TableItem("Work Units", &Read($UI, "nwus") . " received, " . &Read($UI, "nresults") . " sent"); &TableItem("Total CPU time", &time2HMS(&Read($UI, "total_cpu"))); &TableStop; @@ -97,7 +114,7 @@ sub WorkUnitInfo { &TableItem("Record time (JD)", &ExtrJD(&Read($WU, "time_recorded"))); &TableItem("Receiver", "Arecibo Radio Observatory (" . &Read($WU, "receiver") . ")"); &TableItem("Tape version", &Read($WU, "tape_version")); - &TableItem("Area", &Read($WU, "start_ra") . " R.A., " . &Read($WU, "start_dec") . " DEC - " . &Read($WU, "end_ra") . " R.A. " . &Read($WU, "end_dec") . " Dec"); + &TableItem("Area", &Read($WU, "start_ra") . " R.A., " . &Read($WU, "start_dec") . " DEC - " . &Read($WU, "end_ra") . " R.A., " . &Read($WU, "end_dec") . " Dec"); &TableItem("Angle range", &Read($WU, "angle_range")); &TableItem("Subband number", &Read($WU, "subband_number")); &TableItem("Subband sample rate", &Read($WU, "subband_sample_rate")); @@ -122,7 +139,13 @@ sub WorkUnitInfo { } sub StateInfo { + if ($pid) { + $CS = "running with PID $pid"; + } else { + $CS = "not running (or couldn't get the PID)"; + } &TableStart("Current State"); + &TableItem("Client status", "$CS"); &TableItem("Progress status", &Read($ST, "prog")*100 . "%"); &TableItem("Unit CPU time", &time2HMS(&Read($ST, "cpu"))); &TableItem("Doppler shift rate", &Read($ST, "cr")); @@ -276,10 +299,11 @@ sub JD2HMS { # if ($month<10) { $month = "0" . "$month"; } my $month = $months[$tim[4]]; my $year = $tim[5]; + $year += 1900; my $wday = $weekdays[$tim[6]]; my $yday = $tim[7]; - return "$month $mday 19$year / $hour:$min:$sec"; + return "$month $mday $year / $hour:$min:$sec"; } sub ExtrJD {