org.snmp4j.agent.io.prop
Class PropertyMOInput

java.lang.Object
  extended by org.snmp4j.agent.io.prop.PropertyMOInput
All Implemented Interfaces:
MOInput

public class PropertyMOInput
extends java.lang.Object
implements MOInput

The PropertyMOInput can be used to load MIB data from a properties file.

The format of the properties file is as follows:

   snmp4j.agent.cfg.contexts={s|x}<context1>[,{s|x}<context2>...]
   snmp4j.agent.cfg.oid[.ctx.<context>].<oid>=[<numRows>:<numCols>]
   snmp4j.agent.cfg.oid[.ctx.<context>].<oid>=[{<format>}<value>]
   snmp4j.agent.cfg.index[.ctx.<context>].oid.<rowIndex>={o}<index>
   snmp4j.agent.cfg.value[.ctx.<context>].oid.<rowIndex>.<colIndex>=[{<format>}<value>]
 
where text enclosed in [] is optional and

An example properties file is:

 snmp4j.agent.cfg.contexts=
 snmp4j.agent.cfg.oid.1.3.6.1.2.1.1.2.0={o}1.3.6.1.4.1.4976
 snmp4j.agent.cfg.oid.1.3.6.1.2.1.1.4.0={s}System Administrator
 snmp4j.agent.cfg.oid.1.3.6.1.2.1.1.6.0={s}
 snmp4j.agent.cfg.oid.1.3.6.1.2.1.1.7.0={i}10
 snmp4j.agent.cfg.oid.1.3.6.1.2.1.1.9.1=1:2
 snmp4j.agent.cfg.index.1.3.6.1.2.1.1.9.1.0={o}1
 snmp4j.agent.cfg.value.1.3.6.1.2.1.1.9.1.0.0={o}1.3.6.1.4.1.4976.10.1.1.100.4.1
 snmp4j.agent.cfg.value.1.3.6.1.2.1.1.9.1.0.1=
 ## VACM MIB
 # security2Group
 snmp4j.agent.cfg.oid.1.3.6.1.6.3.16.1.2.1=2:3
 snmp4j.agent.cfg.index.1.3.6.1.6.3.16.1.2.1.0={o}2.6.'public'
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.2.1.0.0={s}v1v2cgroup
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.2.1.0.1={i}4
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.2.1.0.2={i}1
 snmp4j.agent.cfg.index.1.3.6.1.6.3.16.1.2.1.1={o}3.6.'SHADES'
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.2.1.1.0={s}v3group
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.2.1.1.1={i}4
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.2.1.1.2={i}1
 # access
 snmp4j.agent.cfg.oid.1.3.6.1.6.3.16.1.4.1=2:6
 snmp4j.agent.cfg.index.1.3.6.1.6.3.16.1.4.1.0={o}10.'v1v2cgroup'.0.2.1
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.4.1.0.0={i}1
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.4.1.0.1={s}unrestrictedReadView
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.4.1.0.2={s}unrestrictedWriteView
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.4.1.0.3={s}unrestrictedNotifyView
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.4.1.0.4={i}4
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.4.1.0.5={i}1
 snmp4j.agent.cfg.index.1.3.6.1.6.3.16.1.4.1.1={o}7.'v3group'.0.3.3
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.4.1.1.0={i}1
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.4.1.1.1={s}unrestrictedReadView
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.4.1.1.2={s}unrestrictedWriteView
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.4.1.1.3={s}unrestrictedNotifyView
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.4.1.1.4={i}4
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.4.1.1.5={i}1
 # view trees
 snmp4j.agent.cfg.oid.1.3.6.1.6.3.16.1.5.2.1=3:4
 snmp4j.agent.cfg.index.1.3.6.1.6.3.16.1.5.2.1.0={o}20.'unrestrictedReadView'.3.1.3.6
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.5.2.1.0.0={s}
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.5.2.1.0.1={i}1
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.5.2.1.0.2={i}4
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.5.2.1.0.3={i}1
 snmp4j.agent.cfg.index.1.3.6.1.6.3.16.1.5.2.1.1={o}21.'unrestrictedWriteView'.3.1.3.6
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.5.2.1.1.0={s}
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.5.2.1.1.1={i}1
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.5.2.1.1.2={i}4
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.5.2.1.1.3={i}1
 snmp4j.agent.cfg.index.1.3.6.1.6.3.16.1.5.2.1.2={o}22.'unrestrictedNotifyView'.3.1.3.6
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.5.2.1.2.0={s}
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.5.2.1.2.1={i}1
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.5.2.1.2.2={i}4
 snmp4j.agent.cfg.value.1.3.6.1.6.3.16.1.5.2.1.2.3={i}1
 ## SNMP community MIB
 snmp4j.agent.cfg.oid.1.3.6.1.6.3.18.1.1.1=1:7
 snmp4j.agent.cfg.index.1.3.6.1.6.3.18.1.1.1.0={o}'public'
 snmp4j.agent.cfg.value.1.3.6.1.6.3.18.1.1.1.0.0={s}public
 snmp4j.agent.cfg.value.1.3.6.1.6.3.18.1.1.1.0.1={s}public
 snmp4j.agent.cfg.value.1.3.6.1.6.3.18.1.1.1.0.2={$1.3.6.1.6.3.10.2.1.1.0}
 snmp4j.agent.cfg.value.1.3.6.1.6.3.18.1.1.1.0.3={s}
 snmp4j.agent.cfg.value.1.3.6.1.6.3.18.1.1.1.0.4={s}
 snmp4j.agent.cfg.value.1.3.6.1.6.3.18.1.1.1.0.5={i}4
 snmp4j.agent.cfg.value.1.3.6.1.6.3.18.1.1.1.0.6={i}1
 ## USM MIB
 snmp4j.agent.cfg.oid.1.3.6.1.6.3.15.1.2.2.1=1:14
 snmp4j.agent.cfg.index.1.3.6.1.6.3.15.1.2.2.1.0={o}$#{1.3.6.1.6.3.10.2.1.1.0}.6.'SHADES'
 snmp4j.agent.cfg.value.1.3.6.1.6.3.15.1.2.2.1.0.0={s}SHADES
 snmp4j.agent.cfg.value.1.3.6.1.6.3.15.1.2.2.1.0.1={o}
 snmp4j.agent.cfg.value.1.3.6.1.6.3.15.1.2.2.1.0.2={o}1.3.6.1.6.3.10.1.1.3
 snmp4j.agent.cfg.value.1.3.6.1.6.3.15.1.2.2.1.0.3={s}
 snmp4j.agent.cfg.value.1.3.6.1.6.3.15.1.2.2.1.0.4={s}
 snmp4j.agent.cfg.value.1.3.6.1.6.3.15.1.2.2.1.0.5={o}1.3.6.1.6.3.10.1.2.2
 snmp4j.agent.cfg.value.1.3.6.1.6.3.15.1.2.2.1.0.6={s}
 snmp4j.agent.cfg.value.1.3.6.1.6.3.15.1.2.2.1.0.7={s}
 snmp4j.agent.cfg.value.1.3.6.1.6.3.15.1.2.2.1.0.8={s}
 snmp4j.agent.cfg.value.1.3.6.1.6.3.15.1.2.2.1.0.9={i}4
 snmp4j.agent.cfg.value.1.3.6.1.6.3.15.1.2.2.1.0.10={i}1
 snmp4j.agent.cfg.value.1.3.6.1.6.3.15.1.2.2.1.0.11={s}SHADESAuthPassword
 snmp4j.agent.cfg.value.1.3.6.1.6.3.15.1.2.2.1.0.12={s}SHADESPrivPassword
 snmp4j.agent.cfg.value.1.3.6.1.6.3.15.1.2.2.1.0.13=

 

