Index  | Recent Threads  | Unanswered Threads  | Who's Active  | Guidelines  | Search
 

Quick Go »
No member browsing this thread
Thread Status: Active
Total posts in this thread: 65
Posts: 65   Pages: 7   [ Previous Page | 1 2 3 4 5 6 7 | Next Page ]
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 13413 times and has 64 replies Next Thread
adriverhoef
Master Cruncher
The Netherlands
Joined: Apr 3, 2009
Post Count: 2346
Status: Offline
Project Badges:
Reply to this Post  Reply with Quote 
Re: Version 1.18 of my script 'wcgresults'

Thank you, Tony, that's very nice to hear, and to see an example of using the output of "wcgresults".
Did you also have 'an idea' (your machine's statistics website) and then build more and more? biggrin

Since the script spits out ANSI strings to highlight all machine names (using -dq), did that pose any difficulty?

An alternative output would be to highlight the time and to put the 'queue' of each machine unhighlighted on a new line, like this (proposing the option -Q, it's just an idea):
$ while sleep 3600; do wcgresults -dQQ; done
15:08:34
device_a mcm1:9 oet1:4 zika:1
device_b scc1:3
device_c mcm1:9
16:08:36
device_a mcm1:5 oet1:6 zika:3
device_b scc1:3
device_c mcm1:11
17:08:38
device_a mcm1:3 oet1:7 zika:3
device_b scc1:3
device_c mcm1:12
etc.

The results with -dQ (omitting the AppNames, just counting the total current number of WUs per machine) would then be:
$ while sleep 3600; do wcgresults -dQ; done
15:08:34
device_a 14
device_b 3
device_c 9
16:08:36
device_a 14
device_b 3
device_c 11
17:08:38
device_a 13
device_b 3
device_c 12
etc.
If that makes it easier for someone ...

Or, if you're only interested in the current queue of tasks on your local machine (also just an idea):
$ wcgresults -tt
13 tasks: 9 downloaded, 3 uploaded, 1 uploading
(R) = Running; (S) = Suspended; (.) = Ready to report
MCM1_0130341_2677_3(.)
SCC1_0000088_Bct-C_99068_1(R)
etc.

There are just so many possibilities! wink
----------------------------------------
[Edit 1 times, last edit by adriverhoef at Feb 12, 2017 9:27:03 AM]
[Feb 12, 2017 1:16:05 AM]   Link   Report threatening or abusive post: please login first  Go to top 
TonyEllis
Senior Cruncher
Australia
Joined: Jul 9, 2008
Post Count: 286
Status: Offline
Project Badges:
Reply to this Post  Reply with Quote 
Re: Version 1.18 of my script 'wcgresults'

Sure - it has grown - but almost finished :-) - just waiting for my USB thermometer to be delivered and that's it... see http://www.phoronix.com/scan.php?page=article...st-temper-linux&num=1
Thanks for the ideas - just # WIP and # active systems was all I was after... my script just sums and counts the numbers - ignores the machine names so ascii codes not a problem...

Here in Australia we are currently experiencing catastrophic heat-wave conditions with temperatures up to 46 C (115 F). My office has no air-conditioning so I have been forced to write a linux script to continuously monitor the CPU temperature and modify <cpu_usage_limit> to limit CPU temp e.g. http://www.sraellis.tk/frame-28-boinc_adjust.html and http://www.sraellis.tk/frame-28-cputemp.html - was more effective than I thought would be possible...

Across New South Wales state 76 bush fires are burning and 21 of those are not under control. Many are having to flee their homes and several have nothing but ashes and debris to return to. I live right beside a nature reserve and can practically touch the gum trees from my balcony - bad news if they catch on fire.
----------------------------------------
----------------------------------------
[Edit 3 times, last edit by TonyEllis at Feb 13, 2017 7:04:07 PM]
[Feb 12, 2017 2:30:23 AM]   Link   Report threatening or abusive post: please login first  Go to top 
adriverhoef
Master Cruncher
The Netherlands
Joined: Apr 3, 2009
Post Count: 2346
Status: Offline
Project Badges:
Reply to this Post  Reply with Quote 
Re: Version 1.18 of my script 'wcgresults'

Across New South Wales state 76 bush fires are burning and 21 of those are not under control. Many are having to flee their homes and several have nothing but ashes and debris to return to. I live right beside a nature reserve and can practically touch the gum trees from my balcony - bad news if they catch on fire.

That would be very bad news, Tony. My girlfriend lived in New South Wales in a nature reserve, in Hazelbrook (Blue Mountains National Park).
[Feb 12, 2017 9:41:56 PM]   Link   Report threatening or abusive post: please login first  Go to top 
thunder7
Senior Cruncher
Netherlands
Joined: Mar 6, 2013
Post Count: 238
Status: Offline
Project Badges:
Reply to this Post  Reply with Quote 
Re: Version 1.18 of my script 'wcgresults'

What arguments do I use to get the jobs on each device that are actually running at the moment? It seems 'in progress' means 'has been downloaded to run as a cpu becomes available'

-w -d shows only 26 occurences of a hostname with has 80 threads running, so that's not it.
Using -l 8192 with that doesn't change this number.
-dq shows me 1236 projects in progress on the 80 thread machine, so that's not it either.
[Apr 14, 2017 8:35:28 AM]   Link   Report threatening or abusive post: please login first  Go to top 
SekeRob
Master Cruncher
Joined: Jan 7, 2013
Post Count: 2741
Status: Offline
Reply to this Post  Reply with Quote 
Re: Version 1.18 of my script 'wcgresults'

Probably by quizzing the client_state.xml file. For instance, a running job has a <slot>#</slot> tag and a leading <active_task> and closing </active_task>. Of course, if there are preempted tasks due rush hour, you could have more active than there are threads.

<active_task>
<project_master_url>http://www.worldcommunitygrid.org/</project_master_url>
<result_name>OET1_0004609_x4GV6p_rig_52453_0</result_name>
<active_task_state>1</active_task_state>
<app_version_num>719</app_version_num>
<slot>1</slot>
<checkpoint_cpu_time>0.000000</checkpoint_cpu_time>
<checkpoint_elapsed_time>0.000000</checkpoint_elapsed_time>
<checkpoint_fraction_done>0.000000</checkpoint_fraction_done>
<checkpoint_fraction_done_elapsed_time>0.000000</checkpoint_fraction_done_elapsed_time>
<current_cpu_time>434.890600</current_cpu_time>
<once_ran_edf>0</once_ran_edf>
<swap_size>48648192.000000</swap_size>
<working_set_size>27643904.000000</working_set_size>
<working_set_size_smoothed>27287120.000000</working_set_size_smoothed>
<page_fault_rate>0.000000</page_fault_rate>
<bytes_sent>0.000000</bytes_sent>
<bytes_received>0.000000</bytes_received>
</active_task>

Not sure though what this has anything to do with the topics WCG API that allows extracting info from the Result Status data set on the website.
----------------------------------------
[Edit 1 times, last edit by SekeRob* at Apr 14, 2017 9:15:43 AM]
[Apr 14, 2017 9:15:01 AM]   Link   Report threatening or abusive post: please login first  Go to top 
adriverhoef
Master Cruncher
The Netherlands
Joined: Apr 3, 2009
Post Count: 2346
Status: Offline
Project Badges:
Reply to this Post  Reply with Quote 
Re: Version 1.18 of my script 'wcgresults'

What arguments do I use to get the jobs on each device that are actually running at the moment?

You would have to use the -r option that I introduced in version 1.19 of wcgresults. But ... you can only run it on the device itself to get meaningful results. There is no way to tell that a job is running on another device than your current one, as far as I can tell.

This is version 1.30.1 of 'wcgresults'.
Save the code below to a file called 'wcgresults', then change the values of MEMBER=… and VERIFY=… when/while editing the file to reflect the credentials of your account, chmod +x it and move it to your ~/bin directory.
--- CUT HERE --- snip 8< --- snip 8< --- snip 8< --- snip 8< --- snip 8< --- snip 8<
#!/bin/sh
#
# wcgresults - use WCG's API to get a list of recent results
# https://www.worldcommunitygrid.org/help/viewTopic.do?shortName=api
#
# VERSION: 1.30.1
# Author: Adri Verhoef

Prog=${0##*/}

#############
# CONFIGURE #
#############
TMPDIR=/var/tmp # Directory for storing temporary files
URLBASE=www.worldcommunitygrid.org # Don't change this, unless you know what you're doing
HTTPS="https:"// # Don't change this, unless you know what you're doing
MEMBER="youraccountname" # The name of your account with which you're crunching
VERIFY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # Your verification code on 'My Profile' (see website)
MEMBER1="anotheraccount" # The name of the account for user 1
VERIFY1="11111111111111111111111111111111" # Verification code for user 1's account
########################
# END OF CONFIGURATION #
########################

usage () {
printf "%s\n" \
"Usage: $Prog [options] [-d | file ...]" \
" Options:" \
" -A omit ANSI-code [can be used with options -q, -r and -t]" \
" -a [see option -f] also record results that got 0 points all in all" \
" -b sortby sort results by the value of ’sortby’" \
" (0 = DeviceId, 1 = SentTime, 2 = ReportDeadline, 3 = ReceivedTime (default), 4 = CpuTime)" \
" -c calculate the optimal size of the jobcache" \
" -D dir download new results to directory ’dir’" \
" -d download new results (for all devices)" \
" -f logfile record results (for all devices) that went through the validator to file ’logfile’, sorted by CpuTime" \
" -i info depending on the value of ’info’ (E, O, S, or V)," \
" E only show the textvalue of each defined ExitStatus >= 192" \
" O only show the textvalue of each defined Outcome" \
" S only show the textvalue of each defined ServerState" \
" V only show the textvalue of each defined ValidateState" \
" -l limit define the number of results to download (default: 250)" \
" -m show all tasknames on this device, each listed with ”report deadline” and ”fraction done”" \
" -o offset define the number of results to skip when downloading (default: 0)" \
" -q only show the number of jobs in progress per device (”-qq” will also list the apps) on one line" \
" -r only show the names of all running tasks in the queue on this device" \
" -s state only select results with ”ValidateState” value ’state’" \
" (0 = pending validation, 1 = valid, 2 = invalid," \
" 4 = pending verification, 5 = results failed to validate within given deadline)" \
" -t only show all tasknames in the queue on this device; use -T to show only one taskname per line" \
" -u user the name of your account on World Community Grid (default: you; ’user’ = 1 ... for other account(s))" \
" -w only select results (max. 250) (for all devices) that are still 'in progress'" \
" -x retry all current file transfer(s) on this device" \
" -z only show the names of all suspended tasks in the queue on this device" \
;
}

# Options
OPTS=hAab:cD:df:i:l:mo:qrs:tTu:wxz
export opt_A=0 # 1: omit ANSI
export opt_a=0
export opt_b=3 # latest received
export opt_c=0
export opt_D=$TMPDIR
export opt_d=0
export opt_f=""
export opt_i=""
export opt_l=250
export opt_m=0
export opt_o=0
export opt_q=0 # 1: show the queue of all devices on one line
export opt_r=0 # 1: show running tasks on this device
export opt_s=""
export opt_T=0
export opt_t=0
export opt_u=""
export opt_w=0
export opt_x=0
export opt_z=0
while getopts $OPTS opt; do
case $opt in
h) usage; exit 0;;
[AacdmqrTtwxz]) eval let opt_$opt++;;
[a-zA-Z0-9]) eval opt_$opt='$OPTARG';;
?) usage; exit 1;;
esac
done
shift $(($OPTIND - 1))

