付延余
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
package com.wgcloud.service;
 
import cn.hutool.core.collection.CollectionUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wgcloud.config.CommonConfig;
import com.wgcloud.dto.NetIoStateDto;
import com.wgcloud.dto.SubtitleDto;
import com.wgcloud.entity.*;
import com.wgcloud.mapper.SystemInfoMapper;
import com.wgcloud.util.DateUtil;
import com.wgcloud.util.FormatUtil;
import com.wgcloud.util.HostUtil;
import com.wgcloud.util.UUIDUtil;
import com.wgcloud.util.staticvar.StaticKeys;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * @version v3.3
 * @ClassName:SystemInfoService.java
 * @author: http://www.wgstart.com
 * @date: 2021年1月16日
 * @Description: SystemInfoService.java
 * @Copyright: 2019-2021 wgcloud. All rights reserved.
 */
@Service
public class SystemInfoService {
 
    private static final Logger logger = LoggerFactory.getLogger(SystemInfoService.class);
 
    public PageInfo selectByParams(Map<String, Object> params, int currPage, int pageSize) throws Exception {
        PageHelper.startPage(currPage, pageSize);
        List<SystemInfo> list = systemInfoMapper.selectByParams(params);
        PageInfo<SystemInfo> pageInfo = new PageInfo<SystemInfo>(list);
        return pageInfo;
    }
 
    public void save(SystemInfo SystemInfo) throws Exception {
        SystemInfo.setId(UUIDUtil.getUUID());
        SystemInfo.setCreateTime(DateUtil.getNowTime());
        systemInfoMapper.save(SystemInfo);
    }
 
    public void downByHostName(List<String> recordList) throws Exception {
        if (recordList.size() < 1) {
            return;
        }
        systemInfoMapper.downByHostName(recordList);
    }
 
    @Transactional
    public void saveRecord(List<SystemInfo> recordList) throws Exception {
        if (recordList.size() < 1) {
            return;
        }
        for (SystemInfo as : recordList) {
            as.setId(UUIDUtil.getUUID());
            as.setCreateTime(DateUtil.getNowTime());
        }
        systemInfoMapper.insertList(recordList);
    }
 
    @Transactional
    public void updateRecord(List<SystemInfo> recordList) throws Exception {
        if (recordList.size() < 1) {
            return;
        }
        systemInfoMapper.updateList(recordList);
    }
 
    @Transactional
    public void updateById(SystemInfo SystemInfo) throws Exception {
        systemInfoMapper.updateById(SystemInfo);
    }
 
    public int deleteById(String[] id) throws Exception {
        return systemInfoMapper.deleteById(id);
    }
 
    public SystemInfo selectById(String id) throws Exception {
        return systemInfoMapper.selectById(id);
    }
 
    public List<SystemInfo> selectAllByParams(Map<String, Object> params) throws Exception {
        return systemInfoMapper.selectAllByParams(params);
    }
 
    public int countByParams(Map<String, Object> params) throws Exception {
        return systemInfoMapper.countByParams(params);
    }
 
    public SystemInfo selectByHostname(String hostname) throws Exception {
        List<SystemInfo> list = systemInfoMapper.selectByHostname(hostname);
        if (list.size() > 0) {
            return list.get(0);
        }
        return null;
    }
 
    /**
     * 根据hostname删除数据
     *
     * @param params
     * @return
     * @throws Exception
     */
    public int deleteByAccHname(Map<String, Object> params) throws Exception {
        return systemInfoMapper.deleteByAccHname(params);
    }
 
    public PageInfo selectBytesTop3(Map<String, Object> params, int currPage, int pageSize) throws Exception {
        PageHelper.startPage(currPage, pageSize);
        List<SystemInfo> list = systemInfoMapper.selectBytesTop3(params);
        PageInfo<SystemInfo> pageInfo = new PageInfo<SystemInfo>(list);
        return pageInfo;
    }
 
