#!/bin/bash ### ### IDMEASUREMENTS - Calculate timing measurements and graphs for documents not shepherded by ADs ### ### Version 1.0.0 ### ### Written in 2008 by Jari Arkko ### Donated to the public domain. ### ### Changelog: ### ### 1.0.0 Initial version from admeasurements ### ### Usage: ### ### admeasurements [ --doc pattern ] [ --copy ] [ --quiet ] [ --timestamp ] ### ### ### Process arguments ### THISPROG=$0 DEBUG=0 DOC=all COPY=0 QUIET=0 TIMESTAMP=0 PREFFAMILY=IPv6 while [ $# -gt 0 ] do case $1 in --doc) shift; DOC="$1"; shift;; --timestamp) shift; TIMESTAMP=1;; --copy) shift; COPY=1;; --rerun) shift; RERUN=1;; --quiet) shift; QUIET=1;; --debug) shift; DEBUG=1;; --prefer-family=IPv4) shift; PREFFAMILY=IPv4;; --prefer-family=IPv6) shift; PREFFAMILY=IPv6;; *) echo 'idmeasurements: Unrecognized argument ('$1') -- exit'; exit 1;; esac done ### ### FUNCTION: Common AWK functions ### COMMONFUNCS=' function draftnameisofficial(d) { return(d ~ /^draft-ietf-/ || d ~ /^draft-iab-/ || d ~ /^draft-iesg-/ || d ~ /^draft-irtf-/); } function stringtonumericdate(date) { split(date,datea,"-"); year = datea[1] + 0; month = datea[2] + 0; day = datea[3] + 0; return(year + ((month-1+(day-1)/30) / 12.0)); } function numericdatetostring(num) { year = sprintf("%d",num); num -= year; num *= 12; month = sprintf("%d",1 + num); num -= (month - 1); num *= 30; day = sprintf("%d",num); return(year "-" month "-" day); } function dateminus(d1,days) { x = stringtonumericdate(d1); #printf("to numeric = %f\n", x); x -= days / (12*30); #printf("with substraction = %f\n", x); return(numericdatetostring(x)); } function dateyear(d) { split(d,d1a,"-"); return(d1a[1]); } function datemonth(d) { split(d,d1a,"-"); return(d1a[2]); } function dateyearmonth(d) { return(dateyear(d) "-" datemonth(d)); } function addmonth(d) { y = dateyear(d); m = datemonth(d); if (m == 12) return(sprintf("%04d-%02d",y+1,1)); else return(sprintf("%04d-%02d",y,m+1)); } function datelt(d1,d2) { split(d1,d1a,"-"); split(d2,d2a,"-"); y1 = d1a[1] + 0; m1 = d1a[2] + 0; d1 = d1a[3] + 0; y2 = d2a[1] + 0; m2 = d2a[2] + 0; d2 = d2a[3] + 0; if (y1 < y2) return(1); if (y1 > y2) return(0); if (m1 < m2) return(1); if (m1 > m2) return(0); if (d1 < d2) return(1); if (d1 > d2) return(0); return(0); } function datele(d1,d2) { split(d1,d1a,"-"); split(d2,d2a,"-"); y1 = d1a[1] + 0; m1 = d1a[2] + 0; d1 = d1a[3] + 0; y2 = d2a[1] + 0; m2 = d2a[2] + 0; d2 = d2a[3] + 0; if (y1 < y2) return(1); if (y1 > y2) return(0); if (m1 < m2) return(1); if (m1 > m2) return(0); if (d1 < d2) return(1); if (d1 > d2) return(0); return(1); } function daydifference(d1,d2) { split(d1,d1a,"-"); split(d2,d2a,"-"); y1 = d1a[1] + 0; m1 = d1a[2] + 0; d1 = d1a[3] + 0; u1 = (y1 - 1970) * 365 + m1 * 30 + d1; y2 = d2a[1] + 0; m2 = d2a[2] + 0; d2 = d2a[3] + 0; u2 = (y2 - 1970) * 365 + m2 * 30 + d2; return(u1 - u2); } function html_file_css_head(title,csshtmlfile,slogan) { csshtmlfileseensection[csshtmlfile] = 0; if (substr(csshtmlfile,1,5) != "/dev/") close(csshtmlfile); printf("\n", 34, 34, 34, 34) > csshtmlfile; printf("\n", 34, 34, 34, 34, 34, 34) >> csshtmlfile; printf("
\n") >> csshtmlfile; printf("\n", 34, 34, 34, 34) >> csshtmlfile; printf("\n", 34, 34, 34, 34, 34, 34) >> csshtmlfile; printf("
\n",
34, name, 34, 34, 34, 34, 34) >> htmlf;
}
function addarg(c,a) {
return(sprintf("%s %c%s%c",c,34,a,34));
}
function generate_timeline(draftname,jpgfile,
initialindividualsubmission,diff1,indname,
initialsubmission,diff2,
firstiesgstate,totaldays,
firstapprov,diff3,
firstpub) {
cmd = "drafttimeline";
cmd = addarg(cmd,"--versions");
cmd = addarg(cmd,"--prefer-family=" preffamily);
cmd = addarg(cmd,draftname);
cmd = addarg(cmd,jpgfile);
cmd = addarg(cmd,initialindividualsubmission);
cmd = addarg(cmd,diff1);
cmd = addarg(cmd,indname);
cmd = addarg(cmd,initialsubmission);
cmd = addarg(cmd,diff2);
cmd = addarg(cmd,firstiesgstate);
cmd = addarg(cmd,totaldays);
cmd = addarg(cmd,firstapprov);
cmd = addarg(cmd,diff3);
cmd = addarg(cmd,firstpub);
system(cmd);
}
BEGIN {
if (debug) printf("idmeasurements: debug: begin\n") >> "/dev/stderr";
disclaimer = ""; disclaimer = disclaimer sprintf("Statistics run taken %d.%d.%d by the ", curday, curmonth, curyear); disclaimer = disclaimer sprintf("idmeasurements.", 34, 34); disclaimer = disclaimer "
\n"; } /^draft/ { name = $1; # # Create html file # htmlfile = name "-timing.html"; if (debug) printf("idmeasurements: debug: processing %s to %s\n", name, htmlfile) >> "/dev/stderr"; startdoctable(name,htmlfile); # # Figure out when the initial submissions etc were # agefile = name ".age"; system("docage --expires --prefer-family=" preffamily " " name " > " agefile); agereplacesfile = name ".replaces-age"; system("docage --replaces --prefer-family=" preffamily " " name " > " agereplacesfile); initialsubmission = ""; getline initialsubmission < agefile; getline expiration < agefile; if (debug) printf("idmeasurements: age entry %s: %s, %s\n", name, initialsubmission, expiration) >> "/dev/stderr"; close(agefile); if (initialsubmission == "") { printf("# docage problem with %s -- skipping\n", name); next; } else { initialindividualsubmission = ""; initialindividualsubmissionline = ""; getline initialindividualsubmissionline < agereplacesfile; close(agereplacesfile); split(initialindividualsubmissionline,comps,":"); initialindividualsubmission = comps[1]; indname = comps[2]; if (expiration == "none") { lastdayforthisdraft = now; } else { lastdayforthisdraft = expiration; } if (initialsubmission != "none") { diff2 = daydifference(lastdayforthisdraft,initialsubmission) } else { diff2 = 0; } if (initialindividualsubmission != "" && initialsubmission != "none") { diff1 = daydifference(initialsubmission,initialindividualsubmission); if (diff1 < 0) { printf("warning:submission earlier than individual document submission in %s\n", name); diff1 = 30; initialindividualsubmission = dateminus(initialsubmission,30); } } else if (initialindividualsubmission != "none") { diff1 = daydifference(lastdayforthisdraft,initialindividualsubmission) } else { diff1 = 0; } # # Print draft-timing-nonad.txt entry # if (debug) printf("idmeasurements: debug: timing entry\n") >> "/dev/stderr"; printf("timing:%s:%s:%s:%d:%d:%d:%d:%d:%d:%s:%d:%s:%s:%d:%s:%d\n", name, "none", "none", 0, 0, 0, 0, 0, 0, initialindividualsubmission, diff1, indname, initialsubmission, diff2, "none", 0); # # Generate timeline graph # if (debug) printf("idmeasurements: debug: timeline\n") >> "/dev/stderr"; generate_timeline(name,name "-timeline.jpg", initialindividualsubmission,diff1,indname, initialsubmission,diff2, "none",0, "none",0, expiration == "none" ? "none" : "(expired)"); # # Print rest of the html # if (debug) printf("idmeasurements: debug: html %s\n", htmlfile) >> "/dev/stderr"; html_file_css_section("IESG Processing Time Statistics",htmlfile); printf("The document has not been received by the AD/IESG yet, no timing calculated.\n") >> htmlfile; html_file_css_section("Overall Processing Time Statistics",htmlfile); printf("
Document was in individual and WG process for %d days, ", diff1 + diff2) >> htmlfile; printf("and in IESG/RFC Editor process for %d days, %d days in total. ", 0, 0) >> htmlfile; torfc = diff1 + diff2; printf("This is %d years and %d months.
\n", torfc / 365, (torfc % 365) / 30) >> htmlfile; if (expiration != "none") { printf("Draft expired on %s.
\n", expiration) >> htmlfile; } html_file_css_section("Data Source and Freshness",htmlfile); printf("%s
\n", disclaimer) >> htmlfile; # # Done! Finish the html file # if (debug) printf("idmeasurements: debug: end of html %s\n", htmlfile) >> "/dev/stderr"; html_file_css_end(htmlfile); if (debug) printf("idmeasurements: debug: done with %s\n", htmlfile) >> "/dev/stderr"; next; } } END { if (debug) printf("idmeasurements: debug: end\n") >> "/dev/stderr"; } ' < nonad_id_list.txt > draft-timing-nonad.txt ### ### Copy ### if [ $COPY = 1 ] then if [ $QUIET = 0 ] then echo 'Copying...' fi SCPOPTS=-q scp $SCPOPTS \ /home/jar/LME/IETF/Tools/idmeasurements.html \ $THISPROG \ jarkko@users.piuha.net:public_html/tools/ scp $SCPOPTS \ draft-timing-nonad.txt \ jarkko@users.piuha.net:public_html/tools/admeasurements for alpha in a b c d e f g h i j k l m o p q r s t u v w x y z do scp $SCPOPTS \ draft-${alpha}*.jpg \ jarkko@users.piuha.net:public_html/tools/lifecycle scp $SCPOPTS \ draft-${alpha}*.html \ jarkko@users.piuha.net:public_html/tools/lifecycle done fi ### ### Cleanup ### exit 0