• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Counter32类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getDataType

import org.snmp4j.smi.Counter32; //导入依赖的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


示例2: testCounter32Variable

import org.snmp4j.smi.Counter32; //导入依赖的package包/类
@Test
public void testCounter32Variable() throws InterruptedException {
	String expectedOid = "1.3.6.1.2.1.4.3.0";
	Number expectedValue = 1588007;
	String expectedSource = "www.myweb.com";
	String expectedMetricId = "MY_FAVORITE_METRIC";
	
	VariableBinding vb = new VariableBinding();
	Counter32 v = new Counter32();
	v.setValue(expectedValue.longValue());
	
	vb.setOid(new OID(expectedOid));
	vb.setVariable(v);

	SnmpPollerConfiguration config = getSnmpPollerConfiguration(
			expectedSource,expectedMetricId,expectedOid);
	out.expectedMessageCount(1);
	in.sendBodyAndHeaders(vb,setScriptHeaders(SNMP_TO_MEASURE_SCRIPT,config));
	out.assertIsSatisfied();
	
	Measurement m = getMeasurement(out);
	assertNotNull("check event for null",m);
	assertEquals("check source",expectedSource,m.getSource());
	assertEquals("check metric",expectedMetricId,m.getMetric());
	assertEquals("check measure",v.getValue(),m.getMeasure().intValue());
}
 
开发者ID:boundary,项目名称:boundary-event-sdk,代码行数:27,代码来源:SnmpToMeasureTest.java


示例3: getVariableBindings

import org.snmp4j.smi.Counter32; //导入依赖的package包/类
@Override
public Map<OID, Variable> getVariableBindings(final OctetString context, final OID queryOID) {
    if (queryOID != null && context != null && context.getValue().length != 0) {
        if (!queryOID.toString().isEmpty() && !context.toString().isEmpty() && communityContextMapping.containsKey(Long.parseLong(context.toString()))) {
            return new TreeMap<OID, Variable>() {{
                put(queryOID, new Counter32(communityContextMapping.get(Long.parseLong(context.toString()))));
            }};
        }
    } else if (queryOID != null) {
        return new TreeMap<OID, Variable>() {{
            put(queryOID, modify(null));
        }};

    }
    return new TreeMap<>();
}
 
开发者ID:1and1,项目名称:snmpman,代码行数:17,代码来源:CommunityIndexCounter32Modifier.java


示例4: testModify

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

    final Modifier modifier = new Modifier(".1.3.6.*", "com.oneandone.snmpman.configuration.modifier.Counter32Modifier", modifierProperties);

    final Counter32 counter32 = new Counter32(0L);
    assertEquals(counter32.getValue(), 0L);

    final Variable modifiedVariable = modifier.modify(counter32);
    assertTrue(modifiedVariable instanceof Counter32);
    assertNotEquals(((Counter32) modifiedVariable).getValue(), 0L);
}
 
开发者ID:1and1,项目名称:snmpman,代码行数:19,代码来源:ModifierTest.java


示例5: testModify

import org.snmp4j.smi.Counter32; //导入依赖的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 Counter32Modifier modifier = new Counter32Modifier();
    modifier.init(modifierProperties);

    final Counter32 counter32 = new Counter32(0);
    assertEquals(counter32.getValue(), 0);

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


示例6: get

import org.snmp4j.smi.Counter32; //导入依赖的package包/类
@Override
public Map<OID, Variable> get(Collection<OID> oids) throws IOException {
    Map<OID, Variable> map = new LinkedHashMap<OID, Variable>();
    if (oids.size() == 2) {
        Iterator<OID> i = oids.iterator();
        map.put(i.next(), new Counter32(lo));
        map.put(i.next(), new Counter32(hi));
    }
    return map;
}
 
开发者ID:genman,项目名称:rhq-plugins,代码行数:11,代码来源:MibTableComponentExtTest.java


示例7: generateRowData

import org.snmp4j.smi.Counter32; //导入依赖的package包/类
private static Variable[] generateRowData(List<MyMibNode> columnNodes) {
	Variable[] rowValues = new Variable[columnNodes.size()];
	for (int i = 0; i < columnNodes.size(); i++) {
		MyMibNode columnNode = columnNodes.get(i);
		String rule = columnNode.getRule();
		
		if("Counter32".equals(columnNode.getType())){
			rowValues[i] = new Counter32(Long.parseLong("".equals(rule) ? TestDataUtil.parseInnerMethod("${randomInt(1, 512)}") : TestDataUtil.parseInnerMethod(rule)));
		}
		
		if("Gauge32".equals(columnNode.getType())){
			rowValues[i] = new Gauge32(Long.parseLong("".equals(rule) ? TestDataUtil.parseInnerMethod("${randomInt(1, 512)}") : TestDataUtil.parseInnerMethod(rule)));
		}
		
		if("Integer32".equals(columnNode.getType()) || "INTEGER".equals(columnNode.getType())){
			rowValues[i] = new Integer32(Integer.parseInt("".equals(rule) ? TestDataUtil.parseInnerMethod("${randomInt(1, 512)}") : TestDataUtil.parseInnerMethod(rule)));
		}
		
		if("TimeTicks".equals(columnNode.getType())){
			rowValues[i] = new TimeTicks();
		}
		
		if("Unsigned32".equals(columnNode.getType())){
			rowValues[i] = new Integer32(Integer.parseInt("".equals(rule) ? TestDataUtil.parseInnerMethod("${randomInt(1, 512)}") : TestDataUtil.parseInnerMethod(rule)));
		}
		
		if("IpAddress".equals(columnNode.getType())){
			rowValues[i] = new IpAddress("10.10.10.10");
		}
		
		if("OCTET STRING".equals(columnNode.getType())){
			rowValues[i] = new OctetString("".equals(rule) ? TestDataUtil.parseInnerMethod("${randomString(5)}") : TestDataUtil.parseInnerMethod(rule));
		}
	}
	return rowValues;
}
 
开发者ID:wangzijian777,项目名称:snmpTool,代码行数:37,代码来源:MOTableGenerator.java


示例8: modify

import org.snmp4j.smi.Counter32; //导入依赖的package包/类
@Override
public final Counter32 modify(final Counter32 variable) {
    if (variable == null) {
        return new Counter32(0);
    }
    return variable;
}
 
开发者ID:1and1,项目名称:snmpman,代码行数:8,代码来源:CommunityIndexCounter32Modifier.java


示例9: testModify

import org.snmp4j.smi.Counter32; //导入依赖的package包/类
@Test
public void testModify() throws Exception {
    final CommunityIndexCounter32Modifier modifier = new CommunityIndexCounter32Modifier();
    modifier.init(modifierProperties);

    final Counter32 counter32 = new Counter32(contextValue1);
    assertEquals(counter32.getValue(), contextValue1);

    final Counter32 modifiedVariable = modifier.modify(counter32);
    assertEquals(modifiedVariable.getValue(), contextValue1);

    final Counter32 modifiedVariable2 = modifier.modify(null);
    assertEquals(modifiedVariable2, new Counter32(0L));
}
 
开发者ID:1and1,项目名称:snmpman,代码行数:15,代码来源:CommunityIndexCounter32ModifierTest.java


示例10: testGetVariableBindings

