交换机采集信息优化
This commit is contained in:
@@ -443,7 +443,7 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "dockerCollect": //风扇采集
|
case "switchFanCollect": //风扇采集
|
||||||
if(GlobalConfig.switchFanCollect != collect || GlobalConfig.switchFanInterval != interval){
|
if(GlobalConfig.switchFanCollect != collect || GlobalConfig.switchFanInterval != interval){
|
||||||
flag = true;
|
flag = true;
|
||||||
GlobalConfig.switchFanCollect = collect;
|
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.config.GlobalConfig;
|
||||||
import com.tongran.agent.client.core.vo.SwitchBoardVO;
|
import com.tongran.agent.client.core.vo.SwitchBoardVO;
|
||||||
import com.tongran.agent.client.service.SwitchBoardService;
|
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.*;
|
||||||
import org.snmp4j.event.ResponseEvent;
|
import org.snmp4j.event.ResponseEvent;
|
||||||
import org.snmp4j.mp.SnmpConstants;
|
import org.snmp4j.mp.SnmpConstants;
|
||||||
@@ -413,18 +413,25 @@ public class SwitchBoardServiceImpl implements SwitchBoardService {
|
|||||||
pdu.setType(PDU.GET);
|
pdu.setType(PDU.GET);
|
||||||
|
|
||||||
event = snmp.send(pdu, target);
|
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) {
|
if (event != null && event.getResponse() != null) {
|
||||||
VariableBinding[] vbs = event.getResponse().getVariableBindings().toArray(new VariableBinding[0]);
|
VariableBinding[] vbs = event.getResponse().getVariableBindings().toArray(new VariableBinding[0]);
|
||||||
for (int m = 0; m < params.length; m++) {
|
for (int m = 0; m < params.length; m++) {
|
||||||
if(StringUtils.isNotBlank(type)){
|
AssertLog.info("参数名:{},值={}", params[m],vbs[m]);
|
||||||
if(StringUtils.equals(params[m], type)){
|
json.put(params[m],vbs[m].getVariable().toString());
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user