当前位置: 首页>>代码示例>>Java>>正文


Java TableEvent.isError方法代码示例

本文整理汇总了Java中org.snmp4j.util.TableEvent.isError方法的典型用法代码示例。如果您正苦于以下问题:Java TableEvent.isError方法的具体用法?Java TableEvent.isError怎么用?Java TableEvent.isError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.snmp4j.util.TableEvent的用法示例。


在下文中一共展示了TableEvent.isError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: querySingleSNMPTableByOID

import org.snmp4j.util.TableEvent; //导入方法依赖的package包/类
public List<SNMPTriple> querySingleSNMPTableByOID(String oid) throws IOException
{
 if(oid == null || oid.isEmpty())return null;
 if(!oid.startsWith("."))oid = "."+oid;
    TableUtils tUtils = new TableUtils(snmp, new DefaultPDUFactory());
    List<TableEvent> events = tUtils.getTable(getTarget(), new OID[]{new OID(oid)}, null, null);

 List<SNMPTriple> snmpList = new ArrayList<SNMPTriple>();
    
    for (TableEvent event : events) {
      if(event.isError()) {
     	 logger.warning("SNMP event error: "+event.getErrorMessage());
     	 continue;
           //throw new RuntimeException(event.getErrorMessage());
      }
      for(VariableBinding vb: event.getColumns()) {
   	   String key = vb.getOid().toString();
   	   String value = vb.getVariable().toString();
   	 snmpList.add(new SNMPTriple(key, "", value));
      }
    }
 return snmpList;
}
 
开发者ID:yahoo,项目名称:mysql_perf_analyzer,代码行数:24,代码来源:SNMPClient.java

示例2: getDiskIndex

import org.snmp4j.util.TableEvent; //导入方法依赖的package包/类
private int getDiskIndex(String device) throws IOException {

      TableUtils tUtils = new TableUtils(snmp, new DefaultPDUFactory());
      
      logger.fine("Query "+this.address+" for disk data: "+device);
       @SuppressWarnings("unchecked")
       List<TableEvent> events = tUtils.getTable(getTarget(), new OID[]{new OID("."+DISK_TABLE_DEVICE_OID)}, null, null);

       for (TableEvent event : events) {
         if(event.isError()) {
        	 logger.warning("SNMP event error: "+event.getErrorMessage());
        	 continue;
              //throw new RuntimeException(event.getErrorMessage());
         }
         for(VariableBinding vb: event.getColumns()) {
      	   String key = vb.getOid().toString();
      	   String value = vb.getVariable().toString();
      	   if(value!=null && value.equals(device))
      	   {
      	       logger.fine("Find device OID entry: "+key);
      	         int index = -1;
      	         String[] strs = key.split("\\.");
      	         try
      	         {
      	        	 index = Integer.parseInt(strs[strs.length-1]);
      	         }catch(Exception ex){}
      	         return index;
      	   }
         }
       }
       return -1;
 }
 
开发者ID:yahoo,项目名称:mysql_perf_analyzer,代码行数:33,代码来源:SNMPClient.java

示例3: getNetIfIndexes

import org.snmp4j.util.TableEvent; //导入方法依赖的package包/类
private Map<Integer, String> getNetIfIndexes(String device) throws IOException {
  Map<Integer, String> ifMaps = new HashMap<Integer, String> ();
		
     TableUtils tUtils = new TableUtils(snmp, new DefaultPDUFactory());
     
     logger.fine("Query "+this.address+" for network interface, excluding lo");
      @SuppressWarnings("unchecked")
      List<TableEvent> events = tUtils.getTable(getTarget(), new OID[]{new OID("."+IF_TABLE_DEVICE_OID)}, null, null);

      for (TableEvent event : events) {
        if(event.isError()) {
       	 logger.warning("SNMP event error: "+event.getErrorMessage());
       	 continue;
             //throw new RuntimeException(event.getErrorMessage());
        }
        for(VariableBinding vb: event.getColumns()) {
     	   String key = vb.getOid().toString();
     	   String value = vb.getVariable().toString();
     	   if(device!=null && !device.isEmpty() && !value.equalsIgnoreCase(device))
     		   continue;
     	   if(value!=null && !value.equalsIgnoreCase("lo"))
     	   {
     	       logger.fine("Find device OID entry: "+key);
     	         int index = -1;
     	         String[] strs = key.split("\\.");
     	         try
     	         {
     	        	 index = Integer.parseInt(strs[strs.length-1]);
     	        	 ifMaps.put(index, value);
     	         }catch(Exception ex){}
     	   }
        }
      }
      return ifMaps;
}
 
开发者ID:yahoo,项目名称:mysql_perf_analyzer,代码行数:36,代码来源:SNMPClient.java

示例4: getProcessIndexes

import org.snmp4j.util.TableEvent; //导入方法依赖的package包/类
/**
  * Query index for given process name. Note the parameter only provides 128 characters,
  * so it could be difficult for us to differentiate each other if multi processes with same name exist.
  * So we will return this list and use the sum from all processes for our metrics
  * @param process
  * @return
  * @throws IOException
  */
 private List<Integer> getProcessIndexes(String process) throws IOException {
  List<Integer> indexes = new ArrayList<Integer> ();
     if(process == null || process.isEmpty())return indexes;

     TableUtils tUtils = new TableUtils(snmp, new DefaultPDUFactory());
     logger.fine("Query "+this.address+" for process " + process);
      @SuppressWarnings("unchecked")
      List<TableEvent> events = tUtils.getTable(getTarget(), new OID[]{new OID("."+PROCESS_TABLE_OID)}, null, null);

      for (TableEvent event : events) {
        if(event.isError()) {
       	 logger.warning("SNMP event error: "+event.getErrorMessage());
       	 continue;
             //throw new RuntimeException(event.getErrorMessage());
        }
        for(VariableBinding vb: event.getColumns()) {
     	   String key = vb.getOid().toString();
     	   String value = vb.getVariable().toString();
     	   if(process!=null && !process.isEmpty() && !value.equalsIgnoreCase(process))
     		   continue;
     	   if(value!=null)
     	   {
     	       logger.fine("Find process OID entry: "+key);
     	       int index = -1;
     	       String[] strs = key.split("\\.");
     	       try
     	       {
     	    	   index = Integer.parseInt(strs[strs.length-1]);
     	    	   indexes.add(index);
     	       }catch(Exception ex){}
     	   }
        }
      }
      return indexes;
}
 
开发者ID:yahoo,项目名称:mysql_perf_analyzer,代码行数:44,代码来源:SNMPClient.java

示例5: getDiskIndexes

import org.snmp4j.util.TableEvent; //导入方法依赖的package包/类
private Map<Integer, String> getDiskIndexes() throws IOException {
Map<Integer, String> diskIndexes = new HashMap<Integer, String>();
      TableUtils tUtils = new TableUtils(snmp, new DefaultPDUFactory());
      
      logger.fine("Query "+this.address+" for disk oids");
       @SuppressWarnings("unchecked")
       List<TableEvent> events = tUtils.getTable(getTarget(), new OID[]{new OID("."+DISK_TABLE_DEVICE_OID)}, null, null);

       for (TableEvent event : events) {
         if(event.isError()) {
        	 logger.warning("SNMP event error: "+event.getErrorMessage());
        	 continue;
              //throw new RuntimeException(event.getErrorMessage());
         }
         
         for(VariableBinding vb: event.getColumns()) {
      	   String key = vb.getOid().toString();
      	   String value = vb.getVariable().toString();
      	   if(value == null || value.isEmpty() || value.startsWith("dm-"))continue;//ignore dm disk
      	   if(value.startsWith("ram") || value.startsWith("loop") )continue;//ignore dm disk
      	   char c = value.charAt(value.length()-1);
      	   if(c>='0' && c<='9' )
      	   {
      		   if(value.startsWith("sd"))
      		   {
      			   if(value.length()>2)
      			   {
      				   char d = value.charAt(2);
      				   if(d>='a' && d<='z')continue;
      			   }
      		   }
      	   }
      	   logger.fine("Find device OID entry: "+key);
      	   int index = -1;
      	   String[] strs = key.split("\\.");
      	   try
      	   {
      		   index = Integer.parseInt(strs[strs.length-1]);
      	       diskIndexes.put(index,  value); 	 
      	   }catch(Exception ex){}
      	}
       }
       return diskIndexes;
 }
 
开发者ID:yahoo,项目名称:mysql_perf_analyzer,代码行数:45,代码来源:SNMPClient.java


注:本文中的org.snmp4j.util.TableEvent.isError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。