import org.snmp4j.smi.Counter32; //导入依赖的package包/类
@Test
public void testGetVariableBindings() throws Exception {
    final CommunityIndexCounter32Modifier modifier = new CommunityIndexCounter32Modifier();
    modifier.init(modifierProperties);

    final OctetString context1 = new OctetString("20");
    final OID queryOID1 = new OID(oid);
    final Map<OID, Variable> variableBindings1 = modifier.getVariableBindings(context1, queryOID1);

    assertEquals(variableBindings1.size(), 1);
    assertEquals(variableBindings1.get(queryOID1), new Counter32(150L));

    final OctetString context2 = new OctetString("23");
    final OID queryOID2 = new OID("1.3.6");
    final Map<OID, Variable> variableBindings2 = modifier.getVariableBindings(context2, queryOID2);

    assertEquals(variableBindings2.size(), 0, "bindings with not initialized context should be empty");

    final OctetString context3 = null;
    final OID queryOID3 = new OID("1.3.6");
    final Map<OID, Variable> variableBindings3 = modifier.getVariableBindings(context3, queryOID3);

    assertEquals(variableBindings3.size(), 1);
    assertEquals(variableBindings3.get(queryOID3), new Counter32(0L), "bindings with null context should be 0");

    final OctetString context4 = new OctetString();
    final OID queryOID4 = new OID("1.3.6");
    final Map<OID, Variable> variableBindings4 = modifier.getVariableBindings(context4, queryOID4);

    assertEquals(variableBindings4.size(), 1);
    assertEquals(variableBindings4.get(queryOID4), new Counter32(0L), "bindings with empty context should be 0");

    final OctetString context5 = new OctetString("20");
    final OID queryOID5 = null;
    final Map<OID, Variable> variableBindings5 = modifier.getVariableBindings(context5, queryOID5);

    assertEquals(variableBindings5.size(), 0, "bindings with null query OID should be empty");
}
 
开发者ID:1and1,项目名称:snmpman,代码行数:39,代码来源:CommunityIndexCounter32ModifierTest.java


示例11: castToLong

import org.snmp4j.smi.Counter32; //导入依赖的package包/类
public static long castToLong(Variable variable) {
	switch (variable.getSyntax()) {
	case SMIConstants.SYNTAX_GAUGE32:
		return ((Gauge32) variable).toLong();
	case SMIConstants.SYNTAX_COUNTER32:
		return ((Counter32) variable).toLong();
	case SMIConstants.SYNTAX_COUNTER64:
		return ((Counter64) variable).toLong();
	case SMIConstants.SYNTAX_TIMETICKS:
		return ((TimeTicks) variable).toLong();
	default:
		throw new IllegalArgumentException("Unsupported cast from "
				+ variable.getSyntaxString() + " to long");
	}
}
 
开发者ID:ccascone,项目名称:JNetMan,代码行数:16,代码来源:SnmpHelper.java


示例12: updateCounter32Value