case $opt_b in [01234]) case $opt_b in 0) opt_b=DeviceId;; 1) opt_b=SentTime;; 2) opt_b=ReportDeadline;; 3) opt_b=ReceivedTime;; 4) opt_b=CpuTime;; esac; SortBy="&SortBy=$opt_b";; *) SortBy="";; esac
case $opt_o in 0) Offset="";; *) Offset="&Offset=$opt_o";; esac
case $opt_q in 0) ;; *) opt_w=1;; esac # see below
case $opt_r in 0) ;; *) opt_t=1;; esac
case $opt_s in [01245]) ValidateState="&ValidateState=$opt_s";; *) ValidateState="";; esac
case $opt_T in 0) ;; *) opt_t=1;; esac
case $opt_u in "") ;; *) eval MEMBER=\$MEMBER$opt_u; eval VERIFY=\$VERIFY$opt_u;; esac
case $opt_w in 0) ServerState=5;; *) ServerState=4;; esac
case $opt_z in 0) ;; *) opt_t=1;; esac

TMPFILE=$opt_D/$Prog.`date +%Y-%m-%dT%H:%M:%S.$$`

FMT_C='6.1f' # Format (of floating point number, w/o '%' or '%-') to be used in ’printf’ for ”ClaimedCredit” and ”GrantedCredit”
FMT_T='7.2f' # Format (of floating point number, w/o '%' or '%-') to be used in ’printf’ for ”CpuTime” and ”ElapsedTime”
FMT_6='......' # value 'not yet known' (instead of %-$FMT_C)
FMT_7='.......' # value 'not yet known' (instead of %-$FMT_F)
C_L="%$FMT_C" # $FMT_C preceded by "%"
C_R="%-$FMT_C" # $FMT_C preceded by "%-"
T_L="%$FMT_T" # $FMT_T preceded by "%"
T_R="%-$FMT_T" # $FMT_T preceded by "%-"
cc_='$combi_DeviceName_AppName_ValidateState_count''''''''{$DeviceName}{$AppName}{$ValidateState}'
ccc='$combi_DeviceName_AppName_ValidateState_ClaimedCredit{$DeviceName}{$AppName}{$ValidateState}'
cct='$combi_DeviceName_AppName_ValidateState_CpuTime''''''{$DeviceName}{$AppName}{$ValidateState}'
cet='$combi_DeviceName_AppName_ValidateState_ElapsedTime''{$DeviceName}{$AppName}{$ValidateState}'
cgc='$combi_DeviceName_AppName_ValidateState_GrantedCredit{$DeviceName}{$AppName}{$ValidateState}'
PRINT_LONG_FORMAT='
if ($ValidateState == 0 || $ValidateState == 4) {
$Grant = "'$FMT_6'"; # Pending ...
} else {
$Grant = sprintf "'$C_R'", '$cgc' / '$cc_';
}
printf "%-20s %6d '$C_L'/$Grant '$T_L'/'$T_R'", $txt_ValidateState[$ValidateState], '$cc_', '$ccc' / '$cc_', '$cct' / '$cc_', '$cet' / '$cc_';
printf "\n";
'
ADDITIONAL_HEADER='(ValidateState) (Claim/Grant) (CpuTime/Elapsed)'
PRINT_EACH_HEADER='
printf "%-16s %-6s %4d\t'"$ADDITIONAL_HEADER"'\n", $DeviceName, $AppName, $combi_DeviceName_AppName{$DeviceName}{$AppName}
'
PRINT_HEADER_ONLY='
printf "\t''\t''\t''''\t'"$ADDITIONAL_HEADER"'\n"
'

calculate_or_record () {
perl -wne '
BEGIN {
$txt_Outcome[0] = "(waiting)"; # in progress
$txt_Outcome[1] = "success";
$txt_Outcome[2] = ""; # UNDEFINED
$txt_Outcome[3] = "error";
$txt_Outcome[4] = "no reply";
$txt_Outcome[5] = ""; # UNDEFINED
$txt_Outcome[6] = "validation error";
$txt_Outcome[7] = "abandoned";
$txt_ServerState[4] = "Still in progress";
$txt_ServerState[5] = "Already reported back to the server";
$txt_ValidateState[0] = "Pending validation";
$txt_ValidateState[1] = "Valid";
$txt_ValidateState[2] = "Invalid";
$txt_ValidateState[3] = "In progress"; # UNDEFINED, see option -w
$txt_ValidateState[4] = "Pending verification";
$txt_ValidateState[5] = "Too late";
# http://boinc.berkeley.edu/error_numbers.h
#str_ExitStatus[192] = "EXIT_STATEFILE_WRITE";
$txt_ExitStatus[192] = "The client will exit if it cannot write to the client_state.xml file. Make sure you have permission to write to the BOINC Data directory.";
#str_ExitStatus[193] = "EXIT_SIGNAL";
$txt_ExitStatus[193] = "The client, Manager and/or application will exit when getting the exit signal.";
#str_ExitStatus[194] = "EXIT_ABORTED_BY_CLIENT";
$txt_ExitStatus[194] = "Task was aborted by the BOINC client.";
#str_ExitStatus[195] = "EXIT_CHILD_FAILED";
$txt_ExitStatus[195] = "The science application running the task failed for unknown reasons.";
#str_ExitStatus[196] = "EXIT_DISK_LIMIT_EXCEEDED";
$txt_ExitStatus[196] = "The amount of disk space that the task could use was more than the limit set to the task.";
#str_ExitStatus[197] = "EXIT_TIME_LIMIT_EXCEEDED";
$txt_ExitStatus[197] = "The amount of time that the task can run was estimated to be far greater than the time limit set to the task.";
#str_ExitStatus[198] = "EXIT_MEM_LIMIT_EXCEEDED";
$txt_ExitStatus[198] = "The amount of memory that the task could use was greater than the limit set to the task.";
#str_ExitStatus[199] = "EXIT_CLIENT_EXITING";
$txt_ExitStatus[199] = "The task was ended when the client was exited.";
#str_ExitStatus[200] = "EXIT_UNSTARTED_LATE";
$txt_ExitStatus[200] = "Task was aborted due to it having not started and already past the deadline.";
#str_ExitStatus[201] = "EXIT_MISSING_COPROC";
$txt_ExitStatus[201] = "A coprocessor that was detected earlier went missing. Work for it is being aborted.";
#str_ExitStatus[202] = "EXIT_ABORTED_BY_PROJECT";
$txt_ExitStatus[202] = "Tasks on the computer were aborted by the project.";
#str_ExitStatus[203] = "EXIT_ABORTED_VIA_GUI";
$txt_ExitStatus[203] = "Applications exit with this code after you told them to abort.";
#str_ExitStatus[204] = "EXIT_UNKNOWN";
$txt_ExitStatus[204] = "Unknown exit.";
#str_ExitStatus[205] = "EXIT_OUT_OF_MEMORY";
#str_ExitStatus[206] = "EXIT_INIT_FAILURE";
#str_ExitStatus[207] = "EXIT_NO_SUB_TASKS";
#str_ExitStatus[208] = "EXIT_SUB_TASK_FAILURE";
if ($ENV{opt_i} ne "") {
$opti = 0;
if ($ENV{opt_i} =~ /[Ee]/) {
printf "Exit\tMeaning\n";
for ($i = 192; $i <= 204; $i++) {
printf "%4d\t%s\n", $i, $txt_ExitStatus[$i];
}
$opti++;
}
if ($ENV{opt_i} =~ /[Oo]/) {
printf "\n" if $opti > 0;
printf "Outc\tMeaning\n";
for ($i = 0; $i <= 7; $i++) {
printf "%4d\t%s\n", $i, $txt_Outcome[$i] unless $txt_Outcome[$i] eq "";
}
$opti++;
}
if ($ENV{opt_i} =~ /[Ss]/) {
printf "\n" if $opti > 0;
printf "Server-\nState\tMeaning\n";
for ($i = 4; $i <= 5; $i++) {
printf "%4d\t%s\n", $i, $txt_ServerState[$i];
}
$opti++;
}
if ($ENV{opt_i} =~ /[Vv]/) {
printf "\n" if $opti > 0;
printf "Validate-\nState\tMeaning\n";
for ($i = 0; $i <= 5; $i++) {
printf "%4d\t%s\n", $i, $txt_ValidateState[$i] unless $i == 3;
}
}
exit(0);
}
if ($ENV{opt_f} ne "") {
if (open(LOGFILE, $ENV{opt_f})) {
while (<LOGFILE>) {
chomp;
@t = split(/\t/);
$GRANTEDCREDIT = 5;
#$MODTIME = 8;
$NAME = 11;
$VALIDATESTATE = 17;
$grantedc{$t[$NAME]} = $t[$GRANTEDCREDIT];
#$modtime{$t[$NAME]} = $t[$MODTIME]; # If a workunit is user aborted, it will have its ModTime changed later on and we do not want to record that. So forget this. :-)
$workunit{$t[$NAME]} = $t[$VALIDATESTATE];
}
close(LOGFILE);
}
open(LOGFILE, ">>$ENV{opt_f}") || die "$ENV{Prog}: cannot open logfile ’$ENV{opt_f}’ for writing.\n";
}
$outcome_varies = 0;
$result_matches = 0;
}
chomp;
if (/"ResultsReturned": "([^"]+)",/) { print "Results returned: $1\n" unless $ENV{opt_f} ne ""; }
elsif (/"AppName": "([^"]+)",/) { $AppName = $1; }
elsif (/"ClaimedCredit": ([^,]+)/) { $ClaimedCredit = $1; }
elsif (/"CpuTime": ([^,]+)/) { $CpuTime = $1; }
elsif (/"ElapsedTime": ([^,]+)/) { $ElapsedTime = $1; }
elsif (/"ExitStatus": ([^,]+)/) { $ExitStatus = $1; }
elsif (/"GrantedCredit": ([^,]+)/) { $GrantedCredit = $1; }
elsif (/"DeviceId": ([^,]+)/) { $DeviceId = $1; } # only used for LOGFILE
elsif (/"DeviceName": "([^"]+)",/) { $DeviceName = $1; }
elsif (/"ModTime": ([^,]+)/) { $ModTime = $1; } # only used for LOGFILE
elsif (/"WorkunitId": ([^,]+)/) { $WorkunitId = $1; } # only used for LOGFILE
elsif (/"ResultId": ([^,]+)/) { $ResultId = $1; } # only used for LOGFILE
elsif (/"Name": "([^"]+)",/) { $Name = $1; }
elsif (/"Outcome": ([^,]+)/) { $Outcome = $1; }
elsif (/"ReceivedTime": "([^"]+)",/) { $ReceivedTime = $1; } # only used for LOGFILE
elsif (/"ReportDeadline": "([^"]+)",/) { $ReportDeadline = $1; } # only used for LOGFILE
elsif (/"SentTime": "([^"]+)",/) { $SentTime = $1; } # only used for LOGFILE
elsif (/"ServerState": ([^,]+)/) { $ServerState = $1; }
elsif (/"ValidateState": ([^,]+)/) { $ValidateState = $1; }
elsif (/"FileDeleteState": ([^,]+)/) { $FileDeleteState = $1; } # only used for LOGFILE
if (/"([^"]+)": ("([^"]+)"|[0-9]+(\.[0-9]+)?)$/) { # last item in record, line not ending in comma
if ($ENV{opt_f} ne "") {
# ServerState == 5: results that have already been reported back to the server
# ValidateState == 0: pending validation
# ValidateState == 4: pending verification
if ($ServerState == 5 && $ValidateState != 0 && $ValidateState != 4 || $ENV{opt_w} > 0) {
if (exists $workunit{$Name}) {
if ($workunit{$Name} != $ValidateState) {
print STDERR "$Name has its ValidateState changed from $workunit{$Name} to $ValidateState\n"; # Hopefully changed from ”Too Late” into something better. (Or probably opt_w>0)
} elsif ($grantedc{$Name} != $GrantedCredit) {
print STDERR "$Name has its GrantedCredit changed from $grantedc{$Name} to $GrantedCredit\n"; # Sometimes an ”Invalid” result (with credit ”0.0”) was granted some credit after all.
} else {
next; # already recorded in LOGFILE; the names of workunits vary per device, so no need to use $DeviceId or $WorkunitId to distinguish between them
}
}
do {
next if $ClaimedCredit + $CpuTime + $ElapsedTime + $GrantedCredit == 0.0; # probably: 192 <= $ExitStatus <= 204
} if $ENV{opt_a} + $ENV{opt_w} == 0; # opt_a=1: record all WUs, also those that got 0 points.
$ReceivedTime = "" if $ENV{opt_w} > 0;
printf LOGFILE "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", $AppName, $ClaimedCredit, $CpuTime, $ElapsedTime, $ExitStatus, $GrantedCredit, $DeviceId, $DeviceName, $ModTime, $WorkunitId, $ResultId, $Name, $Outcome, $ReceivedTime, $ReportDeadline, $SentTime, $ServerState, $ValidateState, $FileDeleteState;
$workunit{$Name} = $ValidateState; # for feeding from file ...
$grantedc{$Name} = $GrantedCredit; # ... to avoid duplicates (when feeding a whole bunch of files at the same time)
}
} else {
if ($Outcome != 1) {
if ($Outcome == 0) {
$ValidateState = 3; # In progress
$ExitStatus = "-";
}
$fmt0 = "%-16s %-6s %-9s %-20s %-6s";
$fmt1 = " %s %s";
if ($ValidateState == 3) {
$sClaimed = "'$FMT_6'";
$sGranted = "'$FMT_6'";
$sCPUTime = "'$FMT_7'";
$sElapsed = "'$FMT_7'";
} else {
$sClaimed = sprintf "'$C_L'", $ClaimedCredit;
$sGranted = sprintf "'$C_R'", $GrantedCredit;
$sCPUTime = sprintf "'$T_L'", $CpuTime;
$sElapsed = sprintf "'$T_R'", $ElapsedTime;
}
$fmt2 = "$sClaimed/$sGranted $sCPUTime/$sElapsed";
$fmt3 = " %s\n";
printf "$fmt0$fmt1$fmt3", "(DeviceName)", "(App)", "(Outcome)", "(ValidateState)", "(Exit)", "(Claim/Grant)", "(CpuTime/Elapsed)", "(Name)" if ++$outcome_varies == 1;
if ($ExitStatus ne "-") {
if ($ExitStatus >= 192 && $ExitStatus <= 204) {
if (not exists $DidExitStatus[$ExitStatus]) {
$DidExitStatus[$ExitStatus] = 1;
printf "\tExitStatus $ExitStatus: $txt_ExitStatus[$ExitStatus]\n";
}
}
}
##printf "$fmt0 $fmt2$fmt3", $DeviceName, $AppName, $txt_Outcome[$Outcome], $txt_ValidateState[$ValidateState], $ExitStatus, $ClaimedCredit, $GrantedCredit, $CpuTime, $ElapsedTime, $Name;
printf "$fmt0 $fmt2 $fmt3", $DeviceName, $AppName, $txt_Outcome[$Outcome], $txt_ValidateState[$ValidateState], $ExitStatus, $Name;
}
if ($ServerState == 5) {
# results that have already been reported back to the server
$combi_DeviceName_AppName{$DeviceName}{$AppName}++; # name of the app, e.g. "beta24", "mcm1"
'$cc_'++; # number of validated results
'$ccc' += $ClaimedCredit;
'$cct' += $CpuTime;
'$cet' += $ElapsedTime;
'$cgc' += $GrantedCredit;
$result_matches++ if $ENV{opt_s} eq "" || $ENV{opt_s} eq $ValidateState;
}
}
}
END {
if ($result_matches > 0) {
printf "%s %s %-6s %s %s\n", "=" x 16, " " x 4, " (Number)", " " x 20, "(Number)" unless $outcome_varies == 0;
'"$PRINT_HEADER_ONLY"' if $ENV{opt_s} ne "";
foreach $DeviceName (sort keys %combi_DeviceName_AppName) {
foreach $AppName (sort keys %{$combi_DeviceName_AppName{$DeviceName}}) {
if ($ENV{opt_s} eq "") {
'"$PRINT_EACH_HEADER"';
foreach $ValidateState (sort keys %{$combi_DeviceName_AppName_ValidateState_count{$DeviceName}{$AppName}}) {
printf "\t\t\t\t";
'"$PRINT_LONG_FORMAT"'
}
} else {
foreach $ValidateState (sort keys %{$combi_DeviceName_AppName_ValidateState_count{$DeviceName}{$AppName}}) {
if ($ENV{opt_s} eq $ValidateState) {
printf "%-16s %-6s %4d\t", $DeviceName, $AppName, $combi_DeviceName_AppName{$DeviceName}{$AppName};
'"$PRINT_LONG_FORMAT"'
}
}
}
}
}
}
}
' "$@"
}

