| | |
| | | |
| | | /** |
| | | * 查询服务器状态 |
| | | * |
| | | * @return |
| | | * @throws InterruptedException |
| | | */ |
| | | public JSONObject selectServerStatus() throws InterruptedException { |
| | | JSONObject json = new JSONObject(); |
| | |
| | | |
| | | /** |
| | | * 查询Cpu信息 |
| | | * |
| | | * @return |
| | | * @throws InterruptedException |
| | | */ |
| | | public JSONObject selectCpuInfo() throws InterruptedException { |
| | | SystemInfo systemInfo = new SystemInfo(); |
| | |
| | | |
| | | /** |
| | | * 查询内存信息 |
| | | * |
| | | * @return |
| | | */ |
| | | public JSONObject selectMemInfo() { |
| | | JSONObject map = new JSONObject(); |
| | |
| | | |
| | | /** |
| | | * 查询在线用户 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<JSONObject> selectOnlineUsers() { |
| | | List<JSONObject> list = new ArrayList<JSONObject>(); |
| | |
| | | Set<String> keys = redisTemplate.keys(RedisCacheKey.signUserKey("*")); |
| | | for (String key : keys) { |
| | | Object obj = redisTemplate.opsForValue().get(key); |
| | | if (obj != null && obj instanceof UserEntity) { |
| | | if (obj instanceof UserEntity) { |
| | | UserEntity ue = (UserEntity) obj; |
| | | |
| | | JSONObject map = new JSONObject(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 统计在线用户数 |
| | | */ |
| | | public int countOnlineUsers() { |
| | | Set<String> keys = redisTemplate.keys(RedisCacheKey.signUserKey("*")); |
| | | |
| | | return null == keys ? 0 : keys.size(); |
| | | } |
| | | |
| | | /** |
| | | * 查询服务资源状态 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<ResEntity> selectResStatus() { |
| | | List<ResEntity> resList = resService.selectResAll(); |
| | |
| | | return testResStatus(resList); |
| | | } |
| | | |
| | | /** |
| | | * 测试资源状态 |
| | | */ |
| | | private List<ResEntity> testResStatus(List<ResEntity> resList) { |
| | | List<ResEntity> list = new ArrayList<ResEntity>(); |
| | | for (ResEntity re : resList) { |
| | |
| | | // Ping通地址 |
| | | socket.connect(add, 2000); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | // log.error(e.getMessage()) |
| | | list.add(re); |
| | | } finally { |
| | | try { |
| | |
| | | |
| | | /** |
| | | * 统计服务资源状态 |
| | | * |
| | | * @return |
| | | */ |
| | | public JSONObject countResStatus() { |
| | | List<ResEntity> resList = resService.selectResAll(); |
| | |
| | | |
| | | /** |
| | | * 资源操作状态 |
| | | * |
| | | * @return |
| | | */ |
| | | |
| | | public JSONObject operateCount() { |
| | | List<OperateEntity> list = operateService.operateCount(); |
| | | JSONObject jsonObject = new JSONObject(); |
| | |
| | | |
| | | /** |
| | | * 用户登录状态 |
| | | * |
| | | * @return |
| | | */ |
| | | |
| | | public JSONObject userLoginCount() { |
| | | List<LoginEntity> list = loginService.selectLoginCounts(); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | if (list.isEmpty()) { |
| | | if (list == null || list.isEmpty()) { |
| | | return null; |
| | | } else { |
| | | List<JSONObject> lister = new ArrayList<JSONObject>(); |
| | | for (LoginEntity key : list) { |
| | | JSONObject map = new JSONObject(); |
| | | map.put("count", key.getCount()); |
| | | map.put("optime", key.getOptime()); |
| | | lister.add(map); |
| | | } |
| | | jsonObject.put("userLoginCount", lister); |
| | | return jsonObject; |
| | | } |
| | | } |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | List<JSONObject> lister = new ArrayList<JSONObject>(); |
| | | for (LoginEntity key : list) { |
| | | JSONObject map = new JSONObject(); |
| | | map.put("count", key.getCount()); |
| | | map.put("optime", key.getOptime()); |
| | | lister.add(map); |
| | | } |
| | | jsonObject.put("userLoginCount", lister); |
| | | |
| | | return jsonObject; |
| | | } |
| | | } |