Commit 8c14dc2a authored by co_dengxiongwen's avatar co_dengxiongwen

tj

parent 43e2d020
......@@ -16,6 +16,10 @@ import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.VariableBinding;
import org.snmp4j.transport.DefaultUdpTransportMapping;
/**
* SNMP又称简单网络管理协议,由一组网络管理的标准组成,
* 该协议能够支持网络管理系统,用以监测连接到网络上的设备是否有任何引起管理上关注的情况。
* 简而言之,SNMP就是为不同种类、不同厂家生产、不同型号的设备,
* 定义为一个统一的接口和协议,使得管理员可以是使用统一的方法来管理这些设备。
* @author jzj
* @date 2020/7/30 15:23
*/
......@@ -32,19 +36,25 @@ public class SnmpGet {
* @return
*/
public static CommunityTarget createDefault(String ip, String community) {
//生成目标地址对象
Address address = GenericAddress.parse(DEFAULT_PROTOCOL + ":" + ip + "/" + DEFAULT_PORT);
//CommunityTarget类实现了Target接口,用于SNMPv1和SNMPv2c这两个版本
CommunityTarget target = new CommunityTarget();
//设置snmp共同体
target.setCommunity(new OctetString(community));
//设置ip地址
target.setAddress(address);
//设置使用的snmp版本
target.setVersion(DEFAULT_VERSION);
// milliseconds
// 超时时间
target.setTimeout(DEFAULT_TIMEOUT);
//重传次数
target.setRetries(DEFAULT_RETRY);
return target;
}
/**
* 通过任意oid ,get方式请求服务器判断ip是否能ping通
* 通过任意oid(对象标示符) ,get方式(get则是取具体的oid的值)请求服务器判断ip是否能ping通
*
* @return
*/
......@@ -54,21 +64,27 @@ public class SnmpGet {
target.setTimeout(timeOut);
Snmp snmp = null;
try {
//绑定要查询的OID
PDU pdu = new PDU();
// pdu.add(new VariableBinding(new OID(new int[]
// {1,3,6,1,2,1,1,2})));
pdu.add(new VariableBinding(new OID(oid)));
//设定采取的协议
DefaultUdpTransportMapping transport = new DefaultUdpTransportMapping();
//创建SNMP对象,用于发送请求PDU
snmp = new Snmp(transport);
////调用snmp中的listen()方法,启动监听进程,接收消息,由于该监听进程是守护进程,最后应调用close()方法来释放该进程
snmp.listen();
pdu.setType(PDU.GET);
//调用 send(PDU pdu,Target target)发送pdu,返回一个ResponseEvent对象
ResponseEvent respEvent = snmp.send(pdu, target);
//通过ResponseEvent对象来获得SNMP请求的应答pdu,方法:public PDU getResponse()
PDU response = respEvent.getResponse();
if (response == null) {
} else {
//通过应答pdu获得mib信息(之前绑定的OID的值),方法:VaribleBinding get(int index)
for (int i = 0; i < response.size(); i++) {
VariableBinding vb = response.get(i);
return true;
......@@ -89,6 +105,13 @@ public class SnmpGet {
return false;
}
/**
* 单个oid
* @param ip
* @param community
* @param oid
* @return
*/
public static boolean snmpGet(String ip, String community, String oid) {
CommunityTarget target = createDefault(ip, community);
......@@ -133,7 +156,7 @@ public class SnmpGet {
*
* @param ip
* @param community
* @param oid
* @param oidList
*/
public static List<String> snmpGetList(String ip, String community, List<String> oidList) {
List<String> snmpList = new ArrayList<>();
......
......@@ -168,7 +168,9 @@ public class SnmpUtil {
double freeSize = Long.parseLong(values[1].getVariable().toString());
// 磁盘缓存大小
double availableSize = Long.parseLong(values[4].getVariable().toString());
// 缓冲区大小
double bufferSize = Long.parseLong(values[3].getVariable().toString());
//占用内存
memory = (totalSize - freeSize - availableSize - bufferSize) / totalSize * 100;
break;
}
......
......@@ -8,7 +8,6 @@ gpt.idleConnectionTestPeriod=60
gpt.acquireIncrement=3
gpt.maxIdleTime=60
gpt.initialPoolSize=10
gpt.maxPoolSize=100
#gpt.devPath=/Users/suochaochao/Work/sjw-cloud/microservice-spring-cloud/microservice-admin/
gpt.java.devPath=D:\\ck_work\\Suntray\\crsh_java\\microservice-admin\\src\\main\\java\\com\\devplatform\\admin\\modules\\
gpt.xml.devPath=D:\\ck_work\\Suntray\\crsh_java\\microservice-admin\\src\\main\\resources\\
......
......@@ -17,7 +17,6 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@Slf4j
@ComponentScan(basePackages = {"com.oauth.security"})
@EnableFeignClients
public class SpringBoot2Oauth2Application {
......
......@@ -34,17 +34,13 @@ import org.springframework.stereotype.Component;
@Component("appLoginInSuccessHandler")
public class AppLoginInSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
@Autowired
private ObjectMapper objectMapper;
@Autowired private ObjectMapper objectMapper;
@Autowired
private PasswordEncoder passwordEncoder;
@Autowired private PasswordEncoder passwordEncoder;
@Autowired
private ClientDetailsService clientDetailsService;
@Autowired private ClientDetailsService clientDetailsService;
@Autowired
private AuthorizationServerTokenServices authorizationServerTokenServices;
@Autowired private AuthorizationServerTokenServices authorizationServerTokenServices;
@Override
public void onAuthenticationSuccess(
......@@ -93,6 +89,11 @@ public class AppLoginInSuccessHandler extends SavedRequestAwareAuthenticationSuc
/**
* 解码
*
* @param header
* @param request
* @return
* @throws IOException
*/
private String[] extractAndDecodeHeader(String header, HttpServletRequest request)
throws IOException {
......@@ -110,7 +111,7 @@ public class AppLoginInSuccessHandler extends SavedRequestAwareAuthenticationSuc
if (delim == -1) {
throw new BadCredentialsException("Invalid basic authentication token");
} else {
return new String[]{token.substring(0, delim), token.substring(delim + 1)};
return new String[] {token.substring(0, delim), token.substring(delim + 1)};
}
}
}
......@@ -8,6 +8,7 @@ import java.util.List;
import org.apache.commons.lang.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationManager;
......@@ -41,9 +42,11 @@ public class MyAuthorizationServerConfig extends AuthorizationServerConfigurerAd
@Autowired
private AuthenticationManager authenticationManager;
@Qualifier("myUserDetailsServiceImpl")
@Autowired
private UserDetailsService userDetailsService;
@Qualifier("jwtTokenStore")
@Autowired
private TokenStore tokenStore;
......
......@@ -41,8 +41,8 @@ public class EquipmentApplication {
public static void main(String[] args) {
SpringApplication.run(EquipmentApplication.class, args);
handleMqInit();
sendMsg();
// handleMqInit();
// sendMsg();
}
private static void handleMqInit() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment