交换机采集信息优化
This commit is contained in:
@@ -443,7 +443,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "dockerCollect": //风扇采集
|
||||
case "switchFanCollect": //风扇采集
|
||||
if(GlobalConfig.switchFanCollect != collect || GlobalConfig.switchFanInterval != interval){
|
||||
flag = true;
|
||||
GlobalConfig.switchFanCollect = collect;
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.tongran.agent.client.core.config.GlobalConfig;
|
||||
import com.tongran.agent.client.core.vo.SwitchBoardVO;
|
||||
import com.tongran.agent.client.service.SwitchBoardService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.tongran.agent.client.utils.AssertLog;
|
||||
import org.snmp4j.*;
|
||||
import org.snmp4j.event.ResponseEvent;
|
||||
import org.snmp4j.mp.SnmpConstants;
|
||||
@@ -413,18 +413,25 @@ public class SwitchBoardServiceImpl implements SwitchBoardService {
|
||||
pdu.setType(PDU.GET);
|
||||
|
||||
event = snmp.send(pdu, target);
|
||||
// System.out.printf("%-5s %-15s %-10s %-15s %-8s %-12s %-12s%n",
|
||||
// "Index", "Name", "Type", "Speed", "Status", "InBytes", "OutBytes");
|
||||
// if (event != null && event.getResponse() != null) {
|
||||
// VariableBinding[] vbs = event.getResponse().getVariableBindings().toArray(new VariableBinding[0]);
|
||||
// String ifName = vbs[0].getVariable().toString();
|
||||
// String ifType = getInterfaceType(vbs[1].getVariable().toInt());
|
||||
// String speed = formatSpeed(vbs[2].getVariable().toInt());
|
||||
// String status = getOperStatus(vbs[3].getVariable().toInt());
|
||||
// long inBytes = vbs[4].getVariable().toLong();
|
||||
// long outBytes = vbs[5].getVariable().toLong();
|
||||
// System.out.printf("%-15s %-10s %-15s %-8s %-12d %-12d%n",
|
||||
// ifName, ifType, speed, status, inBytes, outBytes);
|
||||
// }
|
||||
|
||||
if (event != null && event.getResponse() != null) {
|
||||
VariableBinding[] vbs = event.getResponse().getVariableBindings().toArray(new VariableBinding[0]);
|
||||
for (int m = 0; m < params.length; m++) {
|
||||
if(StringUtils.isNotBlank(type)){
|
||||
if(StringUtils.equals(params[m], type)){
|
||||
json.put(params[m],vbs[m].getVariable().toString());
|
||||
System.out.println(params[m]+":"+vbs[m].getVariable().toString());
|
||||
}
|
||||
}else{
|
||||
json.put(params[m],vbs[m].getVariable().toString());
|
||||
System.out.println(params[m]+":"+vbs[m].getVariable().toString());
|
||||
}
|
||||
AssertLog.info("参数名:{},值={}", params[m],vbs[m]);
|
||||
json.put(params[m],vbs[m].getVariable().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user