| | |
| | | |
| | | import com.lf.server.entity.all.RedisCacheKey; |
| | | import com.lf.server.entity.sys.ResEntity; |
| | | import com.lf.server.entity.sys.UsersEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.FileHelper; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.service.sys.ResService; |
| | | import org.apache.commons.logging.Log; |
| | |
| | | |
| | | // 剩余 |
| | | long surplusByte = memory.getAvailable(); |
| | | map.put("totalMem", StringHelper.formatByte(totalByte)); |
| | | map.put("use", StringHelper.formatByte(totalByte - surplusByte)); |
| | | map.put("remainMem", StringHelper.formatByte(surplusByte)); |
| | | map.put("totalMem", FileHelper.formatByte(totalByte)); |
| | | map.put("use", FileHelper.formatByte(totalByte - surplusByte)); |
| | | map.put("remainMem", FileHelper.formatByte(surplusByte)); |
| | | map.put("usage", new DecimalFormat("#.##%").format((totalByte - surplusByte) * 1.0 / totalByte)); |
| | | |
| | | return map; |
| | |
| | | Set<String> keys = redisTemplate.keys(RedisCacheKey.signUserKey("*")); |
| | | for (String key : keys) { |
| | | Object obj = redisTemplate.opsForValue().get(key); |
| | | if (obj != null && obj instanceof UsersEntity) { |
| | | UsersEntity ue = (UsersEntity) obj; |
| | | if (obj != null && obj instanceof UserEntity) { |
| | | UserEntity ue = (UserEntity) obj; |
| | | |
| | | JSONObject map = new JSONObject(); |
| | | map.put("uid", ue.getUid()); |
| | |
| | | for (ResEntity re : resList) { |
| | | Socket socket = new Socket(); |
| | | try { |
| | | if (StringHelper.isEmpty(re.getServer())){ |
| | | list.add(re); |
| | | continue; |
| | | } |
| | | |
| | | URI uri = new URI(re.getServer()); |
| | | SocketAddress add = new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()); |
| | | |
| | | // Ping通地址 |
| | | socket.connect(add, 2000); |
| | | } catch (Exception e) { |
| | | log.error(e.getStackTrace()); |
| | | log.error(e.getMessage()); |
| | | list.add(re); |
| | | } finally { |
| | | try { |
| | | socket.close(); |
| | | } catch (Exception e) { |
| | | log.error(e.getStackTrace()); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage()); |
| | | } |
| | | } |
| | | } |