sbd-npm 1.4.56 → 1.4.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/status.js +87 -51
- package/util.js +13 -5
- package/README.md +0 -53
package/package.json
CHANGED
package/status.js
CHANGED
@@ -61,59 +61,47 @@ $(function () {
|
|
61
61
|
Util.post(location.pathname, {active_div: localStorage[Status.tab_token], date: $("#ip_date").val()}, function (j) {
|
62
62
|
let html = [];
|
63
63
|
if (!$("#start_time").length) {
|
64
|
-
html.push("<tr><th
|
65
|
-
html.push("<th id='start_time' width='25%'
|
66
|
-
html.push("<tr><th
|
67
|
-
html.push("<th
|
68
|
-
html.push("<tr><th
|
69
|
-
html.push("<th
|
64
|
+
html.push("<tr><th width='25%'>系统时区</th><td>", Status.map_url(j["timezone"]), "</td>");
|
65
|
+
html.push("<th id='start_time' width='25%'>服务器运行时间</th><td colspan='3'>", Util.seconds_to_format(j["start_time"]), "(" + j["up_time"] + ")</td></tr>");
|
66
|
+
html.push("<tr><th>数据库最后同步时间</th><td>", Util.seconds_to_format(j["sync_end_time"]), "</td>");
|
67
|
+
html.push("<th>数据库句柄更新时间</th><td colspan='3'>", Util.seconds_to_format(j["db_time"]), "</td></tr>");
|
68
|
+
html.push("<tr><th>成交量最后同步时间</th><td>", Util.seconds_to_format(j["sync_amount_time"]), "</td>");
|
69
|
+
html.push("<th>位置数据最后同步时间</th><td colspan='3'>", Util.seconds_to_format(j["location_time"]), "</td></tr>");
|
70
|
+
// 数据库
|
71
|
+
html.push("<tr><th>数据库版本</th><td>", j["db_version"], "</td>");
|
72
|
+
let mysql_connections = "<a data-toggle='modal' data-target='.mysql_process_modal'><b>" + j["mysql_process_num"] + "</b></a> / " + j["max_connections"];
|
73
|
+
html.push("<th>数据库当前连接数 / 最大连接数</th><td colspan='3'>", mysql_connections, "</td></tr>");
|
74
|
+
let mysql_remote_ip = "--";
|
75
|
+
if (j["mysql_remote_ip"]) {
|
76
|
+
let mri_html = [];
|
77
|
+
j["mysql_remote_ip"].forEach(function (remote_ip) {
|
78
|
+
mri_html.push(Status.pack_ip_link(remote_ip));
|
79
|
+
});
|
80
|
+
mysql_remote_ip = mri_html.join("、");
|
81
|
+
}
|
82
|
+
html.push("<tr><th>数据库正在连接的IP</th><td colspan='5'>", mysql_remote_ip, "</td></tr>");
|
83
|
+
|
84
|
+
let max_files_tips = "系统允许打开的最大文件描述符数量(即每个进程最多能打开多少个文件,包括网络连接、管道、实际文件等)";
|
85
|
+
html.push("<tr><th>最大文件描述符数量 <i class='glyphicon glyphicon-info-sign' data-toggle='tooltip' data-original-title='", max_files_tips, "'></i></th><td>", (j["max_files"] == "None" ? "--" : j["max_files"]), "</td>");
|
86
|
+
html.push("<th>硬盘可用空间 / 硬盘最大空间</th><td colspan='3'>", j["disk_available_size"], " / ", j["disk_total_size"], "</td></tr>");
|
87
|
+
|
88
|
+
let load_average_tips = "系统负载均衡信息是指在一段时间内系统中正在运行或等待运行的进程数量的平均值。它通常以三个数字表示,分别对应于最近1分钟、5分钟和15分钟的时间段";
|
89
|
+
let load_average = "--";
|
90
|
+
if (j["load_average"]) {
|
91
|
+
let load_average1_cls = j["load_average"][0] < 1 ? "success" : (j["load_average"][0] < 2 ? "info" : "danger");
|
92
|
+
let load_average5_cls = j["load_average"][1] < 1 ? "success" : (j["load_average"][1] < 2 ? "info" : "danger");
|
93
|
+
let load_average15_cls = j["load_average"][2] < 1 ? "success" : (j["load_average"][2] < 2 ? "info" : "danger");
|
94
|
+
load_average = "1分钟平均负载: <span class='label label-" + load_average1_cls + "'>" + Util.to_float(j["load_average"][0], 2) + "</span> 5分钟平均负载: <span class='label label-" + load_average5_cls + "'>" + Util.to_float(j["load_average"][1], 2) + "</span> 15分钟平均负载: <span class='label label-" + load_average15_cls + "'>" + Util.to_float(j["load_average"][2], 2) + "</span>";
|
95
|
+
}
|
96
|
+
html.push("<tr><th>系统负载均衡信息 <i class='glyphicon glyphicon-info-sign' data-toggle='tooltip' data-original-title='", load_average_tips, "'></i></th><td colspan='5'>", load_average, "</td><tr>");
|
97
|
+
|
98
|
+
html.push("<tr><th>系统开放的端口</th><td colspan='5'>", j["open_ports"].join(", "), "</td></tr>");
|
99
|
+
|
70
100
|
$("#status_head").prepend(html.join(""));
|
101
|
+
$("[data-toggle='tooltip']").tooltip();
|
71
102
|
}
|
72
103
|
Status.render_ip_daily(j["ip_daily_data"]);
|
73
|
-
|
74
|
-
$("#db_version").html(j["db_version"]);
|
75
|
-
$("#max_files").html(j["max_files"] == "None" ? "--" : j["max_files"]);
|
76
|
-
$("#open_ports").html(j["open_ports"].join(", "));
|
77
|
-
if (j["load_average"]) {
|
78
|
-
let load_average1_cls = j["load_average"][0] < 1 ? "success" : (j["load_average"][0] < 2 ? "info" : "danger");
|
79
|
-
let load_average5_cls = j["load_average"][1] < 1 ? "success" : (j["load_average"][1] < 2 ? "info" : "danger");
|
80
|
-
let load_average15_cls = j["load_average"][2] < 1 ? "success" : (j["load_average"][2] < 2 ? "info" : "danger");
|
81
|
-
$("#load_average").html("1分钟平均负载: <span class='label label-" + load_average1_cls + "'>" + Util.to_float(j["load_average"][0], 2) + "</span> 5分钟平均负载: <span class='label label-" + load_average5_cls + "'>" + Util.to_float(j["load_average"][1], 2) + "</span> 15分钟平均负载: <span class='label label-" + load_average15_cls + "'>" + Util.to_float(j["load_average"][2], 2) + "</span>");
|
82
|
-
}
|
83
|
-
if (j["mysql_remote_ip"]) {
|
84
|
-
let mysql_remote_ip = [];
|
85
|
-
j["mysql_remote_ip"].forEach(function (remote_ip) {
|
86
|
-
mysql_remote_ip.push(Status.pack_ip_link(remote_ip));
|
87
|
-
});
|
88
|
-
$("#mysql_remote_ip").html(mysql_remote_ip.join("、"));
|
89
|
-
}
|
90
|
-
html = [];
|
91
|
-
let current_connections = 0, db_ip_array = [];
|
92
|
-
j["process_list"].forEach(function (item) {
|
93
|
-
let match_ip_data = Util.regexp_match_ip(item["Host"]);
|
94
|
-
if (match_ip_data && match_ip_data[0] && $.inArray(match_ip_data[0], db_ip_array) === -1) {
|
95
|
-
db_ip_array.push(match_ip_data[0]);
|
96
|
-
}
|
97
|
-
current_connections++;
|
98
|
-
html.push("<tr>");
|
99
|
-
html.push("<td>", item["Id"], "</td>");
|
100
|
-
html.push("<td>", item["User"], "</td>");
|
101
|
-
html.push("<td>", Status.pack_ip_link(item["Host"]), "</td>");
|
102
|
-
html.push("<td>", item["db"], "</td>");
|
103
|
-
html.push("<td>", item["Command"], "</td>");
|
104
|
-
html.push("<td>", item["Time"], "</td>");
|
105
|
-
html.push("<td>", item["State"], "</td>");
|
106
|
-
html.push("<td>", item["Info"], "</td>");
|
107
|
-
html.push("</tr>");
|
108
|
-
});
|
109
|
-
$("#max_connections").html("<span class='label label-info'>" + current_connections + "</span> / " + j["max_connections"]);
|
110
|
-
$("#hard_disk").html(j["disk_available_size"] + " / " + j["disk_total_size"]);
|
111
|
-
Util.render_table_html("process_list", html);
|
112
|
-
if (db_ip_array.length > 0) {
|
113
|
-
let din_obj = $("#db_ip_num");
|
114
|
-
din_obj.html("(" + db_ip_array.length + ")");
|
115
|
-
din_obj.attr("title", db_ip_array.join("\n"));
|
116
|
-
}
|
104
|
+
|
117
105
|
if (j["phone_num"]) {
|
118
106
|
$("#phone_query_head").attr("title", j["phone_num"]);
|
119
107
|
}
|
@@ -168,7 +156,8 @@ $(function () {
|
|
168
156
|
let match_ip_data = Util.regexp_match_ip(ip);
|
169
157
|
if (match_ip_data && match_ip_data[0]) {
|
170
158
|
ip = match_ip_data[0];
|
171
|
-
|
159
|
+
let address = $(this).parent().parent().children('td').eq(1).text().split("-");
|
160
|
+
if (confirm("是否确定要屏蔽IP “ " + ip + "[" + address[0].trim() + "] ” ?")) {
|
172
161
|
Util.show_loading();
|
173
162
|
Util.post(location.pathname, {"active_div": "block_ip", "ip": ip}, function (j) {
|
174
163
|
Util.hide_tips();
|
@@ -186,6 +175,29 @@ $(function () {
|
|
186
175
|
});
|
187
176
|
},
|
188
177
|
|
178
|
+
fetch_mysql_process_data: function() {
|
179
|
+
Util.show_loading();
|
180
|
+
Util.post(location.pathname, {"active_div": "mysql_process"}, function (j) {
|
181
|
+
let html = [], current_connections = 0;
|
182
|
+
j["data"].forEach(function (item) {
|
183
|
+
current_connections++;
|
184
|
+
html.push("<tr>");
|
185
|
+
html.push("<td>", item["Id"], "</td>");
|
186
|
+
html.push("<td>", item["User"], "</td>");
|
187
|
+
html.push("<td>", Status.pack_ip_link(item["Host"]), "</td>");
|
188
|
+
html.push("<td>", item["db"], "</td>");
|
189
|
+
html.push("<td>", item["Command"], "</td>");
|
190
|
+
html.push("<td>", item["Time"], "</td>");
|
191
|
+
html.push("<td>", item["State"], "</td>");
|
192
|
+
html.push("<td>", item["Info"], "</td>");
|
193
|
+
html.push("</tr>");
|
194
|
+
});
|
195
|
+
Util.render_table_html("mysql_process_modal_body_body", html);
|
196
|
+
$("#mysql_process_summary").html("共 <span class='label label-info'>" + current_connections + "</span> 条");
|
197
|
+
Util.hide_tips();
|
198
|
+
});
|
199
|
+
},
|
200
|
+
|
189
201
|
pack_ip_link: function(ip) {
|
190
202
|
let match_ip_data = Util.regexp_match_ip(ip);
|
191
203
|
if (match_ip_data && match_ip_data[0]) {
|
@@ -1385,6 +1397,30 @@ $(function () {
|
|
1385
1397
|
$("#search_referer").val("");
|
1386
1398
|
});
|
1387
1399
|
|
1400
|
+
Util.init_modal_skeleton("mysql_process_modal");
|
1401
|
+
$("#mysql_process_modal_title").html("MySQL正在运行(连接)的线程");
|
1402
|
+
Util.init_table_skeleton({
|
1403
|
+
"element_id": "mysql_process_modal_body",
|
1404
|
+
"caption": '<caption class="text-right" id="mysql_process_summary"></caption>',
|
1405
|
+
"head_cols": [
|
1406
|
+
{"name": "标识", "tooltip": "Id:线程的唯一标识(线程ID)"},
|
1407
|
+
{"name": "用户", "tooltip": "User:执行该线程的用户"},
|
1408
|
+
{"name": "IP:端口号", "tooltip": "Host:发送请求的客户端的IP和端口号"},
|
1409
|
+
{"name": "数据库", "tooltip": "db:当前执行的命令使用的数据库"},
|
1410
|
+
{"name": "正执行的命令", "tooltip": "Command:当前该线程正在执行的命令(Query、Sleep、Connect)"},
|
1411
|
+
{"name": "状态持续时间", "tooltip": "Time:该线程处于当前状态的持续时间(秒)"},
|
1412
|
+
{"name": "线程状态", "tooltip": "State:当前线程的状态描述(Sending data、Locked)"},
|
1413
|
+
{"name": "执行语句", "tooltip": "Info:线程正在执行的SQL语句"},
|
1414
|
+
]
|
1415
|
+
});
|
1416
|
+
let mpm_obj = $('#mysql_process_modal');
|
1417
|
+
mpm_obj.on('shown.bs.modal', function (e) {
|
1418
|
+
Status.fetch_mysql_process_data();
|
1419
|
+
});
|
1420
|
+
mpm_obj.on('hidden.bs.modal', function () {
|
1421
|
+
Util.set_table_loading("mysql_process_modal_body_body");
|
1422
|
+
});
|
1423
|
+
|
1388
1424
|
let request_arguments = Util.request_arguments();
|
1389
1425
|
if (request_arguments["tab"]) {
|
1390
1426
|
localStorage[Status.tab_token] = request_arguments["tab"];
|
package/util.js
CHANGED
@@ -3741,13 +3741,17 @@ const Util = {
|
|
3741
3741
|
let div_id = $(this).attr("id");
|
3742
3742
|
$("#" + tab_token).find("li").each(function () {
|
3743
3743
|
$(this).removeClass("active");
|
3744
|
-
let
|
3745
|
-
if (!
|
3746
|
-
|
3744
|
+
let id_obj = $("#" + $(this).attr("id") + "_div");
|
3745
|
+
if (!id_obj.hasClass("hide")) {
|
3746
|
+
id_obj.addClass("hide");
|
3747
3747
|
}
|
3748
3748
|
});
|
3749
3749
|
$(this).addClass("active");
|
3750
|
-
$("#" + div_id + "_div")
|
3750
|
+
let div_obj = $("#" + div_id + "_div");
|
3751
|
+
div_obj.removeClass("hide");
|
3752
|
+
if (Util.is_mobile() && !div_obj.hasClass("table-responsive")) {
|
3753
|
+
div_obj.addClass("table-responsive");
|
3754
|
+
}
|
3751
3755
|
localStorage[tab_token] = div_id;
|
3752
3756
|
switch_func();
|
3753
3757
|
}
|
@@ -3756,7 +3760,11 @@ const Util = {
|
|
3756
3760
|
});
|
3757
3761
|
$("#" + tab_token + " li").removeClass("active");
|
3758
3762
|
$("#" + localStorage[tab_token]).addClass("active");
|
3759
|
-
$("#" + localStorage[tab_token] + "_div")
|
3763
|
+
let div_obj = $("#" + localStorage[tab_token] + "_div");
|
3764
|
+
div_obj.removeClass("hide");
|
3765
|
+
if (Util.is_mobile() && !div_obj.hasClass("table-responsive")) {
|
3766
|
+
div_obj.addClass("table-responsive");
|
3767
|
+
}
|
3760
3768
|
},
|
3761
3769
|
|
3762
3770
|
/**
|
package/README.md
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
# [SBD-NPM](https://www.npmjs.com/package/sbd-npm)
|
2
|
-
|
3
|
-
## 安装 `NPM(Node Package Manager)`
|
4
|
-
|
5
|
-
安装完 `Node.JS` 之后,`NPM` 也安装上了
|
6
|
-
|
7
|
-
```
|
8
|
-
yum install -y nodejs
|
9
|
-
```
|
10
|
-
|
11
|
-
[https://nodejs.org/en/download/releases/](https://nodejs.org/en/download/releases/)
|
12
|
-
|
13
|
-
## NPM 版本
|
14
|
-
|
15
|
-
```
|
16
|
-
npm -v
|
17
|
-
```
|
18
|
-
|
19
|
-
## 登录 [NPM](https://www.npmjs.com/)
|
20
|
-
|
21
|
-
```
|
22
|
-
npm login
|
23
|
-
```
|
24
|
-
|
25
|
-
## 发布
|
26
|
-
|
27
|
-
```
|
28
|
-
npm publish
|
29
|
-
```
|
30
|
-
|
31
|
-
## 删除撤销版本
|
32
|
-
|
33
|
-
```
|
34
|
-
npm unpublish sbd-npm@1.0.23
|
35
|
-
```
|
36
|
-
|
37
|
-
## 更新版本
|
38
|
-
|
39
|
-
```
|
40
|
-
npm version 1.0.1
|
41
|
-
```
|
42
|
-
|
43
|
-
或直接修改 `package.json` 里的 `version` 字段
|
44
|
-
|
45
|
-
## 配置 Access Token
|
46
|
-
|
47
|
-
项目根目录创建 `.npmrc` 文件,写入以下代码
|
48
|
-
|
49
|
-
```
|
50
|
-
registry=https://registry.npmjs.org/
|
51
|
-
//registry.npmjs.org/:always-auth=true
|
52
|
-
//registry.npmjs.org/:_authToken=npm_r0oogXok12345678902ZX1P1w2ns
|
53
|
-
```
|