import org.snmp4j.smi.Counter32; //导入依赖的package包/类
public void updateCounter32Value(String oid, int val) {
    updateValue(oid, new Counter32(val));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:4,代码来源:MockSnmpAgent.java


示例13: testGetNextMultipleVarbinds

import org.snmp4j.smi.Counter32; //导入依赖的package包/类
@Test
public void testGetNextMultipleVarbinds() throws Exception {
	
	request(".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.11").andExpect(".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.11.1", SMIConstants.SYNTAX_COUNTER32, new Counter32(128350705));

	doGetNext();

	m_agent.getUsm().setEngineBoots(15);
	
	byte[] hexString = new byte[] { (byte)0x11, (byte)0x00, (byte)0x33, (byte)0x44, (byte)0x55, (byte)0x66, (byte)0x77, (byte)0x88 };
	request(".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.11").andExpect(".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.11.1", SMIConstants.SYNTAX_COUNTER32, new Counter32(128350705));
	request(".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.12").andExpect(".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.12.1", SMIConstants.SYNTAX_COUNTER32, new Counter32(3180401803L));
	request(".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.34").andExpect(".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.34.1", SMIConstants.SYNTAX_OCTET_STRING, new OctetString(hexString));
	
	doGetNext();

    // This statement breaks the internal state of the SNMP4J agent
    // m_agent.getUsm().setLocalEngine(m_agent.getUsm().getLocalEngineID(), 15, 200);
    m_agent.getUsm().removeEngineTime(m_usm.getLocalEngineID());
    m_usm.removeEngineTime(m_agent.getUsm().getLocalEngineID());

	request(".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.11.1").andExpect(".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.11.2", SMIConstants.SYNTAX_COUNTER32, new Counter32(1047537430));
	doGetNext();

}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:26,代码来源:BrocadeMibTest.java


示例14: getCounter32

import org.snmp4j.smi.Counter32; //导入依赖的package包/类
public SnmpValue getCounter32(long val) {
    return new Snmp4JValue(new Counter32(val));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:4,代码来源:Snmp4JValueFactory.java


示例15: createMpcRdStatsTable

import org.snmp4j.smi.Counter32; //导入依赖的package包/类
/**
 * mpcRdStatsTable
 **/
private static DefaultMOTable createMpcRdStatsTable() {
	MOTableSubIndex[] subIndexes =
		new MOTableSubIndex[] { new MOTableSubIndex(SMIConstants.SYNTAX_INTEGER) };
	MOTableIndex indexDef = new MOTableIndex(subIndexes, false);
	MOColumn[] columns = new MOColumn[4];
	int c = 0;
	columns[c++] =
		new MOColumn(c, SMIConstants.SYNTAX_INTEGER,
				new MOAccessImpl(0));     // mpcRdStatGroupID -> not-accessible
	
	columns[c++] =
		new MOMutableColumn(c, SMIConstants.SYNTAX_INTEGER,     // mpcRdStatReset
				MOAccessImpl.ACCESS_READ_WRITE, null);
	
	columns[c++] =
		new MOColumn(c, SMIConstants.SYNTAX_COUNTER32,
				MOAccessImpl.ACCESS_READ_ONLY);// mpcRdStatNumAutoSwitchovers	
	
	columns[c++] =
		new MOColumn(c, SMIConstants.SYNTAX_COUNTER32,
				MOAccessImpl.ACCESS_READ_ONLY);     // mpcRdStatNumManualSwitchovers
	

	DefaultMOTable ifTable =
		new DefaultMOTable(new OID("1.3.6.1.4.1.7569.1.2.1.62.1"), indexDef, columns);
	MOMutableTableModel model = (MOMutableTableModel) ifTable.getModel();


	int count = 0;
	int[] list = {1,2,3,4,5,6};
	for (int element : list) {
		String elemVal = "";
		
		Variable[] rowValues1 = new Variable[] {
				new Integer32(324),
				new Integer32(765),
				new Counter32(33),
				new Counter32(49)
		};
		model.addRow(new DefaultMOMutableRow2PC(new OID(elemVal.valueOf(element)), rowValues1));	
		count++;
	}

	ifTable.setVolatile(true);
	return ifTable;
}
 
开发者ID:wangzijian777,项目名称:snmpTool,代码行数:50,代码来源:MOTableGenerator.java


示例16: cast

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


示例17: testGetNext

import org.snmp4j.smi.Counter32; //导入依赖的package包/类
@Test
public void testGetNext() throws Exception {
	
	request(".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.11").andExpect(".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.11.1", SMIConstants.SYNTAX_COUNTER32, new Counter32(128350705));
	
	doGetNext();

	request(".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.11.1").andExpect(".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.11.2", SMIConstants.SYNTAX_COUNTER32, new Counter32(1047537430));

	doGetNext();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:12,代码来源:BrocadeMibTest.java


示例18: updateCounter32Value

import org.snmp4j.smi.Counter32; //导入依赖的package包/类
/**
 * <p>updateCounter32Value</p>
 *
 * @param oid a {@link java.lang.String} object.
 * @param val a int.
 */
public void updateCounter32Value(String oid, int val) {
    updateValue(oid, new Counter32(val));
}
 
开发者ID:vishwaabhinav,项目名称:OpenNMS,代码行数:10,代码来源:MockSnmpAgent.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DataNodeDiskChecker类代码示例发布时间:2022-05-22
下一篇:
Java ResteasyUriInfo类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap