Monitor.cshtml
9.54 KB
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
@{
ViewData["Title"] = "系统监控";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@section header {
<style type="text/css">
.warning {
color: red;
}
</style>
}
<div class="layui-row">
<div class="layui-col-xs6">
<div class="layui-card">
<div class="layui-card-header"><b>CPU</b></div>
<div class="layui-card-body">
<table class="layui-table" lay-skin="line">
<thead>
<tr>
<th>属性</th>
<th>值</th>
</tr>
</thead>
<tbody>
<tr>
<td>型号</td>
<td><span id="cupName">未获取</span></td>
</tr>
<tr>
<td>制造商</td>
<td><span id="cpuSupper">未获取</span></td>
</tr>
<tr>
<td>核心数</td>
<td><span id="cpuNum">未获取</span></td>
</tr>
<tr>
<td>使用率</td>
<td><span id="cpuUsed">0%</span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="layui-col-xs6">
<div class="layui-card">
<div class="layui-card-header"><b>内存</b></div>
<div class="layui-card-body">
<table class="layui-table" lay-skin="line">
<thead>
<tr>
<th>属性</th>
<th>值</th>
</tr>
</thead>
<tbody>
<tr>
<td>总内存</td>
<td><span id="MemTotal">未获取</span></td>
</tr>
<tr>
<td>已用内存</td>
<td><span id="MemSys">未获取</span></td>
</tr>
<tr>
<td>剩余内存</td>
<td><span id="MemFree">未获取</span></td>
</tr>
<tr>
<td>使用率</td>
<td><span id="MemUsed">未获取</span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-card">
<div class="layui-card-header"><b>硬盘状态</b></div>
<div class="layui-card-body">
<table class="layui-table" lay-skin="line">
<thead>
<tr>
<th>盘符</th>
<th>文件系统</th>
<th>总大小</th>
<th>可用大小</th>
<th>已用大小</th>
<th>占用百分比</th>
</tr>
</thead>
<tbody id="SysFiles">
<tr>
<td colspan="6" style="text-align: center;">无数据</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-card">
<div class="layui-card-header"><b>服务器信息</b></div>
<div class="layui-card-body">
<div class="layui-row">
<span class="layui-col-md3">服务器名称</span>
<span class="layui-col-md3" id="ComputerName">null</span>
<span class="layui-col-md3">操作系统</span>
<span class="layui-col-md3" id="Caption">未获取</span>
</div>
<hr class="layui-border-blue">
<div class="layui-row">
<span class="layui-col-md3">服务器IP</span>
<span class="layui-col-md3" id="IP">未获取</span>
<span class="layui-col-md3">系统架构</span>
<span class="layui-col-md3" id="OSArchitecture">未获取</span>
</div>
<hr class="layui-border-blue">
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-card">
<div class="layui-card-header"><b>程序运行环境</b></div>
<div class="layui-card-body">
<div class="layui-row">
<span class="layui-col-md3">框架平台</span>
<span class="layui-col-md3">Net Core</span>
<span class="layui-col-md3">运行时信息版本</span>
<span class="layui-col-md3">2.2</span>
</div>
<hr class="layui-border-blue">
<div class="layui-row">
<span class="layui-col-md3">启动时间</span>
<span class="layui-col-md3"><span id="StartTime">0</span></span>
<span class="layui-col-md3">运行时长</span>
<span class="layui-col-md3"><span id="RunTime">0</span></span>
</div>
<hr class="layui-border-blue">
<div class="layui-row">
<span class="layui-col-md3">项目路径</span>
<span class="layui-col-md9" id="Path">null</span>
</div>
<hr class="layui-border-blue">
</div>
</div>
</div>
@section Scripts {
<script>
layui.use('element', function () {
var element = layui.element;
});
function Update() {
$.ajax({
url: "GetSystemInfo",
success: function (result) {
//CPU
$("#cpuNum").html(result.cpu.num);
$("#cupName").html(result.cpu.name);
$("#cpuSupper").html(result.cpu.supper);
$("#cpuUsed").html(result.cpu.used);
if (result.cpu.used.replace("%", "") >= 80) {
$("#cpuUsed").attr("class", "warning");
}
else {
$("#cpuUsed").attr("class", "");
}
//内存
$("#MemTotal").html(result.mem.total);
$("#MemFree").html(result.mem.free);
$("#MemSys").html(result.mem.sys);
$("#MemUsed").html(result.mem.used);
if (result.mem.used.replace("%", "") >= 80) {
$("#MemUsed").attr("class", "warning");
}
else {
$("#MemUsed").attr("class", "");
}
//SystemInfo
$("#StartTime").html(result.sys.startTime);
$("#RunTime").html(result.sys.runTime);
$("#Path").html(result.sys.path);
$("#ComputerName").html(result.sys.name);
$("#Caption").html(result.sys.caption);
$("#OSArchitecture").html(result.sys.osArchitecture)
$("#IP").html(result.sys.ip);
//磁盘信息
var sysFiles = [];
result.sysFiles.forEach((item, index) => {
var temp = `<tr>
<td>${item.dirName}</td>
<td>${item.sysTypeName}</td>
<td>${item.total}</td>
<td>${item.free}</td>
<td>${item.used}</td>`;
if (item.usage.replace("%", "") >= 80) {
temp += `<td class="warning">${item.usage}</td>`
}
else {
temp += `<td>${item.usage}</td>`
};
temp += `</tr>`;
sysFiles.push(temp);
});
if (sysFiles.length > 0) {
$("#SysFiles").html(sysFiles);
}
},
error: function (error) {
var msg = error.responseText;
if (msg == "") {
layer.msg("网络故障或程序异常,获取数据失败!若长时间出现,请联系管理员处理!", { icon: 2 });
}
else {
console.error(msg);
layer.msg(`获取数据失败!${msg}若长时间出现,请联系管理员处理!`, { icon: 2 });
}
}
});
}
window.onload = Update;
window.setInterval(Update, 1000);
</script>
}