From 8ff07e69a3a0e88e7d4a6f57c042b91ebac30504 Mon Sep 17 00:00:00 2001 From: kanoi Date: Fri, 10 Apr 2015 12:28:52 +1000 Subject: [PATCH 1/5] ckpool - add start time and pid to seq information --- src/ckpool.c | 2 ++ src/ckpool.h | 4 ++++ src/stratifier.c | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/ckpool.c b/src/ckpool.c index 1ffe45f4..d3516b1a 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -1397,6 +1397,8 @@ int main(int argc, char **argv) global_ckp = &ckp; memset(&ckp, 0, sizeof(ckp)); + ckp.starttime = time(NULL); + ckp.startpid = getpid(); ckp.loglevel = LOG_NOTICE; ckp.initial_args = ckalloc(sizeof(char *) * (argc + 2)); /* Leave room for extra -H */ for (ckp.args = 0; ckp.args < argc; ckp.args++) diff --git a/src/ckpool.h b/src/ckpool.h index 86b8ff3f..fd192f97 100644 --- a/src/ckpool.h +++ b/src/ckpool.h @@ -99,6 +99,10 @@ struct server_instance { typedef struct server_instance server_instance_t; struct ckpool_instance { + /* Start time */ + time_t starttime; + /* Start pid */ + pid_t startpid; /* The initial command line arguments */ char **initial_args; /* Number of arguments */ diff --git a/src/stratifier.c b/src/stratifier.c index 63c46175..9d51a4f8 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -640,6 +640,8 @@ static char *ckdb_msg(ckpool_t *ckp, sdata_t *sdata, json_t *val, const int idty /* Set the atomically incrementing sequence number */ mutex_lock(&sdata->ckdb_msg_lock); + json_set_int(val, "seqstart", ckp->starttime); + json_set_int(val, "seqpid", ckp->startpid); json_set_int(val, "seqall", sdata->ckdb_seq++); json_set_int(val, ckdb_seq_names[idtype], sdata->ckdb_seq_ids[idtype]++); mutex_unlock(&sdata->ckdb_msg_lock); From c78559cda5889e62155d3d920e408c187106f2e6 Mon Sep 17 00:00:00 2001 From: kanoi Date: Fri, 10 Apr 2015 19:47:28 +1000 Subject: [PATCH 2/5] php - add a UTC timestamp to the footer --- pool/page.php | 13 +++++++++---- pool/prime.php | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pool/page.php b/pool/page.php index 7bb2607c..c83be7b9 100644 --- a/pool/page.php +++ b/pool/page.php @@ -245,7 +245,7 @@ if (!$iCrap) } $head .= " h1 {margin-top: 20px; float:middle; font-size: 20px;} -.foot, .push {height: 50px; font-size: 10pt;} +.foot, .push {height: 50px;} .title {background-color: #909090;} .even {background-color: #cccccc;} .odd {background-color: #a8a8a8;} @@ -263,6 +263,9 @@ h1 {margin-top: 20px; float:middle; font-size: 20px;} .fthi {color:red; font-size:7px; } .ftlo {color:green; font-size:7px; } .ft {color:blue; font-size:7px; } +.ftl {text-align: left; color:blue; font-size:7px; display:inline-block; width:33%; } +.ftm {text-align: middle; font-size:10pt; display:inline-block; width:33%; } +.ftr {text-align: rigth; color:blue; font-size:7px; display:inline-block; width:33%; } $css_marker \n"; @@ -613,12 +616,14 @@ function pgbody($info, $page, $menu, $dotop, $user, $douser) # function pgfoot($info) { + global $stt; $foot = ''; $foot .= ''; $foot .= ''; $foot .= ''; $foot .= '
'; - $foot .= '

'; + $std = gmdate('jS M H:i:s \U\T\C', intval($stt)); + $foot .= "

$std "; if (is_array($info) && isset($info['sync'])) { $sync = $info['sync']; @@ -627,13 +632,13 @@ function pgfoot($info) else $syc = 'lo'; $syncd = number_format($sync); - $foot .= "sync: $syncd "; + $foot .= "sync: $syncd "; } $foot .= 'Copyright © Kano 2014'; $now = date('Y'); if ($now != '2014') $foot .= "-$now"; - $foot .= ' Z/s
'; + $foot .= ' Z/s 
'; $foot .= "\n"; return $foot; diff --git a/pool/prime.php b/pool/prime.php index 44e06463..ea3d8ea2 100644 --- a/pool/prime.php +++ b/pool/prime.php @@ -1,7 +1,7 @@ Date: Fri, 10 Apr 2015 19:58:15 +1000 Subject: [PATCH 3/5] php - stop footer from wrapping on smaller displays --- pool/page.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pool/page.php b/pool/page.php index c83be7b9..97515559 100644 --- a/pool/page.php +++ b/pool/page.php @@ -263,9 +263,9 @@ h1 {margin-top: 20px; float:middle; font-size: 20px;} .fthi {color:red; font-size:7px; } .ftlo {color:green; font-size:7px; } .ft {color:blue; font-size:7px; } -.ftl {text-align: left; color:blue; font-size:7px; display:inline-block; width:33%; } -.ftm {text-align: middle; font-size:10pt; display:inline-block; width:33%; } -.ftr {text-align: rigth; color:blue; font-size:7px; display:inline-block; width:33%; } +.ftl {text-align: left; color:blue; font-size:7px; display:inline-block; width:20%; white-space: nowrap; } +.ftm {text-align: middle; font-size:10pt; display:inline-block; width:60%; white-space: nowrap; } +.ftr {text-align: rigth; color:blue; font-size:7px; display:inline-block; width:20%; } $css_marker \n"; From dbea35751d45ae88c76b6fb469a740e47b8e2fa1 Mon Sep 17 00:00:00 2001 From: kanoi Date: Sat, 11 Apr 2015 14:49:06 +1000 Subject: [PATCH 4/5] php - set onload script before iamge load and add a local timestamp --- pool/page.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pool/page.php b/pool/page.php index 97515559..1f8d2a57 100644 --- a/pool/page.php +++ b/pool/page.php @@ -205,8 +205,8 @@ function ni(e,o){if(e){if(o==0){e.defd=e.style.display;e.style.display='none'}el function domin(o){var e=document.getElementById('minicb');if(e){if(o==0){e.checked=true}else{e.checked=false}};for(var i=0;i<10;i++){e=document.getElementById('mini'+i);ni(e,o)}} function mini(){var hm=gcn('mini');if(hm==''){domin(1)}else{domin(0)}} function md(e){var c='';if(e.checked){c='y'}scnv('mini',c);mini()} +function tim(){var e=document.getElementById('ftr');if(e){var now=new Date(),t=document.createTextNode(now.toLocaleString());e.appendChild(t)}} function jst(){var e=document.getElementById('jst');if(e){e.style.visibility='hidden'}} -window.onpaint=jst(); \n"; $head .= "\n"; @@ -592,7 +592,7 @@ function pgmenu($menus) # function pgbody($info, $page, $menu, $dotop, $user, $douser) { - $body = ' Date: Sun, 12 Apr 2015 14:43:06 +1000 Subject: [PATCH 5/5] ckpool - ensure seqall won't be negative and use it as the ckdb msg id --- src/stratifier.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 9d51a4f8..7ea1497f 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -341,9 +341,9 @@ struct stratifier_data { /* Protects sequence numbers */ mutex_t ckdb_msg_lock; /* Incrementing global sequence number */ - int ckdb_seq; + uint64_t ckdb_seq; /* Incrementing ckdb_ids[] sequence numbers */ - int ckdb_seq_ids[ID_COUNT]; + uint64_t ckdb_seq_ids[ID_COUNT]; bool ckdb_offline; @@ -637,19 +637,21 @@ static char *ckdb_msg(ckpool_t *ckp, sdata_t *sdata, json_t *val, const int idty char *json_msg; char logname[512]; char *ret = NULL; + uint64_t seqall; - /* Set the atomically incrementing sequence number */ - mutex_lock(&sdata->ckdb_msg_lock); json_set_int(val, "seqstart", ckp->starttime); json_set_int(val, "seqpid", ckp->startpid); - json_set_int(val, "seqall", sdata->ckdb_seq++); + /* Set the atomically incrementing sequence numbers */ + mutex_lock(&sdata->ckdb_msg_lock); + seqall = sdata->ckdb_seq++; + json_set_int(val, "seqall", seqall); json_set_int(val, ckdb_seq_names[idtype], sdata->ckdb_seq_ids[idtype]++); mutex_unlock(&sdata->ckdb_msg_lock); json_msg = json_dumps(val, JSON_COMPACT); if (unlikely(!json_msg)) goto out; - ASPRINTF(&ret, "%s.id.json=%s", ckdb_ids[idtype], json_msg); + ASPRINTF(&ret, "%s.%"PRIu64".json=%s", ckdb_ids[idtype], seqall, json_msg); free(json_msg); out: json_decref(val); @@ -2410,7 +2412,7 @@ static int send_recv_auth(stratum_instance_t *client) LOGINFO("Got ckdb response: %s", buf); response = alloca(responselen); memset(response, 0, responselen); - if (unlikely(sscanf(buf, "id.%*d.%c%n", response, &offset) < 1)) { + if (unlikely(sscanf(buf, "%*d.%*d.%c%n", response, &offset) < 1)) { LOGWARNING("Got1 unparseable ckdb auth response: %s", buf); goto out_fail; } @@ -3821,7 +3823,7 @@ static void ckdbq_process(ckpool_t *ckp, char *msg) int offset = 0; memset(response, 0, responselen); - if (sscanf(buf, "id.%*d.%c%n", response, &offset) > 0) { + if (sscanf(buf, "%*d.%*d.%c%n", response, &offset) > 0) { strcpy(response+1, buf+offset); if (safecmp(response, "ok")) { char *cmd;