do_opt_c () {
perl -wne '
BEGIN {
$ask = "Duration of a workunit (hh:mm:ss or mm:ss or number of seconds): "; print $ask;
}
chomp;
s/^ +//;
s/ +$//;
$s = $_;
if ($s =~ /^([0-9]+)[h:]([0-9]+)[m:]([0-9]+)s?$/) {
$secs = 3600*$1 + 60*$2 + $3;
} elsif ($s =~ /^([0-9]+)h([0-9]+)m?$/) {
$secs = 3600*$1 + 60*$2;
} elsif ($s =~ /^([0-9]+)h$/) {
$secs = 3600*$1;
} elsif ($s =~ /^([0-9]+)[m:]([0-9]+)s?$/) {
$secs = 60*$1 + $2;
} elsif ($s =~ /^([0-9]+)m$/) {
$secs = 60*$1;
} elsif ($s =~ /^([0-9]+)s?$/) {
$secs = $1;
} elsif ($s eq ".") {
exit(0);
} else {
printf "Invalid time, try 1h30m0s or 50m22s or 3600s\n\n";
$secs = 0;
}
printf "You could set your jobcache to %.2f days.\n\n", $secs * 35 / 86400 if $secs > 0;
print $ask;
'
}

do_opt_m () {
let part=0
TMP_BOINCCMD=/tmp/boinccmd.$$
boinccmd --get_tasks > $TMP_BOINCCMD.$part
for key in "report deadline" "fraction done" "name"; do
let part++
sed -n "s/^ $key: //p" $TMP_BOINCCMD.0 > $TMP_BOINCCMD.$part
done
if [ $opt_m -gt 1 ]; then
FOURDASH=----
DDDDDASH=$FOURDASH$FOURDASH$FOURDASH$FOURDASH
printf "%24s\t%-8s\t%s\n" "${DDDDDASH}Deadline" "Fraction" "Name${DDDDDASH}"
fi
# Sample output from 'paste':
# Tue Mar 14 12:05:37 2017 0.237921 HST1_008952_000037_MC0024_T400_F00020_S00008_0
paste $TMP_BOINCCMD.[123]
rm -f $TMP_BOINCCMD.[0-3]
}

