sbd-npm 1.4.80 → 1.4.82
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 +147 -93
- package/util.js +1 -1
package/package.json
CHANGED
package/status.js
CHANGED
@@ -225,6 +225,7 @@ $(function () {
|
|
225
225
|
{"name": "虚拟内存", "table_sort": 1},
|
226
226
|
{"name": "启动命令"},
|
227
227
|
{"name": "创建时间", "table_sort": 1},
|
228
|
+
{"name": "操作"}
|
228
229
|
]
|
229
230
|
});
|
230
231
|
$("#is_py_process").click(function () {
|
@@ -239,8 +240,19 @@ $(function () {
|
|
239
240
|
let is_py_process = $("#is_py_process").prop("checked") ? "1" : "0";
|
240
241
|
Util.post(location.pathname, {active_div: localStorage[Status.tab_token], is_py_process: is_py_process}, function (j) {
|
241
242
|
let html = [], process_num = 0;
|
243
|
+
let screen_pid = j["screen_pid"] ? j["screen_pid"] : 0;
|
244
|
+
let screen_pid_date = j["screen_pid_date"] ? j["screen_pid_date"] : 0;
|
242
245
|
j["data"].forEach(function (item) {
|
243
246
|
process_num++;
|
247
|
+
let is_screen = 0;
|
248
|
+
if (screen_pid === item["pid"]) {
|
249
|
+
is_screen = 1;
|
250
|
+
} else {
|
251
|
+
let parameter = Status.match_cmdline_parameter(item["cmdline"]);
|
252
|
+
if (parameter.length > 0) {
|
253
|
+
is_screen = 1;
|
254
|
+
}
|
255
|
+
}
|
244
256
|
html.push("<tr>");
|
245
257
|
html.push("<td>", item["pid"], "</td>");
|
246
258
|
html.push("<td>", item["name"], "</td>");
|
@@ -250,10 +262,15 @@ $(function () {
|
|
250
262
|
html.push("<td data-val='", item["vms"], "'>", Util.trans_byte_size(item["vms"]), "</td>");
|
251
263
|
html.push("<td title='", item["cmdline"], "'>", Util.substring(item["cmdline"], 60), "</td>");
|
252
264
|
html.push("<td>", Util.seconds_to_format(item["create_time"]), "</td>");
|
265
|
+
html.push(Status.pack_screen_html(is_screen, item["pid"], screen_pid, screen_pid_date, item["cmdline"]));
|
253
266
|
html.push("</tr>");
|
254
267
|
});
|
255
268
|
Util.render_table_html("process_div_body", html);
|
256
269
|
$("#process_num").html(process_num);
|
270
|
+
// 终止进程
|
271
|
+
Status.handle_process_kill("process_div_body", 1);
|
272
|
+
// 进程会话
|
273
|
+
Status.handle_process_screen("process_div_body", 1);
|
257
274
|
Util.hide_tips();
|
258
275
|
});
|
259
276
|
},
|
@@ -757,6 +774,7 @@ $(function () {
|
|
757
774
|
}
|
758
775
|
let html = [], process_num = 0;
|
759
776
|
let screen_pid = j["screen_pid"] ? j["screen_pid"] : 0;
|
777
|
+
let screen_pid_date = j["screen_pid_date"] ? j["screen_pid_date"] : 0;
|
760
778
|
j["process"].forEach(function (item) {
|
761
779
|
process_num++;
|
762
780
|
let is_xmr = 0, is_screen = 0;
|
@@ -767,8 +785,8 @@ $(function () {
|
|
767
785
|
if (screen_pid === item["pid"]) {
|
768
786
|
is_screen = 1;
|
769
787
|
} else {
|
770
|
-
let
|
771
|
-
if (
|
788
|
+
let parameter = Status.match_cmdline_parameter(item["cmdline"]);
|
789
|
+
if (parameter.length > 0) {
|
772
790
|
is_screen = 1;
|
773
791
|
}
|
774
792
|
}
|
@@ -787,120 +805,156 @@ $(function () {
|
|
787
805
|
html.push("<td title='", item["cmdline"], "'>", cmdline, "</td>");
|
788
806
|
}
|
789
807
|
html.push("<td>", Util.seconds_to_format(item["create_time"]), "</td>");
|
790
|
-
|
791
|
-
let screen_html = "";
|
792
|
-
if (screen_pid === item["pid"]) {
|
793
|
-
if (j["screen_pid_date"] && j["screen_pid_date"] > 0) {
|
794
|
-
screen_html = "<a data-screen='1' class='process_screen' href='#'><span title='会话数据已成功获取(" + Util.seconds_to_format(j["screen_pid_date"]) + ")' class='label label-success'>会话</span></a>";
|
795
|
-
} else {
|
796
|
-
screen_html = "<a class='process_screen' href='#'><span title='会话数据获取中...' class='label label-info'>会话</span></a>";
|
797
|
-
}
|
798
|
-
} else {
|
799
|
-
screen_html = "<a class='process_screen' href='#'>会话</a>";
|
800
|
-
}
|
801
|
-
html.push("<td><a class='process_kill' href='#'>终止</a> ", screen_html, "</td>");
|
802
|
-
} else {
|
803
|
-
html.push("<td><a class='process_kill' href='#'>终止</a></td>");
|
804
|
-
}
|
808
|
+
html.push(Status.pack_screen_html(is_screen, item["pid"], screen_pid, screen_pid_date, item["cmdline"]));
|
805
809
|
html.push("</tr>");
|
806
810
|
});
|
807
811
|
Util.render_table_html("machine_process_div_body", html);
|
808
812
|
$("#machine_process_tip").html('共 <span class="label label-info">' + process_num + '</span> 进程,最后更新时间:' + Util.seconds_to_format(j["date"]) + ',Revision:' + j["revision"] + ',MachineId:' + j["machine_id"]);
|
809
813
|
$("#machines option[value='" + j["machine_id"] + "']").text(j["ip"] + "(" + process_num + ")");
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
814
|
+
// 终止进程
|
815
|
+
Status.handle_process_kill("machine_process_div_body", 2);
|
816
|
+
// 进程会话
|
817
|
+
Status.handle_process_screen("machine_process_div_body", 2);
|
818
|
+
} else if (is_init === 1) {
|
819
|
+
$('#machines').html('<option value="">暂无Machine</option>');
|
820
|
+
}
|
821
|
+
Util.hide_tips();
|
822
|
+
});
|
823
|
+
},
|
824
|
+
|
825
|
+
handle_process_kill: function(element_id, action_type) {
|
826
|
+
$("#" + element_id + " .process_kill").each(function() {
|
827
|
+
$(this).click(function() {
|
828
|
+
let pid = $(this).parent().parent().children('td').eq(0).text();
|
829
|
+
let cmdline_index = action_type === 2 ? 2 : 6;
|
830
|
+
let cmdline_obj = $(this).parent().parent().children('td').eq(cmdline_index);
|
831
|
+
let cmdline = cmdline_obj.attr('title') ? cmdline_obj.attr('title') : cmdline_obj.text();
|
832
|
+
let action = Status.parse_machine_action(cmdline);
|
833
|
+
let pid_action = "[" + pid + "(" + action + ")]";
|
834
|
+
if (confirm("是否确定要终止进程 " + pid_action + " ?")) {
|
835
|
+
Util.show_loading();
|
836
|
+
let instruction = "kill_pid_" + pid;
|
837
|
+
let machine_id = action_type === 2 ? $("#machines").val() : "";
|
838
|
+
Util.post(location.pathname, {active_div: "machine_instruction_add", "machine_id": machine_id, "instruction": instruction, "action_type": action_type}, function (j) {
|
839
|
+
Util.hide_tips();
|
840
|
+
if (j["code"] === 1) {
|
841
|
+
Util.show_tips("进程 " + pid_action + " 已加到终止队列中", 4567, "alert-success");
|
842
|
+
} else if (j["code"] === 2) {
|
843
|
+
Util.show_tips("Machine 不存在!", 4567, "alert-danger");
|
844
|
+
} else if (j["code"] === 3) {
|
845
|
+
Util.show_tips("进程 " + pid_action + " 异常!", 4567, "alert-danger");
|
846
|
+
} else {
|
847
|
+
Util.show_tips("进程值不能为空!", 4567, "alert-danger");
|
831
848
|
}
|
832
849
|
});
|
833
|
-
}
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
850
|
+
}
|
851
|
+
});
|
852
|
+
});
|
853
|
+
},
|
854
|
+
|
855
|
+
handle_process_screen: function(element_id, action_type) {
|
856
|
+
$("#" + element_id + " .process_screen").each(function() {
|
857
|
+
$(this).click(function() {
|
858
|
+
Util.show_loading();
|
859
|
+
let pid = $(this).parent().parent().children('td').eq(0).text();
|
860
|
+
let cmdline_index = action_type === 2 ? 2 : 6;
|
861
|
+
let cmdline_obj = $(this).parent().parent().children('td').eq(cmdline_index);
|
862
|
+
let cmdline = cmdline_obj.attr('title') ? cmdline_obj.attr('title') : cmdline_obj.text();
|
863
|
+
let action = Status.parse_machine_action(cmdline);
|
864
|
+
let is_fetch_screen = $(this).attr("data-screen");
|
865
|
+
if (is_fetch_screen && is_fetch_screen == "1") {
|
866
|
+
let instruction = "screen_" + pid + "_" + action;
|
867
|
+
let machine_id = action_type === 2 ? $("#machines").val() : "";
|
868
|
+
Util.post(location.pathname, {active_div: "machine_screen", "machine_id": machine_id, "pid": pid, "instruction": instruction}, function (j) {
|
869
|
+
Util.hide_tips();
|
870
|
+
if (j["data"]) {
|
871
|
+
Util.showAlert(j["data"]);
|
851
872
|
} else {
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
}
|
873
|
-
});
|
874
|
-
this_obj.html("<span title='会话数据获取中...' class='label label-info'>会话</span>");
|
875
|
-
Util.show_tips("进程 [" + pid + "(" + action + ")] 已加到会话队列中", 4567, "alert-success");
|
876
|
-
} else if (j["code"] === 2) {
|
877
|
-
Util.show_tips("Machine 不存在!", 4567, "alert-danger");
|
878
|
-
} else if (j["code"] === 3) {
|
879
|
-
Util.show_tips("进程 [" + pid + "(" + action + ")] 异常!", 4567, "alert-danger");
|
873
|
+
Util.show_tips("数据异常!", 4567, "alert-danger");
|
874
|
+
}
|
875
|
+
});
|
876
|
+
} else {
|
877
|
+
let this_obj = $(this);
|
878
|
+
if (this_obj.find("span.label-info").length > 0) {
|
879
|
+
Util.hide_tips();
|
880
|
+
Util.show_tips("进程 [" + pid + "(" + action + ")] 已在会话队列处理中", 4567, "alert-danger");
|
881
|
+
} else {
|
882
|
+
let instruction = "screen_" + pid + "_" + action;
|
883
|
+
let machine_id = action_type === 2 ? $("#machines").val() : "";
|
884
|
+
Util.post(location.pathname, {active_div: "machine_instruction_add", "machine_id": machine_id, "instruction": instruction, "action_type": action_type}, function (j) {
|
885
|
+
Util.hide_tips();
|
886
|
+
if (j["code"] === 1) {
|
887
|
+
$("#" + element_id + " a").each(function() {
|
888
|
+
let span_obj = $(this).find('span.label.label-info');
|
889
|
+
if (span_obj.length) {
|
890
|
+
var span_text = span_obj.text();
|
891
|
+
span_obj.remove();
|
892
|
+
$(this).append(span_text);
|
880
893
|
} else {
|
881
|
-
|
894
|
+
let is_fetch_screen = $(this).attr("data-screen");
|
895
|
+
if (is_fetch_screen && is_fetch_screen == "1") {
|
896
|
+
$(this).text('会话').removeAttr('data-screen');
|
897
|
+
}
|
882
898
|
}
|
883
899
|
});
|
900
|
+
this_obj.html("<span title='会话数据获取中...' class='label label-info'>会话</span>");
|
901
|
+
Util.show_tips("进程 [" + pid + "(" + action + ")] 已加到会话队列中", 4567, "alert-success");
|
902
|
+
} else if (j["code"] === 2) {
|
903
|
+
Util.show_tips("Machine 不存在!", 4567, "alert-danger");
|
904
|
+
} else if (j["code"] === 3) {
|
905
|
+
Util.show_tips("进程 [" + pid + "(" + action + ")] 异常!", 4567, "alert-danger");
|
906
|
+
} else {
|
907
|
+
Util.show_tips("进程值不能为空!", 4567, "alert-danger");
|
884
908
|
}
|
885
|
-
}
|
886
|
-
}
|
887
|
-
}
|
888
|
-
}
|
889
|
-
$('#machines').html('<option value="">暂无Machine</option>');
|
890
|
-
}
|
891
|
-
Util.hide_tips();
|
909
|
+
});
|
910
|
+
}
|
911
|
+
}
|
912
|
+
});
|
892
913
|
});
|
893
914
|
},
|
894
915
|
|
916
|
+
pack_screen_html: function(is_screen, pid, screen_pid, screen_pid_date, cmdline) {
|
917
|
+
if (is_screen === 1) {
|
918
|
+
let screen_html = "";
|
919
|
+
if (screen_pid === pid) {
|
920
|
+
if (screen_pid_date > 0) {
|
921
|
+
screen_html = "<a data-screen='1' class='process_screen' href='#'><span title='会话数据已成功获取(" + Util.seconds_to_format(screen_pid_date) + ")' class='label label-success'>会话</span></a>";
|
922
|
+
} else {
|
923
|
+
screen_html = "<a class='process_screen' href='#'><span title='会话数据获取中...' class='label label-info'>会话</span></a>";
|
924
|
+
}
|
925
|
+
} else {
|
926
|
+
screen_html = "<a class='process_screen' href='#'>会话</a>";
|
927
|
+
}
|
928
|
+
return "<td><a class='process_kill' href='#'>终止</a> " + screen_html + "</td>";
|
929
|
+
} else {
|
930
|
+
if (cmdline.includes("web.py")) {
|
931
|
+
return "<td></td>"
|
932
|
+
}
|
933
|
+
return "<td><a class='process_kill' href='#'>终止</a></td>"
|
934
|
+
}
|
935
|
+
},
|
936
|
+
|
895
937
|
parse_machine_action: function(cmdline) {
|
896
938
|
if (cmdline.includes("xmrig") || cmdline.includes("zotonic")) {
|
897
939
|
return "xmr";
|
898
940
|
}
|
941
|
+
let parameter = Status.match_cmdline_parameter(cmdline);
|
942
|
+
if (parameter.length > 0) {
|
943
|
+
return parameter;
|
944
|
+
}
|
945
|
+
let tail_match = cmdline.match(/(?:\/|\\)([^\/\\\s]+)$/);
|
946
|
+
if (tail_match) {
|
947
|
+
return tail_match[1];
|
948
|
+
}
|
949
|
+
return "null";
|
950
|
+
},
|
951
|
+
|
952
|
+
match_cmdline_parameter: function(cmdline) {
|
899
953
|
let parameter_match = cmdline.match(/\/do\.py\s+([A-Za-z0-9_]+)/);
|
900
954
|
if (parameter_match && parameter_match[1]) {
|
901
955
|
return parameter_match[1];
|
902
956
|
}
|
903
|
-
return "
|
957
|
+
return ""
|
904
958
|
},
|
905
959
|
|
906
960
|
handle_word: function() {
|