標籤:礦池 檔案 uid parser href -o 源碼 utf8 int
btcpool礦池-slparser(share log parser)模組解析核心機制總結
- 支援三種功能:
?? 指定Date和UID,將列印指定日期指定使用者的share資訊到stdout
???? UID=0時,將列印指定日期所有使用者的share資訊
?? 指定Date但未指定UID,讀取指定日期sharelog,統計資料並寫入資料庫
???? 按Worker、user、pool三個維度統計:Accept1h、Accept1d、score1h、score1d、Reject1h、Reject1d
???? 資料庫僅保留最近3個月統計資料
?? 如果Date和UID均未指定,將監聽檔案變化,讀取share並統計資料,每15秒寫入資料庫
????* 同時啟動Httpd服務,開放ServerStatus和WorkerStatus
slparser命令使用
slparser -c slparser.cfg -l log_dirslparser -c slparser.cfg -l log_dir2 -d 20160830slparser -c slparser.cfg -l log_dir3 -d 20160830 -u puid#-c指定slparser設定檔#-l指定日誌目錄#-d指定日期#-u指定PUID(即userId),userId為0時dump all, >0時僅輸出指定userId的sharelog
slparser.cfg設定檔
slparserhttpd = {#指定IP和連接埠ip = "0.0.0.0";port = 8081;#每間隔15s寫庫flush_db_interval = 15;};#指定sharelog檔案路徑sharelog = {data_dir = "/data/sharelog";};#資料庫配置,表為table.stats_xxxxpooldb = {host = "";port = 3306;username = "dbusername";password = "dbpassword";dbname = "";};
slparser流程圖
bpool_local_stats_db資料庫結構
bpool_local_stats_db.txt
``c++<br/>DROP TABLE IF EXISTS
stats_pool_day;<br/>CREATE TABLE
stats_pool_day(<br/>
dayint(11) NOT NULL,<br/>
share_acceptbigint(20) NOT NULL DEFAULT ‘0‘,<br/>
share_rejectbigint(20) NOT NULL DEFAULT ‘0‘,<br/>
reject_ratedouble NOT NULL DEFAULT ‘0‘,<br/>
scoredecimal(35,25) NOT NULL DEFAULT ‘0.0000000000000000000000000‘,<br/>
earnbigint(20) NOT NULL DEFAULT ‘0‘,<br/>
luckydouble NOT NULL DEFAULT ‘0‘,<br/>
created_attimestamp NULL DEFAULT NULL,<br/>
updated_attimestamp NULL DEFAULT NULL,<br/>UNIQUE KEY
day(
day`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS stats_pool_hour
;
CREATE TABLE stats_pool_hour
(
hour
int(11) NOT NULL,
share_accept
bigint(20) NOT NULL DEFAULT ‘0‘,
share_reject
bigint(20) NOT NULL DEFAULT ‘0‘,
reject_rate
double NOT NULL DEFAULT ‘0‘,
score
decimal(35,25) NOT NULL DEFAULT ‘0.0000000000000000000000000‘,
earn
bigint(20) NOT NULL DEFAULT ‘0‘,
created_at
timestamp NULL DEFAULT NULL,
updated_at
timestamp NULL DEFAULT NULL,
UNIQUE KEY hour
(hour
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS stats_users_day
;
CREATE TABLE stats_users_day
(
puid
int(11) NOT NULL,
day
int(11) NOT NULL,
share_accept
bigint(20) NOT NULL DEFAULT ‘0‘,
share_reject
bigint(20) NOT NULL DEFAULT ‘0‘,
reject_rate
double NOT NULL DEFAULT ‘0‘,
score
decimal(35,25) NOT NULL DEFAULT ‘0.0000000000000000000000000‘,
earn
bigint(20) NOT NULL DEFAULT ‘0‘,
created_at
timestamp NULL DEFAULT NULL,
updated_at
timestamp NULL DEFAULT NULL,
UNIQUE KEY puid_day
(puid
,day
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS stats_users_hour
;
CREATE TABLE stats_users_hour
(
puid
int(11) NOT NULL,
hour
int(11) NOT NULL,
share_accept
bigint(20) NOT NULL DEFAULT ‘0‘,
share_reject
bigint(20) NOT NULL DEFAULT ‘0‘,
reject_rate
double NOT NULL DEFAULT ‘0‘,
score
decimal(35,25) NOT NULL DEFAULT ‘0.0000000000000000000000000‘,
earn
bigint(20) NOT NULL DEFAULT ‘0‘,
created_at
timestamp NULL DEFAULT NULL,
updated_at
timestamp NULL DEFAULT NULL,
UNIQUE KEY puid_hour
(puid
,hour
),
KEY hour
(hour
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS stats_workers_day
;
CREATE TABLE stats_workers_day
(
puid
int(11) NOT NULL,
worker_id
bigint(20) NOT NULL,
day
int(11) NOT NULL,
share_accept
bigint(20) NOT NULL DEFAULT ‘0‘,
share_reject
bigint(20) NOT NULL DEFAULT ‘0‘,
reject_rate
double NOT NULL DEFAULT ‘0‘,
score
decimal(35,25) NOT NULL DEFAULT ‘0.0000000000000000000000000‘,
earn
bigint(20) NOT NULL DEFAULT ‘0‘,
created_at
timestamp NULL DEFAULT NULL,
updated_at
timestamp NULL DEFAULT NULL,
UNIQUE KEY puid_worker_id_day
(puid
,worker_id
,day
),
KEY day
(day
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS stats_workers_hour
;
CREATE TABLE stats_workers_hour
(
puid
int(11) NOT NULL,
worker_id
bigint(20) NOT NULL,
hour
int(11) NOT NULL,
share_accept
bigint(20) NOT NULL DEFAULT ‘0‘,
share_reject
bigint(20) NOT NULL DEFAULT ‘0‘,
reject_rate
double NOT NULL DEFAULT ‘0‘,
score
decimal(35,25) NOT NULL DEFAULT ‘0.0000000000000000000000000‘,
earn
bigint(20) NOT NULL DEFAULT ‘0‘,
created_at
timestamp NULL DEFAULT NULL,
updated_at
timestamp NULL DEFAULT NULL,
UNIQUE KEY puid_worker_id_hour
(puid
,worker_id
,hour
),
KEY hour
(hour
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
區塊鏈教程btcpool礦池源碼分析slparser