付延余
2022-12-16 f0f8ee8c4a945adbc742d9bab69382b28ad311fb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
function searchByOrder(orderBy,orderType){
    var urlParams = window.location.search;
    var hrefUrl = "/tssw/systemInfo/systemInfoList?orderBy="+orderBy+"&orderType="+orderType;
    if (urlParams.indexOf("pageSize") != -1) {
        hrefUrl += "&pageSize=5000";
    }
    if (urlParams.indexOf("groupId") != -1) {
        hrefUrl += "&groupId="+$("#groupId").val();
    }
    window.location.href = hrefUrl;
}
 
function searchByOnline(state){
    window.location.href = "/tssw/systemInfo/systemInfoList?state="+state;
}
 
function searchByOnlineDashView(state){
    window.location.href = "/tssw/systemInfo/systemInfoList?dashView=1&state="+state;
}
 
 
function searchByOrderDashView(orderBy,orderType){
    var urlParams = window.location.search;
    var hrefUrl = "/tssw/systemInfo/systemInfoList?dashView=1&orderBy="+orderBy+"&orderType="+orderType;
    if (urlParams.indexOf("pageSize") != -1) {
        hrefUrl += "&pageSize=5000";
    }
    if (urlParams.indexOf("groupId") != -1) {
        hrefUrl += "&groupId="+$("#groupId").val();
    }
    window.location.href = hrefUrl;
}
 
function searchAll(){
    window.location.href = "/tssw/systemInfo/systemInfoList?pageSize=5000";
}
 
function searchAllDashView(){
    window.location.href = "/tssw/systemInfo/systemInfoList?dashView=1&pageSize=5000";
}
 
function viewImage(id) {
    window.location.href = "/tssw/dash/hostDraw?id="+id;
}
 
function viewDashView(id) {
    window.location.href = "/tssw/systemInfo/detail?dashView=1&id="+id;
}
function viewChartDashView(id) {
    window.location.href = "/tssw/systemInfo/chart?dashView=1&id="+id;
}
function viewDatetDashView(id,searchTime){
    window.location.href = "/tssw/systemInfo/chart?dashView=1&id="+id+"&am="+searchTime;
}
function view(id) {
    window.location.href = "/tssw/systemInfo/detail?id="+id;
}
function viewChart(id) {
    window.location.href = "/tssw/systemInfo/chart?id="+id;
}
 
function del(id) {
    if(confirm('你确定要删除吗?此操作只会删除主机,主机下的监控资源及历史数据不会被删除')) {
        window.location.href = "/tssw/systemInfo/del?id=" + id;
    }
}
 
function viewWebSSH(hostname) {
    window.open("/tssw/ssh2/view?hostname="+hostname);
}
 
 
function viewDate(id,searchTime){
    window.location.href = "/tssw/systemInfo/chart?id="+id+"&am="+searchTime;
}
 
function excelExport(id,searchTime){
    var startTime = $("#startTime").val();
    var endTime = $("#endTime").val();
    window.open("/tssw/systemInfo/chartExcel?id="+id+"&startTime="+startTime+"&endTime="+endTime+"&am="+searchTime);
}
 
function excelExportHostList(){
    var urlParams = window.location.search;
    window.open("/tssw/systemInfo/hostListExcel" + urlParams);
}
 
function viewApps(hostname){
    window.location.href = "/tssw/appInfo/list?hostname="+hostname;
}
 
function viewDockers(hostname){
    window.location.href = "/tssw/dockerInfo/list?hostname="+hostname;
}
 
function viewPorts(hostname){
    window.location.href = "/tssw/portInfo/list?hostname="+hostname;
}
 
function viewFileWarn(hostname){
    window.location.href = "/tssw/fileWarnInfo/list?hostname="+hostname;
}
 
