Search in sources :

Example 1 with AppCount

use of com.usthe.manager.pojo.dto.AppCount in project hertzbeat by dromara.

the class MonitorServiceImpl method getAllAppMonitorsCount.

@Override
public List<AppCount> getAllAppMonitorsCount() {
    List<AppCount> appCounts = monitorDao.findAppsStatusCount();
    if (appCounts == null) {
        return null;
    }
    // Statistical category information, calculate the number of corresponding states for each monitor
    // 统计类别信息,计算每个监控分别对应状态的数量
    Map<String, AppCount> appCountMap = new HashMap<>(appCounts.size());
    for (AppCount item : appCounts) {
        AppCount appCount = appCountMap.getOrDefault(item.getApp(), new AppCount());
        appCount.setApp(item.getApp());
        switch(item.getStatus()) {
            case CommonConstants.AVAILABLE_CODE:
                appCount.setAvailableSize(appCount.getAvailableSize() + item.getSize());
                break;
            case CommonConstants.UN_AVAILABLE_CODE:
                appCount.setUnAvailableSize(appCount.getUnAvailableSize() + item.getSize());
                break;
            case CommonConstants.UN_MANAGE_CODE:
                appCount.setUnManageSize(appCount.getUnManageSize() + item.getSize());
                break;
            case CommonConstants.UN_REACHABLE_CODE:
                appCount.setUnReachableSize(appCount.getUnReachableSize() + item.getSize());
                break;
            default:
                break;
        }
        appCountMap.put(item.getApp(), appCount);
    }
    // 遍历统计得到的map,转换成List<App Count>结果集
    return appCountMap.values().stream().peek(item -> {
        item.setSize(item.getAvailableSize() + item.getUnManageSize() + item.getUnReachableSize() + item.getUnAvailableSize());
        Job job = appService.getAppDefine(item.getApp());
        if (job != null) {
            item.setCategory(job.getCategory());
        }
    }).collect(Collectors.toList());
}
Also used : java.util(java.util) CommonConstants(com.usthe.common.util.CommonConstants) MonitorDao(com.usthe.manager.dao.MonitorDao) ParamDefine(com.usthe.common.entity.manager.ParamDefine) MonitorDatabaseException(com.usthe.manager.support.exception.MonitorDatabaseException) Configmap(com.usthe.common.entity.job.Configmap) Autowired(org.springframework.beans.factory.annotation.Autowired) Param(com.usthe.common.entity.manager.Param) IntervalExpressionUtil(com.usthe.common.util.IntervalExpressionUtil) MonitorService(com.usthe.manager.service.MonitorService) Job(com.usthe.common.entity.job.Job) AppCount(com.usthe.manager.pojo.dto.AppCount) Tag(com.usthe.common.entity.manager.Tag) Service(org.springframework.stereotype.Service) MonitorDto(com.usthe.manager.pojo.dto.MonitorDto) CollectRep(com.usthe.common.entity.message.CollectRep) ParamDao(com.usthe.manager.dao.ParamDao) Monitor(com.usthe.common.entity.manager.Monitor) PageRequest(org.springframework.data.domain.PageRequest) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) IpDomainUtil(com.usthe.common.util.IpDomainUtil) Slf4j(lombok.extern.slf4j.Slf4j) AlertDefineBindDao(com.usthe.alert.dao.AlertDefineBindDao) SnowFlakeIdGenerator(com.usthe.common.util.SnowFlakeIdGenerator) Specification(org.springframework.data.jpa.domain.Specification) AppService(com.usthe.manager.service.AppService) AesUtil(com.usthe.common.util.AesUtil) CollectJobService(com.usthe.collector.dispatch.entrance.internal.CollectJobService) MonitorDetectException(com.usthe.manager.support.exception.MonitorDetectException) Metrics(com.usthe.common.entity.job.Metrics) Transactional(org.springframework.transaction.annotation.Transactional) AppCount(com.usthe.manager.pojo.dto.AppCount) Job(com.usthe.common.entity.job.Job)

Example 2 with AppCount

use of com.usthe.manager.pojo.dto.AppCount in project hertzbeat by dromara.

the class SummaryController method appMonitors.

@GetMapping
@ApiOperation(value = "Query all application category monitoring statistics", notes = "查询所有应用类别监控统计信息")
public ResponseEntity<Message<Dashboard>> appMonitors() {
    List<AppCount> appsCount = monitorService.getAllAppMonitorsCount();
    Message<Dashboard> message = new Message<>(new Dashboard(appsCount));
    return ResponseEntity.ok(message);
}
Also used : Message(com.usthe.common.entity.dto.Message) AppCount(com.usthe.manager.pojo.dto.AppCount) Dashboard(com.usthe.manager.pojo.dto.Dashboard) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

AppCount (com.usthe.manager.pojo.dto.AppCount)2 AlertDefineBindDao (com.usthe.alert.dao.AlertDefineBindDao)1 CollectJobService (com.usthe.collector.dispatch.entrance.internal.CollectJobService)1 Message (com.usthe.common.entity.dto.Message)1 Configmap (com.usthe.common.entity.job.Configmap)1 Job (com.usthe.common.entity.job.Job)1 Metrics (com.usthe.common.entity.job.Metrics)1 Monitor (com.usthe.common.entity.manager.Monitor)1 Param (com.usthe.common.entity.manager.Param)1 ParamDefine (com.usthe.common.entity.manager.ParamDefine)1 Tag (com.usthe.common.entity.manager.Tag)1 CollectRep (com.usthe.common.entity.message.CollectRep)1 AesUtil (com.usthe.common.util.AesUtil)1 CommonConstants (com.usthe.common.util.CommonConstants)1 IntervalExpressionUtil (com.usthe.common.util.IntervalExpressionUtil)1 IpDomainUtil (com.usthe.common.util.IpDomainUtil)1 SnowFlakeIdGenerator (com.usthe.common.util.SnowFlakeIdGenerator)1 MonitorDao (com.usthe.manager.dao.MonitorDao)1 ParamDao (com.usthe.manager.dao.ParamDao)1 Dashboard (com.usthe.manager.pojo.dto.Dashboard)1