    /**
     * 主机列表添加一些附加值参数,以及参数转换格式化
     *
     * @param pageInfo
     */
    public void hostAddVal(PageInfo<SystemInfo> pageInfo, List<HostGroup> hostGroupList) throws Exception {
        //组装进程数量,docker数量,端口数量,监控日志,磁盘使用率 begin
        Map<String, Object> paramsAppInfo = new HashMap<String, Object>();
 
        //查询所有主机分组列表,封装为map begin
        Map<String, String> hostGroupMap = new HashMap<>();
        for (HostGroup hostGroup : hostGroupList) {
            hostGroupMap.put(hostGroup.getId(), hostGroup.getGroupName());
        }
        //查询所有主机分组列表,封装为map end
 
        for (SystemInfo systemInfo1 : pageInfo.getList()) {
            paramsAppInfo.put("hostname", systemInfo1.getHostname());
            systemInfo1.setRxbyt(FormatUtil.kbToM(systemInfo1.getRxbyt()) + "/s");
            systemInfo1.setTxbyt(FormatUtil.kbToM(systemInfo1.getTxbyt()) + "/s");
            /*int totalAppSize = appInfoService.countByParams(paramsAppInfo);
            systemInfo1.setGroupName(totalAppSize + "");
            int dockerSize = dockerInfoService.countByParams(paramsAppInfo);
            systemInfo1.setDockerName(dockerSize + "");
            int portSize = portInfoService.countByParams(paramsAppInfo);
            systemInfo1.setPortName(portSize + "");
            int fileWarnSize = fileWarnInfoService.countByParams(paramsAppInfo);
            systemInfo1.setFileWarnName(fileWarnSize + "");*/
 
            //设置主机logo
            HostUtil.setSysImage(systemInfo1);
 
            //设置主机分组名称
            String groupId = systemInfo1.getGroupId();
            if (!StringUtils.isEmpty(groupId)) {
                systemInfo1.setGroupId(hostGroupMap.get(groupId));
            }
 
            //设置磁盘总使用率 begin
            List<DiskState> deskStates = diskStateService.selectAllByParams(paramsAppInfo);
            HostUtil.setDiskSumPer(deskStates, systemInfo1);
            //设置磁盘总使用率 end
 
            //设置主机及监控资源累积告警次数 begin
            if (StaticKeys.TRUE_VAL.equals(commonConfig.getShowWarnCount())) {
                String warnQueryWd = systemInfo1.getHostname();
                paramsAppInfo.clear();
                paramsAppInfo.put("hostname", warnQueryWd);
                paramsAppInfo.put("hostnameNe", "已恢复");
                systemInfo1.setWarnCount(logInfoService.countByParams(paramsAppInfo));
                systemInfo1.setWarnQueryWd(warnQueryWd);
            }
            //设置主机及监控资源累积告警次数 end
 
        }
        //组装进程数量,docker数量,端口数量,监控日志,磁盘使用率 end
    }
 
    /**
     * 公众看板页面,未登录时候,IP脱敏显示,隐藏前5个字符
     *
     * @param pageInfo
     */
    public void hideLeftIp(PageInfo<SystemInfo> pageInfo, HttpServletRequest request) {
        if (!StaticKeys.TRUE_VAL.equals(commonConfig.getDashViewIpHide())) {
            return;
        }
        HttpSession session = request.getSession();
        AccountInfo accountInfo = (AccountInfo) session.getAttribute(StaticKeys.LOGIN_KEY);
        if (null == accountInfo) {
            for (SystemInfo systemInfo : pageInfo.getList()) {
                if (StringUtils.isBlank(systemInfo.getHostname())) {
                    continue;
                }
                int length = StringUtils.length(systemInfo.getHostname());
                String resHostName = StringUtils.leftPad(StringUtils.right(systemInfo.getHostname(), length - 5), length, "*");
                systemInfo.setHostname(resHostName);
            }
        }
    }
 
