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


Java UnsignedInteger32类代码示例

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


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

示例1: sendPDU

import org.snmp4j.smi.UnsignedInteger32; //导入依赖的package包/类
/**
 * 向接收器发送Trap 信息
 * 
 * @throws IOException
 */
public void sendPDU() throws IOException {
	PDU pdu = new PDU();
	pdu.add(new VariableBinding(
			new OID(".1.3.6.1.2.1.1.1.0"),
			new OctetString("SNMP Trap Test.see more:http://www.micmiu.com")));
	pdu.add(new VariableBinding(SnmpConstants.sysUpTime, new TimeTicks(
			new UnsignedInteger32(System.currentTimeMillis() / 1000)
					.getValue())));
	pdu.add(new VariableBinding(SnmpConstants.snmpTrapOID, new OID(
			".1.3.6.1.6.3.1.1.4.3")));

	// 向Agent发送PDU
	pdu.setType(PDU.TRAP);
	snmp.send(pdu, target);
	System.out.println("----> Trap Send END <----");
}
 
开发者ID:micmiu,项目名称:snmp-tutorial,代码行数:22,代码来源:SnmpTrapSendDemo.java

示例2: getDataType

import org.snmp4j.smi.UnsignedInteger32; //导入依赖的package包/类
public static SNMPDataType getDataType(Variable var){
		SNMPDataType retVal = SNMPDataType.INT;
/*		
 * 	org.snmp4j.smi.Variable implementations
 * 		AbstractVariable, BitString, 
 * 		Counter32, Counter64, Gauge32, Integer32, UnsignedInteger32, 
 * 		TimeTicks, 
 * 		OctetString,
 * 		GenericAddress, IpAddress, Null, OID, Opaque, SMIAddress, SshAddress, TcpAddress, TlsAddress, 
 * 		TransportIpAddress, TsmSecurityParameters, UdpAddress, VariantVariable
 * 	SNMPDataType: STRING,INT,LONG,FLOAT,TICKS,OCTIN,OCTOUT,COUNT, OTHER
 */
		if(var instanceof TimeTicks) {
			retVal = SNMPDataType.TICKS;
		} else if(var instanceof Counter64 || var instanceof Counter32) {
			retVal = SNMPDataType.COUNT;
		} else if(var instanceof Integer32 || var instanceof UnsignedInteger32) {
			retVal = SNMPDataType.COUNT;
		} else if(var instanceof Gauge32) {
			retVal = SNMPDataType.COUNT;
		} else if(var instanceof OctetString) {
			retVal = SNMPDataType.STRING;
		}
		return retVal;
	}
 
开发者ID:PRTG,项目名称:JMXMiniProbe,代码行数:26,代码来源:SNMPUtil.java

示例3: toLong

import org.snmp4j.smi.UnsignedInteger32; //导入依赖的package包/类
public long toLong() {
    switch (m_value.getSyntax()) {
    case SMIConstants.SYNTAX_COUNTER64:
        return ((Counter64)m_value).getValue();
    case SMIConstants.SYNTAX_INTEGER:
        return ((Integer32)m_value).getValue();
    case SMIConstants.SYNTAX_COUNTER32:
    case SMIConstants.SYNTAX_TIMETICKS:
    case SMIConstants.SYNTAX_UNSIGNED_INTEGER32:
        return ((UnsignedInteger32)m_value).getValue();
    case SMIConstants.SYNTAX_OCTET_STRING:
        return (convertStringToLong());
    default:
        return Long.parseLong(m_value.toString());
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:17,代码来源:Snmp4JValue.java

示例4: toBigInteger

import org.snmp4j.smi.UnsignedInteger32; //导入依赖的package包/类
public BigInteger toBigInteger() {
    switch (m_value.getSyntax()) {
    case SMIConstants.SYNTAX_COUNTER64:
        final Counter64 cnt = (Counter64)m_value;
        if (cnt.getValue() > 0) {
            return BigInteger.valueOf(cnt.getValue());
        } else {
            return new BigInteger(cnt.toString());
        }
    case SMIConstants.SYNTAX_INTEGER:
        return BigInteger.valueOf(((Integer32)m_value).getValue());
    case SMIConstants.SYNTAX_COUNTER32:
    case SMIConstants.SYNTAX_TIMETICKS:
    case SMIConstants.SYNTAX_UNSIGNED_INTEGER32:
        return BigInteger.valueOf(((UnsignedInteger32)m_value).getValue());
    default:
        return new BigInteger(m_value.toString());
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:20,代码来源:Snmp4JValue.java

示例5: testModify

import org.snmp4j.smi.UnsignedInteger32; //导入依赖的package包/类
@Test
public void testModify() throws Exception {
    final ModifierProperties modifierProperties = new ModifierProperties();
    modifierProperties.put("minimum", 0);
    modifierProperties.put("maximum", 3000);
    modifierProperties.put("minimumStep", 1);
    modifierProperties.put("maximumStep", 10);

    final UnsignedInteger32Modifier modifier = new UnsignedInteger32Modifier();
    modifier.init(modifierProperties);

    final UnsignedInteger32 unsignedInteger32 = new UnsignedInteger32(0);
    assertEquals(unsignedInteger32.getValue(), 0);

    final UnsignedInteger32 modifiedVariable = modifier.modify(unsignedInteger32);
    assertNotEquals(modifiedVariable.getValue(), 0);
}
 
开发者ID:1and1,项目名称:snmpman,代码行数:18,代码来源:UnsignedInteger32ModifierTest.java

示例6: newVarbind

import org.snmp4j.smi.UnsignedInteger32; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Varbind newVarbind(String oid, Object value) {
  VariableBinding varbind = resolveOid(oid);
  int syntax = mib.syntaxForObject(varbind.getOid().toString());
  Variable variable = AbstractVariable.createFromSyntax(syntax);
  if (variable instanceof Integer32) {
    ((Integer32) variable).setValue(((Number) value).intValue());
  }
  else if (variable instanceof UnsignedInteger32) {
    ((UnsignedInteger32) variable).setValue(Math.abs(((Number) value).longValue()));
  }
  else if (variable instanceof Counter64) {
    ((Counter64) variable).setValue(((Number) value).longValue());      
  }
  else if (variable instanceof OctetString) {
    if (value instanceof String) {
      ((OctetString) variable).setValue((String) value);
    }
    else {
      ((OctetString) variable).setValue((byte[]) value);
    }
  }
  else if (variable instanceof OID) {
    if (value instanceof String) {
      ((OID) variable).setValue((String) value);
    }
    else {
      ((OID) variable).setValue((int[]) value);
    }
  }
  else {
    throw new IllegalStateException("unrecognized type");
  }

  varbind.setVariable(variable);
  return varbindFactory.newVarbind(varbind);
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:41,代码来源:Snmp4jContext.java

示例7: newVariable

import org.snmp4j.smi.UnsignedInteger32; //导入依赖的package包/类
static Variable newVariable(int syntax, Object value) {
  Variable variable = AbstractVariable.createFromSyntax(syntax);
  if (variable instanceof Integer32) {
    ((Integer32) variable).setValue(((Number) value).intValue());
  }
  else if (variable instanceof UnsignedInteger32) {
    ((UnsignedInteger32) variable).setValue(Math.abs(((Number) value).longValue()));
  }
  else if (variable instanceof Counter64) {
    ((Counter64) variable).setValue(((Number) value).longValue());
  }
  else if (variable instanceof OctetString) {
    if (value instanceof String) {
      ((OctetString) variable).setValue((String) value);
    }
    else {
      ((OctetString) variable).setValue((byte[]) value);
    }
  }
  else if (variable instanceof OID) {
    if (value instanceof String) {
      ((OID) variable).setValue((String) value);
    }
    else {
      ((OID) variable).setValue((int[]) value);
    }
  }
  else {
    throw new IllegalStateException("unrecognized type");
  }
  return variable;
}
 
开发者ID:soulwing,项目名称:tnm4j,代码行数:33,代码来源:Snmp4jVarbind.java

示例8: toInt

import org.snmp4j.smi.UnsignedInteger32; //导入依赖的package包/类
public int toInt() {
    switch (m_value.getSyntax()) {
    case SMIConstants.SYNTAX_COUNTER64:
        return (int)((Counter64)m_value).getValue();
    case SMIConstants.SYNTAX_INTEGER:
        return ((Integer32)m_value).getValue();
    case SMIConstants.SYNTAX_COUNTER32:
    case SMIConstants.SYNTAX_TIMETICKS:
    case SMIConstants.SYNTAX_UNSIGNED_INTEGER32:
        return (int)((UnsignedInteger32)m_value).getValue();
    default:
        return Integer.parseInt(m_value.toString());
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:15,代码来源:Snmp4JValue.java

示例9: createPDU

import org.snmp4j.smi.UnsignedInteger32; //导入依赖的package包/类
private PDU createPDU(SnmpTrapInfo snmpTrapInfo) {
    PDU trap = new PDU();
    trap.setType(PDU.TRAP);

    int alertType = snmpTrapInfo.getAlertType() + 1;
    if (alertType > 0) {
        long sysUpTimeTicks = ManagementFactory.getRuntimeMXBean().getUptime() / 10;
        trap.add(new VariableBinding(SnmpConstants.sysUpTime, new TimeTicks(sysUpTimeTicks)));
        trap.add(new VariableBinding(SnmpConstants.snmpTrapOID, getOID(CsSnmpConstants.TRAPS_PREFIX + alertType)));
        if (snmpTrapInfo.getDataCenterId() != 0) {
            trap.add(new VariableBinding(getOID(CsSnmpConstants.DATA_CENTER_ID), new UnsignedInteger32(snmpTrapInfo.getDataCenterId())));
        }

        if (snmpTrapInfo.getPodId() != 0) {
            trap.add(new VariableBinding(getOID(CsSnmpConstants.POD_ID), new UnsignedInteger32(snmpTrapInfo.getPodId())));
        }

        if (snmpTrapInfo.getClusterId() != 0) {
            trap.add(new VariableBinding(getOID(CsSnmpConstants.CLUSTER_ID), new UnsignedInteger32(snmpTrapInfo.getClusterId())));
        }

        if (snmpTrapInfo.getMessage() != null) {
            trap.add(new VariableBinding(getOID(CsSnmpConstants.MESSAGE), new OctetString(snmpTrapInfo.getMessage())));
        } else {
            throw new CloudRuntimeException(" What is the use of alert without message ");
        }

        if (snmpTrapInfo.getGenerationTime() != null) {
            trap.add(new VariableBinding(getOID(CsSnmpConstants.GENERATION_TIME), new OctetString(snmpTrapInfo.getGenerationTime().toString())));
        } else {
            trap.add(new VariableBinding(getOID(CsSnmpConstants.GENERATION_TIME)));
        }
    } else {
        throw new CloudRuntimeException(" Invalid alert Type ");
    }

    return trap;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:39,代码来源:SnmpHelper.java

示例10: removeCrossConnect

import org.snmp4j.smi.UnsignedInteger32; //导入依赖的package包/类
private boolean removeCrossConnect(CrossConnectFlowRule xc) {

        int channel = toChannel(xc.ochSignal());

        // Create the PDU object
        PDU pdu = new PDU();
        pdu.setType(PDU.SET);

        // Disable the channel
        OID ctrlChannelState = new OID(CTRL_CHANNEL_STATE + (xc.isAddRule() ? "1." : "2.") + channel);
        pdu.add(new VariableBinding(ctrlChannelState, new Integer32(OUT_OF_SERVICE)));

        // Put cross connect back into default port 1
        OID ctrlChannelAddDropPortIndex = new OID(CTRL_CHANNEL_ADD_DROP_PORT_INDEX +
                (xc.isAddRule() ? "1." : "2.") + channel);
        pdu.add(new VariableBinding(ctrlChannelAddDropPortIndex,
                new UnsignedInteger32(DISABLE_CHANNEL_ADD_DROP_PORT_INDEX)));

        // Put port/channel back to open loop
        OID ctrlChannelMode = new OID(CTRL_CHANNEL_MODE + (xc.isAddRule() ? "1." : "2.") + channel);
        pdu.add(new VariableBinding(ctrlChannelMode, new Integer32(OPEN_LOOP)));

        // Add rules are set to target power, drop rules are attenuated
        if (xc.isAddRule()) {
            OID ctrlChannelTargetPower = new OID(CTRL_CHANNEL_TARGET_POWER + "1." + channel);
            pdu.add(new VariableBinding(ctrlChannelTargetPower, new Integer32(DISABLE_CHANNEL_TARGET_POWER)));
        } else {
            OID ctrlChannelAbsoluteAttenuation = new OID(CTRL_CHANNEL_ABSOLUTE_ATTENUATION + "2." + channel);
            pdu.add(new VariableBinding(
                    ctrlChannelAbsoluteAttenuation, new UnsignedInteger32(DISABLE_CHANNEL_ABSOLUTE_ATTENUATION)));
        }

        try {
            ResponseEvent response = snmp.set(pdu);

            // TODO: parse response
        } catch (IOException e) {
            log.error("Failed to remove cross connect, unable to connect to device: ", e);
            return false;
        }

        return true;
    }
 
开发者ID:shlee89,项目名称:athena,代码行数:44,代码来源:LumentumFlowRuleProgrammable.java

示例11: cast

import org.snmp4j.smi.UnsignedInteger32; //导入依赖的package包/类
@Override
protected UnsignedInteger32 cast(long value) {
    return new UnsignedInteger32(value);
}
 
开发者ID:1and1,项目名称:snmpman,代码行数:5,代码来源:UnsignedInteger32Modifier.java


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