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


Java Variable.toLong方法代码示例

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


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

示例1: asLong

import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
@Override
public long asLong() {
  Variable variable = getVariable();
  if (variable == null) {
    return 0;
  }
  return variable.toLong();
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:9,代码来源:Snmp4jVarbind.java

示例2: toObject

import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
private static Object toObject(Variable variable) {
  if (variable instanceof OID) {
    return ((OID) variable).toIntArray();
  }
  else if (variable instanceof OctetString) {
    return ((OctetString) variable).toByteArray();
  }
  else if (variable instanceof IpAddress) {
    return ((IpAddress) variable).toByteArray();
  }
  else {
    return variable.toLong();
  }
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:15,代码来源:Snmp4jVarbind.java

示例3: getChannelInfo

import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
protected Channel getChannelInfo(OIDHolder oidh, Map<OID, Variable> vars){
		Channel retVal = null;
		Variable var = vars.get(oidh.oid);
		String name = oidh.getName();
		long value = -1;
		if(var instanceof Null){
			String tmp = var.toString();
			retVal = new LongChannel(name, Unit.BANDWIDTH, -1);
			String logString = "OID["+oidh.oidString+"] "+name+" returned: "+tmp;
//			System.out.println(logString);
            Logger.log(logString );
//			retVal.
		} else {
			value = var.toLong();
		}
//			public enum SNMPDataResponseType {STRING,INT,LONG,FLOAT,TICKS,OCTIN,OCTOUT,COUNT};
			switch(oidh.dataType){
			case INT:
			case LONG:
			case OCTIN:
			case OCTOUT:
				retVal = new LongChannel(name, Unit.BANDWIDTH, value, Channel.Mode.COUNTER);
				break;
			case TICKS:
				retVal = new LongChannel(name, Unit.TIME_SECONDS, (value < 0 ? value : (long)(value/100)));
				break;
			case COUNT:
				retVal = new LongChannel(name, Unit.COUNT, value);
				break;
//			case STRING:
//				retVal = new LongChannel(name, "BytesBandwidth", var.toLong());
//				break;
//		lchannel  = new LongChannel("Packet Loss", "Percent", stats.loss);
			
		}
		return retVal;
	}
 
开发者ID:PRTG,项目名称:JMXMiniProbe,代码行数:38,代码来源:SNMPSensorSubInterface.java

示例4: getChannel

import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
public Channel getChannel(Variable var){
		Channel retVal = null;
		long value = -1;
		if(var instanceof Null){
			String tmp = var.toString();
			retVal = new LongChannel(getName(), Unit.BANDWIDTH, -1);
			String logString = "OID["+getObject()+"] "+getName()+" returned: "+tmp;
			retVal.setMessage(logString);
			retVal.setWarning(1);
            Logger.log(logString );
		} else {
			SNMPDataType type = getDataType();
			String valueStr = var.toString();
//			var.
			switch(type){
				case FLOAT:
					{
						float valueFloat = Float.parseFloat(valueStr);
						retVal = super.getChannel(valueFloat);
					}
					break;
				case OTHER:
					setDataType(SNMPUtil.getDataType(var));
				case LONG:
				case INT:
				default:
					retVal = super.getChannel(var.toLong());
			}
		}
		if(retVal != null && retVal.getUnit() == Unit.CUSTOM){
			retVal.setCustomunit(getCustomUnit());
		}
		return retVal;
	}
 
开发者ID:PRTG,项目名称:JMXMiniProbe,代码行数:35,代码来源:SNMPEntry.java

示例5: asMeasurement

import org.snmp4j.smi.Variable; //导入方法依赖的package包/类
/**
 * Converts an SNMP variable into an RHQ measurement value.
 * This includes mapping integer values into string constants,
 * converting strings to doubles, etc.
 *
 * @param request measurement request
 * @param variable SNMP variable
 * @return data as a trait or numeric (or complex)
 */
private MeasurementData asMeasurement(MeasurementScheduleRequest request, Variable variable) {
    if (variable == null)
        throw new NullPointerException("variable");
    if (request == null)
        throw new NullPointerException("request");
    DataType dataType = request.getDataType();
    String name = request.getName();
    if (variable instanceof Integer32) {
        int i = ((Integer32)variable).toInt();
        Map<Integer, String> mapping = index.getMapping(name);
        if (mapping != null && !mapping.isEmpty()) {
            return new MeasurementDataTrait(request, mapping.get(i));
        }
    }
    if (dataType == DataType.TRAIT) {
        return new MeasurementDataTrait(request, variable.toString());
    }
    if (variable instanceof OctetString && dataType == DataType.MEASUREMENT) {
        // interpret as String
        return new MeasurementDataNumeric(request, new Double(variable.toString()));
    }
    if (variable instanceof TimeTicks) {
        long ms = ((TimeTicks)variable).toMilliseconds();
        return new MeasurementDataNumeric(request, (double)ms);
    }
    return new MeasurementDataNumeric(request, (double)variable.toLong());
}
 
开发者ID:genman,项目名称:rhq-plugins,代码行数:37,代码来源:MibComponent.java


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