    /**
     * 设置图表的副标题,cpu和内存的最高、平均、最低值
     *
     * @param model
     * @param cpuStateList cpu状态数据
     * @param memStateList 内存状态数据
     */
    public void setSubtitle(Model model, List<CpuState> cpuStateList, List<MemState> memStateList) {
        //cpu使用率最高
        Double maxCpu = 0d;
        //cpu使用率平均
        Double avgCpu = 0d;
        //cpu使用率最低
        Double minCpu = 1000d;
        Double sumCpu = 0d;
 
        //内存使用率最高
        Double maxMem = 0d;
        //内存使用率最低
        Double minMem = 1000d;
        //内存使用率平均
        Double avgMem = 0d;
        Double sumMem = 0d;
 
        //组装cpu使用率 begin
        for (CpuState cpuState : cpuStateList) {
            if (null != cpuState.getSys()) {
                if (cpuState.getSys() > maxCpu) {
                    maxCpu = cpuState.getSys();
                }
                if (cpuState.getSys() < minCpu) {
                    minCpu = cpuState.getSys();
                }
                sumCpu += cpuState.getSys();
            }
        }
        if (cpuStateList.size() > 0) {
            avgCpu = sumCpu / cpuStateList.size();
        } else {
            minCpu = 0d;
        }
        SubtitleDto cpuSubtitleDto = new SubtitleDto();
        cpuSubtitleDto.setAvgValue(FormatUtil.formatDouble(avgCpu, 2) + "");
        cpuSubtitleDto.setMaxValue(maxCpu + "");
        cpuSubtitleDto.setMinValue(minCpu + "");
        model.addAttribute("cpuSubtitleDto", cpuSubtitleDto);
        //组装cpu使用率 end
 
        //组装内存使用率 begin
        for (MemState memState : memStateList) {
            if (null != memState.getUsePer()) {
                if (memState.getUsePer() > maxMem) {
                    maxMem = memState.getUsePer();
                }
                if (memState.getUsePer() < minMem) {
                    minMem = memState.getUsePer();
                }
                sumMem += memState.getUsePer();
            }
        }
        if (memStateList.size() > 0) {
            avgMem = sumMem / memStateList.size();
        } else {
            minMem = 0d;
        }
        SubtitleDto memSubtitleDto = new SubtitleDto();
        memSubtitleDto.setAvgValue(FormatUtil.formatDouble(avgMem, 2) + "");
        memSubtitleDto.setMaxValue(maxMem + "");
        memSubtitleDto.setMinValue(minMem + "");
        model.addAttribute("memSubtitleDto", memSubtitleDto);
        //组装内存使用率 end
    }
 
    /**
     * 查找系统负载最大值
     *
     * @param sysLoadStateList
     * @param model
     * @return
     */
    public void findLoadMaxVal(List<SysLoadState> sysLoadStateList, Model model) {
        //图表属性max
        double maxVal = 0;
        //1分钟负载值最高
        Double maxOneLoad = 0d;
        //1分钟负载值平均
        Double avgOneLoad = 0d;
        //1分钟负载值最低
        Double minOneLoad = 1000d;
        Double sumOneLoad = 0d;
 
        //5分钟负载值最高
        Double maxFiveLoad = 0d;
        //5分钟负载值平均
        Double avgFiveLoad = 0d;
        //5分钟负载值最低
        Double minFiveLoad = 1000d;
        Double sumFiveLoad = 0d;
 
        //15分钟负载值最高
        Double maxFifteenLoad = 0d;
        //15分钟负载值平均
        Double avgFifteenLoad = 0d;
        //15分钟负载值最低
        Double minFifteenLoad = 1000d;
        Double sumFifteenLoad = 0d;
 
        if (!CollectionUtil.isEmpty(sysLoadStateList)) {
            for (SysLoadState sysLoadState : sysLoadStateList) {
                if (null != sysLoadState.getOneLoad()) {
                    if (sysLoadState.getOneLoad() > maxOneLoad) {
                        maxOneLoad = sysLoadState.getOneLoad();
                    }
                    if (sysLoadState.getOneLoad() < minOneLoad) {
                        minOneLoad = sysLoadState.getOneLoad();
                    }
                    sumOneLoad += sysLoadState.getOneLoad();
                }
                if (null != sysLoadState.getFiveLoad()) {
                    if (sysLoadState.getFiveLoad() > maxFiveLoad) {
                        maxFiveLoad = sysLoadState.getFiveLoad();
                    }
                    if (sysLoadState.getFiveLoad() < minFiveLoad) {
                        minFiveLoad = sysLoadState.getFiveLoad();
                    }
                    sumFiveLoad += sysLoadState.getFiveLoad();
                }
                if (null != sysLoadState.getFifteenLoad()) {
                    if (sysLoadState.getFifteenLoad() > maxFifteenLoad) {
                        maxFifteenLoad = sysLoadState.getFifteenLoad();
                    }
                    if (sysLoadState.getFifteenLoad() < minFifteenLoad) {
                        minFifteenLoad = sysLoadState.getFifteenLoad();
                    }
                    sumFifteenLoad += sysLoadState.getFifteenLoad();
                }
            }
        }
        if (maxOneLoad > maxVal) {
            maxVal = maxOneLoad;
        }
        if (maxFiveLoad > maxVal) {
            maxVal = maxFiveLoad;
        }
        if (maxFifteenLoad > maxVal) {
            maxVal = maxFifteenLoad;
        }
        if (maxVal == 0) {
            maxVal = 1;
        }
        model.addAttribute("sysLoadStateMaxVal", Math.ceil(maxVal));
        if (sysLoadStateList.size() > 0) {
            avgOneLoad = sumOneLoad / sysLoadStateList.size();
            avgFiveLoad = sumFiveLoad / sysLoadStateList.size();
            avgFifteenLoad = sumFifteenLoad / sysLoadStateList.size();
        } else {
            minOneLoad = 0d;
            minFiveLoad = 0d;
            minFifteenLoad = 0d;
        }
        //设置系统负载图表副标题 begin
        SubtitleDto oneLoadSubtitleDto = new SubtitleDto();
        oneLoadSubtitleDto.setAvgValue(FormatUtil.formatDouble(avgOneLoad, 2) + "");
        oneLoadSubtitleDto.setMaxValue(maxOneLoad + "");
        oneLoadSubtitleDto.setMinValue(minOneLoad + "");
        model.addAttribute("oneLoadSubtitleDto", oneLoadSubtitleDto);
        SubtitleDto fiveLoadSubtitleDto = new SubtitleDto();
        fiveLoadSubtitleDto.setAvgValue(FormatUtil.formatDouble(avgFiveLoad, 2) + "");
        fiveLoadSubtitleDto.setMaxValue(maxFiveLoad + "");
        fiveLoadSubtitleDto.setMinValue(minFiveLoad + "");
        model.addAttribute("fiveLoadSubtitleDto", fiveLoadSubtitleDto);
        SubtitleDto fifteenLoadSubtitleDto = new SubtitleDto();
        fifteenLoadSubtitleDto.setAvgValue(FormatUtil.formatDouble(avgFifteenLoad, 2) + "");
        fifteenLoadSubtitleDto.setMaxValue(maxFifteenLoad + "");
        fifteenLoadSubtitleDto.setMinValue(minFifteenLoad + "");
        model.addAttribute("fifteenLoadSubtitleDto", fifteenLoadSubtitleDto);
        //设置系统负载图表副标题 end
 
    }
 
    /**
     * 转为DTO,因为图表显示要用数字类型
     *
     * @param netIoStateList
     * @return
     */
    public List<NetIoStateDto> toNetIoStateDto(List<NetIoState> netIoStateList) {
        List<NetIoStateDto> dtoList = new ArrayList<>();
        for (NetIoState netIoState : netIoStateList) {
            NetIoStateDto dto = new NetIoStateDto();
            dto.setCreateTime(netIoState.getCreateTime());
            dto.setDateStr(netIoState.getDateStr());
            dto.setHostname(netIoState.getHostname());
            dto.setRxbyt(Double.valueOf(netIoState.getRxbyt()));
            dto.setRxpck(Double.valueOf(netIoState.getRxpck()));
            dto.setTxbyt(Double.valueOf(netIoState.getTxbyt()));
            dto.setTxpck(Double.valueOf(netIoState.getTxpck()));
            dto.setDropin(Double.valueOf(netIoState.getDropin()));
            dto.setDropout(Double.valueOf(netIoState.getDropout()));
            dto.setNetConnections(Integer.valueOf(netIoState.getNetConnections()));
            dtoList.add(dto);
        }
        return dtoList;
    }
 
    /**
     * 查找网络流量、包、丢弃包最大值,传递到页面
     *
     * @param netIoStateList
     * @return
     */
    public void findNetIoStateBytMaxVal(List<NetIoStateDto> netIoStateList, Model model) {
        //图表属性max用最大值,上下行传输速率
        double maxBytesVal = 0;
        //图表属性max用最大值,每秒传输包数
        double maxPckVal = 0;
        //图表属性max用最大值,每秒丢包数
        double maxDropVal = 0;
 
        //下行传输速率最高
        Double maxRxbyt = 0d;
        //下行传输速率平均
        Double avgRxbyt = 0d;
        //下行传输速率最低
        Double minRxbyt = 99999d;
        Double sumRxbyt = 0d;
 
        //上行传输速率最高
        Double maxTxbyt = 0d;
        //上行传输速率最低
        Double minTxbyt = 99999d;
        //上行传输速率平均
        Double avgTxbyt = 0d;
        Double sumTxbyt = 0d;
 
        //每秒钟接收的数据包最高
        Double maxRxpck = 0d;
        //每秒钟接收的数据包平均
        Double avgRxpck = 0d;
        //每秒钟接收的数据包最低
        Double minRxpck = 99999d;
        Double sumRxpck = 0d;
 
        //每秒钟发送的数据包最高
        Double maxTxpck = 0d;
        //每秒钟发送的数据包最低
        Double minTxpck = 99999d;
        //每秒钟发送的数据包平均
        Double avgTxpck = 0d;
        Double sumTxpck = 0d;
 
        //连接数最高
        Integer maxConns = 0;
        //连接数最低
        Integer minConns = 99999;
        //连接数平均
        Double avgConns = 0d;
        Integer sumConns = 0;
 
        if (!CollectionUtil.isEmpty(netIoStateList)) {
            for (NetIoStateDto netIoState : netIoStateList) {
                try {
                    //组装图表属性用最大值max begin
                    if (null != netIoState.getDropin() && netIoState.getDropin() > maxDropVal) {
                        maxDropVal = netIoState.getDropin();
                    }
                    if (null != netIoState.getDropout() && netIoState.getDropout() > maxDropVal) {
                        maxDropVal = netIoState.getDropout();
                    }
                    //组装图表属性用最大值max end
 
                    //组装下行传输速率 begin
                    if (null != netIoState.getRxbyt()) {
                        if (netIoState.getRxbyt() > maxRxbyt) {
                            maxRxbyt = netIoState.getRxbyt();
                        }
                        if (netIoState.getRxbyt() < minRxbyt) {
                            minRxbyt = netIoState.getRxbyt();
                        }
                        sumRxbyt += netIoState.getRxbyt();
                    }
                    if (null != netIoState.getTxbyt()) {
                        if (netIoState.getTxbyt() > maxTxbyt) {
                            maxTxbyt = netIoState.getTxbyt();
                        }
                        if (netIoState.getTxbyt() < minTxbyt) {
                            minTxbyt = netIoState.getTxbyt();
                        }
                        sumTxbyt += netIoState.getTxbyt();
                    }
                    //组装上行传输速率 end
 
                    //组装每秒传输数据包 begin
                    if (null != netIoState.getRxpck()) {
                        if (netIoState.getRxpck() > maxRxpck) {
                            maxRxpck = netIoState.getRxpck();
                        }
                        if (netIoState.getRxpck() < minRxpck) {
                            minRxpck = netIoState.getRxpck();
                        }
                        sumRxpck += netIoState.getRxpck();
                    }
                    if (null != netIoState.getTxpck()) {
                        if (netIoState.getTxpck() > maxTxpck) {
                            maxTxpck = netIoState.getTxpck();
                        }
                        if (Double.valueOf(netIoState.getTxpck()) < minTxpck) {
                            minTxpck = netIoState.getTxpck();
                        }
                        sumTxpck += netIoState.getTxpck();
                    }
                    //组装每秒传输数据包 end
 
                    //组装连接数 begin
                    if (null != netIoState.getNetConnections()) {
                        if (netIoState.getNetConnections() > maxConns) {
                            maxConns = netIoState.getNetConnections();
                        }
                        if (Double.valueOf(netIoState.getNetConnections()) < minConns) {
                            minConns = netIoState.getNetConnections();
                        }
                        sumConns += netIoState.getNetConnections();
                    }
                    //组装连接数 end
                } catch (Exception e) {
                    logger.error("设置网络流量图表副标题错误", e);
                }
            }
        }
 
        //设置图表属性max最大值 begin
        if (maxRxbyt > maxBytesVal) {
            maxBytesVal = maxRxbyt;
        }
        if (maxTxbyt > maxBytesVal) {
            maxBytesVal = maxTxbyt;
        }
        if (maxRxpck > maxPckVal) {
            maxPckVal = maxRxpck;
        }
        if (maxTxpck > maxPckVal) {
            maxPckVal = maxTxpck;
        }
        if (maxBytesVal == 0) {
            maxBytesVal = 1;
        }
        model.addAttribute("netIoStateBytMaxVal", Math.ceil(maxBytesVal));
        if (maxPckVal == 0) {
            maxPckVal = 1;
        }
        model.addAttribute("netIoStatePckMaxVal", Math.ceil(maxPckVal));
        if (maxDropVal == 0) {
            maxDropVal = 1;
        }
        model.addAttribute("netIoStateDropPckMaxVal", Math.ceil(maxDropVal));
        //设置图表属性max最大值 end
 
        if (netIoStateList.size() > 0) {
            avgRxbyt = sumRxbyt / netIoStateList.size();
            avgTxbyt = sumTxbyt / netIoStateList.size();
            avgRxpck = sumRxpck / netIoStateList.size();
            avgTxpck = sumTxpck / netIoStateList.size();
            avgConns = sumConns / (double) netIoStateList.size();
        } else {
            minRxbyt = 0d;
            minTxbyt = 0d;
            minRxpck = 0d;
            minTxpck = 0d;
            minConns = 0;
        }
        SubtitleDto rxbytSubtitleDto = new SubtitleDto();
        rxbytSubtitleDto.setAvgValue(FormatUtil.kbToM(FormatUtil.formatDouble(avgRxbyt, 2) + "") + "/s");
        rxbytSubtitleDto.setMaxValue(FormatUtil.kbToM(maxRxbyt + "") + "/s");
        rxbytSubtitleDto.setMinValue(FormatUtil.kbToM(minRxbyt + "") + "/s");
        model.addAttribute("rxbytSubtitleDto", rxbytSubtitleDto);
 
        SubtitleDto txbytSubtitleDto = new SubtitleDto();
        txbytSubtitleDto.setAvgValue(FormatUtil.kbToM(FormatUtil.formatDouble(avgTxbyt, 2) + "") + "/s");
        txbytSubtitleDto.setMaxValue(FormatUtil.kbToM(maxTxbyt + "") + "/s");
        txbytSubtitleDto.setMinValue(FormatUtil.kbToM(minTxbyt + "") + "/s");
        model.addAttribute("txbytSubtitleDto", txbytSubtitleDto);
 
        SubtitleDto rxpckSubtitleDto = new SubtitleDto();
        rxpckSubtitleDto.setAvgValue(FormatUtil.formatDouble(avgRxpck, 2) + "/s");
        rxpckSubtitleDto.setMaxValue(maxRxpck + "/s");
        rxpckSubtitleDto.setMinValue(minRxpck + "/s");
        model.addAttribute("rxpckSubtitleDto", rxpckSubtitleDto);
 
        SubtitleDto txpckSubtitleDto = new SubtitleDto();
        txpckSubtitleDto.setAvgValue(FormatUtil.formatDouble(avgTxpck, 2) + "/s");
        txpckSubtitleDto.setMaxValue(maxTxpck + "/s");
        txpckSubtitleDto.setMinValue(minTxpck + "/s");
        model.addAttribute("txpckSubtitleDto", txpckSubtitleDto);
 
        SubtitleDto connsSubtitleDto = new SubtitleDto();
        connsSubtitleDto.setAvgValue(FormatUtil.formatDouble(avgConns, 2) + "");
        connsSubtitleDto.setMaxValue(maxConns + "");
        connsSubtitleDto.setMinValue(minConns + "");
        model.addAttribute("connsSubtitleDto", connsSubtitleDto);
 
    }
 
 
    /**
     * 公众看板页面,未登录时候,IP脱敏显示,隐藏前5个字符
     *
     * @param systemInfo
     */
    public void hideLeftIp(SystemInfo systemInfo, HttpServletRequest request) {
        if (StringUtils.isBlank(systemInfo.getHostname())) {
            return;
        }
        if (!StaticKeys.TRUE_VAL.equals(commonConfig.getDashViewIpHide())) {
            return;
        }
        HttpSession session = request.getSession();
        AccountInfo accountInfo = (AccountInfo) session.getAttribute(StaticKeys.LOGIN_KEY);
        if (null == accountInfo) {
            int length = StringUtils.length(systemInfo.getHostname());
            String resHostName = StringUtils.leftPad(StringUtils.right(systemInfo.getHostname(), length - 5), length, "*");
            systemInfo.setHostname(resHostName);
        }
    }
 
 
    @Autowired
    private SystemInfoMapper systemInfoMapper;
    @Autowired
    private CommonConfig commonConfig;
    @Resource
    private DiskStateService diskStateService;
    @Resource
    private LogInfoService logInfoService;
 
 
}