Browse Source

ckdb/php - add ckdb uptime to the pool stats page

master
kanoi 9 years ago
parent
commit
eb751398e1
  1. 12
      pool/page_stats.php
  2. 4
      src/ckdb.c
  3. 4
      src/ckdb.h
  4. 9
      src/ckdb_cmd.c

12
pool/page_stats.php

@ -16,10 +16,20 @@ function dostats($data, $user)
{
$info = $data['info'];
$pe = false;
if (isset($info['p_elapsed']))
{
$dspel = howlongago($info['p_elapsed']);
$pg .= "Pool Uptime: $dspel<br>";
$pg .= "Pool&nbsp;Uptime:&nbsp;$dspel";
$pe = true;
}
if (isset($info['ckdb_elapsed']))
{
if ($pe)
$pg .= '&emsp;';
$dspel = howlongago($info['ckdb_elapsed']);
$pg .= "CKDB&nbsp;Uptime:&nbsp;$dspel";
}
$dsp = '?THs';

4
src/ckdb.c

@ -322,6 +322,8 @@ static sem_t socketer_sem;
// command called for any ckdb alerts
char *ckdb_alert_cmd = NULL;
tv_t ckdb_start;
char *btc_server = "http://127.0.0.1:8330";
char *btc_auth;
int btc_timeout = 5;
@ -7244,6 +7246,8 @@ int main(int argc, char **argv)
char *kill;
tv_t now;
setnow(&ckdb_start);
printf("CKDB Master V%s (C) Kano (see source code)\n", CKDB_VERSION);
feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);

4
src/ckdb.h

@ -52,7 +52,7 @@
#define DB_VLOCK "1"
#define DB_VERSION "1.0.5"
#define CKDB_VERSION DB_VERSION"-2.106"
#define CKDB_VERSION DB_VERSION"-2.107"
#define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -385,6 +385,8 @@ extern uint64_t blis_processed;
// Access using event_limits_free lock
extern char *ckdb_alert_cmd;
extern tv_t ckdb_start;
extern char *btc_server;
extern char *btc_auth;
extern int btc_timeout;

9
src/ckdb_cmd.c

@ -3515,13 +3515,18 @@ static char *cmd_homepage(__maybe_unused PGconn *conn, char *cmd, char *id,
tvs_to_buf(&(poolstats->createdate), reply, siz);
snprintf(tmp, sizeof(tmp), "p_statsdate=%s%c", reply, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp);
snprintf(tmp, sizeof(tmp), "ckdb_elapsed=%d%c",
(int)(now->tv_sec - ckdb_start.tv_sec), FLDSEP);
APPEND_REALLOC(buf, off, len, tmp);
} else {
snprintf(tmp, sizeof(tmp), "users=?%cworkers=?%cp_hashrate=?%c"
"p_hashrate5m=?%cp_hashrate1hr=?%c"
"p_hashrate24hr=?%cp_elapsed=?%c"
"p_statsdate=?%c",
"p_statsdate=?%cckdb_elapsed=?%c",
FLDSEP, FLDSEP, FLDSEP, FLDSEP,
FLDSEP, FLDSEP, FLDSEP, FLDSEP);
FLDSEP, FLDSEP, FLDSEP, FLDSEP,
FLDSEP);
APPEND_REALLOC(buf, off, len, tmp);
}

Loading…
Cancel
Save