do_opt_t () {
if [ $opt_r = 0 -a $opt_z = 0 ]; then
# opt_t
PERL_PUT_STATE='printf "%s(%s)%s", '"$PERL_INIT_ANSI"', $s, '"$PERL_EXIT_ANSI"''
PERL_TERM_SIZE='
use Term::Size "chars"; # Fedora: dnf install perl-Term-Size
'
PERL_INIT_COLS='
$maxl = 0; # find longest taskname
(($cols, $rows) = chars(STDOUT)) || ($cols = 0);
$cols = 80 if $cols == 0;
'
PERL_INIT_MAXL='
$x = length $1;
$maxl = $x if $x > $maxl;
'
PERL_INIT_WHAT='
$what{$1} = "";
'
PERL_SET_STATE='
$what{$name{$n}} = $1;
'
PERL_FIND_RTOR='
if (/^ ready to report: (.*)/) {
$rtor{$n} = $1;
next;
}
'
PERL_FIND_SUSP='
if (/^ suspended via GUI: (.*)/) {
$susp{$n} = $1;
next;
}
'
PERL_FIND_FRAC=""
PERL_EXPLAIN_1='(A) = Aborted; (C) = Computation error; (D) = Downloading; (N) = New; (R) = Running;'
PERL_EXPLAIN_2='(S) = Suspended; (U) = Uploading; (W) = Waiting to run; (.) = Ready to report'
PERL_FINAL_CUT='
do {
if ($cols <= 80) { $sep = "\n" } else { $sep = " " }
printf "'"$PERL_EXPLAIN_1"'%s'"$PERL_EXPLAIN_2"'\n", $sep;
} if $ENV{opt_t} > 1;
# Try fitting all names in 10 textcolumns first (with 2 spaces inbetween):
$x=0;
for ($k = 10; $k >= 2; $k--) {
# 3 spaces for states "(.)" or "(R)", 1 for room between columns, 3 for states in last column
if (($maxl + 3+1) * ($k-1) + $maxl + 3 < $cols) {
$x=1; # found a suitable maximum number of textcolumns
last;
}
last if $x == 1;
}
$k = 1 if $ENV{opt_T} > 0;
$rows = int(($n + $k-1) / $k);
$WHAT{"aborted"} = "A";
$WHAT{"compute error"} = "C";
$WHAT{"downloading"} = "D";
$WHAT{"new"} = "N";
$WHAT{"uploading"} = "U";
for ($r = 1; $r <= $rows; $r++) {
for ($j = 1; $j <= $k; $j++) {
$seq = $r + ($j-1)*$rows;
last if $seq > $n;
$wu = $name{$seq};
($w, $u) = $wu =~ /(.*_)([0-9]+)/;
if ($u > 0) {
printf "%s%s%s%s", $w, '"$PERL_INIT_ANSI"', $u, '"$PERL_EXIT_ANSI"';
} else {
printf "%s", $wu;
}
$x = length $name{$seq};
if ($acts{$seq} eq "EXECUTING") {
$s = "R"; '"$PERL_PUT_STATE"';
$x += 3;
} elsif (exists $WHAT{$what{$wu}}) {
printf "(%s)", $WHAT{$what{$wu}};
$x += 3;
} elsif ($susp{$seq} eq "yes") {
$s = "S"; '"$PERL_PUT_STATE"';
$x += 3;
} elsif ($acts{$seq} eq "SUSPENDED") {
printf "(W)";
$x += 3;
} elsif ($rtor{$seq} eq "yes") {
print "(.)";
$x += 3;
}
print " " x (1 + $maxl+3-$x) if $j < $k;
}
printf "\n";
}
'
elif [ $opt_z = 0 ]; then
# opt_r
PERL_TERM_SIZE=""
PERL_INIT_COLS=""
PERL_INIT_MAXL=""
PERL_INIT_WHAT=""
PERL_SET_STATE=""
PERL_FIND_RTOR=""
PERL_FIND_SUSP=""
PERL_FIND_FRAC='
if (/^ fraction done: (.*)/) {
$frac{$n} = $1;
next;
}
'
PERL_FINAL_CUT='
for ($seq = 1; $seq <= $n; $seq++) {
printf "%s%s(R)%s[%.3f%%]\n", $name{$seq}, '"$PERL_INIT_ANSI"', '"$PERL_EXIT_ANSI"', 100*$frac{$seq} if $acts{$seq} eq "EXECUTING"; # active task state
}
'
else
# opt_z
PERL_TERM_SIZE=""
PERL_INIT_COLS=""
PERL_INIT_MAXL=""
PERL_INIT_WHAT=""
PERL_SET_STATE=""
PERL_FIND_RTOR=""
PERL_FIND_SUSP='
if (/^ suspended via GUI: (.*)/) {
$susp{$n} = $1;
$suspended++ if $susp{$n} eq "yes";
next;
}
'
PERL_FIND_FRAC=""
PERL_FINAL_CUT='
for ($seq = 1; $seq <= $n; $seq++) {
printf "%s%s(S)%s\n", $name{$seq}, '"$PERL_INIT_ANSI"', '"$PERL_EXIT_ANSI"' if $susp{$seq} eq "yes";
}
'
fi
boinccmd --get_tasks |
perl -wne '
'"$PERL_ANSICOLOR"'
'"$PERL_TERM_SIZE"'
BEGIN {
$n = 0; # count the number of tasks
'"$PERL_INIT_COLS"'
$suspended = 0;
}
if (/^([1-9][0-9]*)\) --+/) {
$n = $1; # starts at 1
next;
}
if (/^ name: (.*)/) {
$name{$n} = $1;
'"$PERL_INIT_WHAT"'
'"$PERL_INIT_MAXL"'
next;
}
if (/^ active_task_state: (.*)/) {
$acts{$n} = $1;
$running++ if $acts{$n} eq "EXECUTING"; # active task state
next;
}
'"$PERL_FIND_RTOR"'
if (/^ state: (.*)/) {
$load{$1}++;
'"$PERL_SET_STATE"'
next;
}
'"$PERL_FIND_SUSP"'
'"$PERL_FIND_FRAC"'
END {
exit(0) if $n == 0;
printf "$n task%s", "s" x ($n > 1);
$sep = ":";
foreach $state (sort keys %load) {
printf "%s %d %s", $sep, $load{$state}, $state;
$sep = ",";
}
printf "%s %d running", $sep, $running if $ENV{opt_r} > 1;
printf "%s %d suspended", $sep, $suspended if $ENV{opt_z} > 1;
printf "\n";
'"$PERL_FINAL_CUT"'
}
'
}