Version:
1.2
Author:
Frank Fock

Field Summary
static java.lang.String CONFIG_PREFIX
           
static java.lang.String CONTEXTS_ID
           
static java.lang.String CTX_ID
           
static java.lang.String INDEX_ID
           
static java.lang.String OID_ID
           
static java.lang.String VALUE_ID
           
static java.lang.String VERSION_ID
           
 
Constructor Summary
PropertyMOInput(java.util.Properties props)
           
PropertyMOInput(java.util.Properties props, VariableProvider variables)
           
 
Method Summary
 void close()
           
 org.snmp4j.smi.Variable createVariableFromString(java.lang.String value, java.lang.Class<? extends org.snmp4j.smi.Variable> returnType)
          Parses a string of the format
 int getImportMode()
          Returns the update mode, which might be one of the constants defined by ImportModes.
 Context readContext()
           
 IndexedVariables readIndexedVariables()
           
 MOInfo readManagedObject()
           
 Sequence readSequence()
           
 org.snmp4j.smi.Variable readVariable()
           
 void skipContext(Context context)
           
 void skipManagedObject(MOInfo mo)
          Skips to the end of the specified managed object's configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_PREFIX

public static final java.lang.String CONFIG_PREFIX
See Also:
Constant Field Values

CONTEXTS_ID

public static final java.lang.String CONTEXTS_ID
See Also:
Constant Field Values

OID_ID

public static final java.lang.String OID_ID
See Also:
Constant Field Values

INDEX_ID

public static final java.lang.String INDEX_ID
See Also:
Constant Field Values

VERSION_ID

public static final java.lang.String VERSION_ID
See Also:
Constant Field Values

CTX_ID

public static final java.lang.String CTX_ID
See Also:
Constant Field Values

VALUE_ID

public static final java.lang.String VALUE_ID
See Also:
Constant Field Values
Constructor Detail

PropertyMOInput

public PropertyMOInput(java.util.Properties props)

PropertyMOInput

public PropertyMOInput(java.util.Properties props,
                       VariableProvider variables)
Method Detail

getImportMode

public int getImportMode()
Returns the update mode, which might be one of the constants defined by ImportModes. By default, ImportModes.REPLACE_CREATE is returned.

Specified by:
getImportMode in interface MOInput
Returns:
the constant denoting the update mode that should be used by a SerializableManagedObject to import its content from persistent storage.

readContext

public Context readContext()
                    throws java.io.IOException
Specified by:
readContext in interface MOInput
Throws:
java.io.IOException

readIndexedVariables

public IndexedVariables readIndexedVariables()
                                      throws java.io.IOException
Specified by:
readIndexedVariables in interface MOInput
Throws:
java.io.IOException

readManagedObject

public MOInfo readManagedObject()
                         throws java.io.IOException
Specified by:
readManagedObject in interface MOInput
Throws:
java.io.IOException

readSequence

public Sequence readSequence()
                      throws java.io.IOException
Specified by:
readSequence in interface MOInput
Throws:
java.io.IOException

readVariable

public org.snmp4j.smi.Variable readVariable()
                                     throws java.io.IOException
Specified by:
readVariable in interface MOInput
Throws:
java.io.IOException

skipContext

public void skipContext(Context context)
                 throws java.io.IOException
Specified by:
skipContext in interface MOInput
Throws:
java.io.IOException

skipManagedObject

public void skipManagedObject(MOInfo mo)
                       throws java.io.IOException
Description copied from interface: MOInput
Skips to the end of the specified managed object's configuration.

Specified by:
skipManagedObject in interface MOInput
Parameters:
mo - a MOInfo instance.
Throws:
java.io.IOException

createVariableFromString

public org.snmp4j.smi.Variable createVariableFromString(java.lang.String value,
                                                        java.lang.Class<? extends org.snmp4j.smi.Variable> returnType)
Parses a string of the format
 OID={type}value where <type> is one of
 the following single characters enclosed by '{' and '}':
  i                     Integer32
  u                     UnsingedInteger32, Gauge32
  s                     OCTET STRING
  x                     OCTET STRING specified as hex string where
                        bytes separated by colons (':').
  d                     OCTET STRING specified as decimal string
                        where bytes are separated by dots ('.').
  n                     Null
  o                     OBJECT IDENTIFIER
  t                     TimeTicks
  a                     IpAddress
  b                     OCTET STRING specified as binary string where
                        bytes are separated by spaces.
  $<variableName>     where  is the name of a predefined
                        variable or the OID of a variable of the agent's
                        MIB.
 
and returns the corresponding variable.

Parameters:
value - the variable value string.
returnType - the expected Variable class to return.
Returns:
null if value is null and the Variable corresponding to value otherwise.

close

public void close()
           throws java.io.IOException
Specified by:
close in interface MOInput
Throws:
java.io.IOException

Copyright 2005-2010 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.