function ajaxSaveRemark() {
    $("#form2").ajaxSubmit(function(message) {
        window.location.href = window.location.href;
    });
}
 
 
function setHostRemark(hostId,hostRemark) {
    $("#id").val(hostId);
    $("#remark").val(hostRemark);
}
 
 
function setWinConsole(hostId,winConsole) {
    $("#id2").val(hostId);
    $("#winConsole").val(winConsole);
}
 
function ajaxSaveWinConsole() {
    $("#form3").ajaxSubmit(function(message) {
        window.open (message);
        window.location.href = window.location.href;
    });
}
 
function viewWinConsole() {
    window.open ($("#winConsole").val());
    $("#modal-default2").modal("toggle");
}
 
function showSetGroupId() {
    var chk_value =[];
    $("input[name='todo2']:checkbox").each(function() {
        if($(this).is(':checked')) {
            chk_value.push($(this).val());
        }
    });
    if(chk_value.length == 0){
        alert("请先选择需要设置分组的主机");
        return;
    }
    $("#id3").val(chk_value.join(","));
    $("#modal-default3").modal("toggle");
}
 
function ajaxSaveGroupId() {
    $("#form4").ajaxSubmit(function(message) {
        window.location.href = window.location.href;
    });
}
 
function searchByGroupId() {
    window.location.href = "/tssw/systemInfo/systemInfoList?groupId="+$("#groupId").val();
}
 
function searchByAccount() {
    window.location.href = "/tssw/systemInfo/systemInfoList?account="+$("#account").val();
}
 
function searchByGroupIdDashView() {
    window.location.href = "/tssw/systemInfo/systemInfoList?dashView=1&groupId="+$("#groupId").val();
}
 
function ajaxSystemInfoList() {
    var urlParams = window.location.search;
    var dashView = "";
    if (urlParams.indexOf("dashView") != -1) {
        dashView = "?dashView=1";
    }
    $.ajax({
        url: "/tssw/systemInfo/systemInfoListAjax"+dashView,
        type: "GET",
        dataType: "json",
        success: function(data) {
            for(i in data) {
                var obj = $("#"+data[i].id+"_state").html();
                if(obj!=null && obj != undefined){
                    $("#"+data[i].id+"_state").html(data[i].hostname);
                    $("#"+data[i].id+"_memPer").html(data[i].image);
                    $("#"+data[i].id+"_cpuPer").html(data[i].hostnameExt);
                    $("#"+data[i].id+"_rxbyt").html(data[i].rxbyt);
                    $("#"+data[i].id+"_txbyt").html(data[i].txbyt);
                    $("#"+data[i].id+"_fiveLoad").html(data[i].fiveLoad);
                    $("#"+data[i].id+"_netConnections").html(data[i].netConnections);
                    $("#"+data[i].id+"_createTime").html(data[i].remark);
                }
            }
        }
    });
}
 
function startTime(){
    if("" == $("#startTime").html()){
        $("#timeDiv").show();
        $("#startTime").html("30");
    } else {
        var sec = parseInt($("#startTime").html());
        sec = sec - 1;
        if (-1==sec){
            $("#startTime").html("30");
        }else{
            $("#startTime").html(sec);
        }
    }
}
 
var timer=null;
var timer2=null;
function startTask() {
    if(timer == null){
        $("#startTaskBtn").html("停止刷新");
        $("#startTaskBtn").addClass("btn-default");
        toastr.success("【自动刷新】启动成功,每隔30秒会自动刷新主机状态、内存%、CPU%、上下行传输速率、系统负载、连接数量、更新时间");
        timer = setInterval(function(){ajaxSystemInfoList()},30000);
        timer2 = setInterval(function(){ startTime()},1000);
    }else{
        toastr.success("【自动刷新】停止成功");
        $("#startTaskBtn").html("自动刷新");
        $("#startTaskBtn").removeClass("btn-default");
        clearInterval(timer);
        timer=null;
        clearInterval(timer2);
        timer2=null;
        $("#startTime").html("");
        $("#timeDiv").hide();
    }
}
 
 
function cancel(){
    history.back();
}