do_opt_q () {
perl -wne '
'"$PERL_ANSICOLOR"'
use POSIX; # strftime()
BEGIN {
$total = 0;
}
chomp;
@t = split(/\t/);
# column 0: AppName
# column 7: DeviceName
$app{$t[7]}{$t[0]}++;
$dev{$t[7]}++;
$total++;
END {
if ($ENV{opt_d} == 0) {
printf "-";
} else {
print strftime "%T", localtime; # HH:MM:SS
}
foreach $devkey (sort keys %dev) {
printf " %s%s%s", '"$PERL_INIT_ANSI"', $devkey, '"$PERL_EXIT_ANSI"';
if ($ENV{opt_q} == 1) {
printf " %d", $dev{$devkey};
} else {
foreach $appkey (sort keys %{$app{$devkey}}) {
printf " %s:%d", $appkey, $app{$devkey}{$appkey};
}
}
}
printf " %s%s%s %d\n", '"$PERL_INIT_ANSI"', "=", '"$PERL_EXIT_ANSI"', $total;
}
' $opt_f
rm -f $opt_f
}

do_opt_x () {
# List all current file transfers:
boinccmd --get_file_transfers |
perl -wne '
use POSIX; # strftime()
if (/^ name: (.*)/) {
$name = $1;
next;
}
if (/^ direction: (.*)/) {
$load{$name} = $1; # "download" or "upload"
next;
}
if (/^ xfer active: (.*)/) {
delete $load{$name} if $1 eq "yes";
next;
}
END {
foreach $name (sort keys %load) {
printf STDERR "%s\tabout to retry %sing task %s\n", (sprintf strftime "%T", localtime), $load{$name}, $name; # %T = HH:MM:SS
system(sprintf "boinccmd --file_transfer http://%s %s retry", "'"$URLBASE"'", $name);
}
}
'
}

wcgget () {
[ -n "$opt_f" ] && Offset="&Offset=$skipm"
wget $QUIET -O $TMPFILE "$HTTPS$URLBASE/api/members/$MEMBER/results?code=$VERIFY&format=json&ServerState=$ServerState$ValidateState$SortBy$Offset&Limit=$opt_l" && [ -s $TMPFILE ] &&
calculate_or_record $TMPFILE
if [ -n "$opt_f" ]; then
mv $TMPFILE $TMPFILE.$skipm
[ -s $TMPFILE.$skipm ] || exit 1
fi
}

wcgget_cumulative () {
[ $opt_w = 0 ] &&
SortBy="&SortBy=CpuTime" # CpuTime is rather unique for each WU in order to prevent fetching duplicate WU-entries from the database (resulting from overlap in two or more fetches) using other key selections such as SentTime.
# (https://www.worldcommunitygrid.org/help/viewTopic.do?shortName=api says "Default is SentTime.")
wcgget
let avail=`perl -wne 'print if s/\s+"ResultsAvailable": "([^"]+)",\s+/$1/' $TMPFILE.$skipm` # "ResultsAvailable": "395",
let toget=$avail-$opt_l
[ $opt_q -gt 0 ] && rm -f $TMPFILE.$skipm
while [ $toget -gt 0 ]; do
let skipm=$skipm+$opt_l # let wcget() deal with the Offset
wcgget
let toget=$toget-$opt_l # decrease the number of available results
[ $opt_q -gt 0 ] && rm -f $TMPFILE.$skipm
# BUGFIX 01-03-2017: $TMPFILE$skipm gewijzigd naar $TMPFILE.$skipm
done
}

if [ $opt_A = 0 ]; then
PERL_ANSICOLOR='use Term::ANSIColor qw(:constants); # "REVERSE", "RESET"'
PERL_INIT_ANSI='REVERSE'
PERL_EXIT_ANSI='RESET'
else
PERL_ANSICOLOR=''
PERL_INIT_ANSI='""'
PERL_EXIT_ANSI='""'
fi
if [ -n "$opt_i" ]; then
opt_d=0
fi
if [ $opt_q -gt 0 ]; then
opt_f=/tmp/$Prog.$$ # name of the LOGFILE; let do_opt_q() do the cleanup
fi
if [ $opt_c -gt 0 ]; then
do_opt_c
elif [ $opt_m -gt 0 ]; then
do_opt_m
elif [ $opt_t -gt 0 ]; then
do_opt_t
elif [ $opt_x -gt 0 ]; then
do_opt_x
elif [ $opt_d = 0 ]; then
calculate_or_record "$@"
if [ $opt_q -gt 0 ]; then
do_opt_q
fi
else
let skipm=0 # offset
if [ -n "$opt_f" -o $opt_q -gt 0 ]; then
QUIET=-q
wcgget_cumulative
if [ $opt_q -gt 0 ]; then
do_opt_q
fi
else
QUIET=""
wcgget
fi
fi

----------------------------------------
[Edit 1 times, last edit by adriverhoef at Apr 14, 2017 1:52:03 PM]
[Apr 14, 2017 12:33:25 PM]   Link   Report threatening or abusive post: please login first  Go to top 
adriverhoef
Master Cruncher
The Netherlands
Joined: Apr 3, 2009
Post Count: 2346
Status: Offline
Project Badges:
Reply to this Post  Reply with Quote 
Version 1.30.1 of my script 'wcgresults'

What's new in version 1.30.1 of 'wcgresults' since version 1.18?

- Option -t has been added to see the current queue on your device.
- Option -r has been added to see the current running tasks on your device.
- Option -c has been added to compute the optimal size of the jobcache on your device.
- Options -E, -O, -S, -V have been packed into one option -i.
- Option -A has been added to suppress ANSI-code.
- Option -q now also reports a total count (use with option -d).
- Option -x has been added to retry all current file transfers on your device.
- Option -m has been added to show all tasknames on your device (with ”report deadline” and ”fraction done”).
- A processnumber was added to generate unique filenames.
- Option -z has been added to show all suspended tasks on your device.
- Option -T has been added as an extension of option -t to show only one taskname per line.
----------------------------------------
[Edit 3 times, last edit by adriverhoef at Apr 14, 2017 6:18:05 PM]
[Apr 14, 2017 1:48:49 PM]   Link   Report threatening or abusive post: please login first  Go to top 
TonyEllis
Senior Cruncher
Australia
Joined: Jul 9, 2008
Post Count: 286
Status: Offline
Project Badges:
Reply to this Post  Reply with Quote 
Re: Version 1.30.1 of my script 'wcgresults'

WOW - thanks once again adriverhoef for that update.. smile

Changed my script to using -Adq so have been able to drop "| sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" which was used to remove the ANSI codes plus have a count now already calculated at the end of the line simplifying my script. So... the only count required in my script is the number of devices, a simple exercise...

"wcgresults" is used to generate the stats graphed at this url...
http://www.sraellis.tk/frame-17-wcg_wip.html
----------------------------------------
[Apr 14, 2017 3:17:59 PM]   Link   Report threatening or abusive post: please login first  Go to top 
adriverhoef
Master Cruncher
The Netherlands
Joined: Apr 3, 2009
Post Count: 2346
Status: Offline
Project Badges:
Reply to this Post  Reply with Quote 
Re: Version 1.30.1 of my script 'wcgresults'

[Apr 15, 2017 1:34:37 AM]   Link   Report threatening or abusive post: please login first  Go to top 
adriverhoef
Master Cruncher
The Netherlands
Joined: Apr 3, 2009
Post Count: 2346
Status: Offline
Project Badges:
Reply to this Post  Reply with Quote 
Re: Version 1.30.1 of my script 'wcgresults'

Tony, what would you say if I should be adding a device count to the output of 'wcgresults -Adq'? Like so:

12:53:53 device1 125 android_device2 3 device3 30 = 158 @ 3

Would you find that useful? I'm asking since it would break your current script, although you wouldn't be needing to compute your number of devices anymore.
----------------------------------------
[Edit 1 times, last edit by adriverhoef at May 21, 2017 12:02:37 AM]
[May 20, 2017 2:35:29 PM]   Link   Report threatening or abusive post: please login first  Go to top 
Posts: 65   Pages: 7   [ Previous Page | 1 2 3 4 5 6 7 | Next Page ]
[ Jump to Last Post ]
Post new Thread