disman
Class Disman

java.lang.Object
  |
  +--disman.Disman

public class Disman
extends java.lang.Object


Field Summary
protected  int pollFactor
           
protected  int pollInterval
           
protected  int pollTimeout
           
 
Constructor Summary
Disman()
          Equivalent to Disman("localhost", 161, "public").
Disman(java.lang.String host)
          Equivalent to Disman(host, 161, "public").
Disman(java.lang.String host, int port, java.lang.String community)
          Create a Disman object associated with a given set of SNMP parameters.
Disman(java.lang.String host, java.lang.String community)
          Equivalent to Disman(host, 161, community).
 
Method Summary
 java.lang.String call(java.lang.String owner, Language language, java.lang.String source, java.lang.String argument)
          Run a script from a given URL written in a given language, with a given argument, and with a given owner.
 java.lang.String call(java.lang.String owner, java.lang.String pattern, java.lang.String source, java.lang.String argument)
          Run a script from a given URL written in a language described by a given description substring, with a given argument, and with a given owner.
 Extension getExtension(int[] oidarray)
          Get an Extension object by a given OID.
 Extension getExtension(java.lang.String pattern)
          Get an Extension object matching a description substring pattern.
 java.util.Vector getExtensions()
          Get a vector of all Extension objects.
 java.util.Vector getExtensions(Language language)
          Get a vector of all Extension objects related to a given Language object.
 Language getLanguage(int index)
          Get a Language object by an smLangTable index.
 Language getLanguage(int[] oidarray)
          Get a Language object by a given OID.
 Language getLanguage(java.lang.String pattern)
          Get a Language object matching a description substring pattern.
 java.util.Vector getLanguages()
          Get a vector of all Language objects.
 Launch getLaunch(java.lang.String owner, java.lang.String name)
          Get a Launch object by a given owner and name.
 java.util.Vector getLaunches()
          Get a vector of all Launch objects.
 java.util.Vector getLaunches(Script script)
          Get a vector of all Launch objects associated with a given Script object.
 java.util.Vector getLaunches(java.lang.String owner)
          Get a vector of all Launch objects of a given owner.
 int[] getLocalTime()
          Return the local time from the scheduler as an array of integer values representing the MIB value's octets (schedLocalTime).
 int getPollFactor()
          Return the percentage by which the poll interval increases between two polls (default: 150).
 int getPollInterval()
          Return the start interval in milli seconds for methods of this Disman object that perform SNMP polling operations (default: 100).
 int getPollTimeout()
          Return the maximum polling time in milli seconds for methods of this Disman object that perform SNMP polling operations (default: 10000).
protected  java.lang.String[] getRequest(jmgmt.snmp.io.Varbind[] varbinds)
           
 Run getRun(java.lang.String owner, java.lang.String name, int index)
          Get a Run object by a given launch button owner, launch button name, and index.
 java.util.Vector getRuns()
          Get a vector of all Run objects.
 java.util.Vector getRuns(Launch launch)
          Get a vector of all Run objects started from a given launch button.
 java.util.Vector getRuns(java.lang.String owner)
          Get a vector of all Run objects started from launch buttons of a given owner.
 Schedule getSchedule(java.lang.String owner, java.lang.String name)
          Get a Schedule object by a given owner and name.
 java.util.Vector getSchedules()
          Get a vector of all Schedule objects.
 java.util.Vector getSchedules(java.lang.String owner)
          Get a vector of all Schedule objects of a given owner.
 Script getScript(java.lang.String owner, java.lang.String name)
          Get a Script object by a given owner and name.
 java.util.Vector getScripts()
          Get a vector of all Script objects.
 java.util.Vector getScripts(Language language)
          Get a vector of all Script objects written in a given language.
 java.util.Vector getScripts(java.lang.String owner)
          Get a vector of all Script objects of a given owner.
 java.util.Date getTime()
          Get the local time from the scheduler as a Date object.
 Launch installLaunch(java.lang.String owner, java.lang.String name, Script script)
          Create and install a Launch object by a given owner, name, and script.
 Schedule installSchedule(java.lang.String owner, java.lang.String name, java.lang.String description, java.lang.String spec, java.lang.String oid, int value, int type)
          Create and install a Schedule object by a given owner and name.
 Script installScript(java.lang.String owner, java.lang.String name, java.lang.String description, Language language, java.lang.String source)
          Create and install a Script object by a given owner and name.
protected  java.util.Date intArrayToDate(int[] dat)
          Convert a DateAndTime int array into a Date object.
 void setPollFactor(int factor)
          Set the percentage by which the poll interval increases between two polls.
 void setPollInterval(int interval)
          Set the start interval in milli seconds for methods of this Disman object that perform SNMP polling operations (default: 100).
 void setPollTimeout(int timeout)
          Set the maximum polling time in milli seconds for methods of this Disman object that perform SNMP polling operations (default: 10000).
protected  java.lang.String setRequest(java.lang.String oid, java.util.BitSet value)
           
protected  java.lang.String setRequest(java.lang.String oid, byte[] value)
           
protected  java.lang.String setRequest(java.lang.String oid, long value)
           
protected  java.lang.String setRequest(java.lang.String oid, jmgmt.asn1.OID value)
           
protected  java.lang.String setRequest(java.lang.String oid, java.lang.String value)
           
protected  java.lang.String setRequestInt(java.lang.String oid, long value)
           
 java.lang.String toString()
          Return a String representation of the Disman object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pollInterval

protected int pollInterval

pollFactor

protected int pollFactor

pollTimeout

protected int pollTimeout
Constructor Detail

Disman

public Disman(java.lang.String host,
              int port,
              java.lang.String community)
       throws java.net.SocketException,
              java.net.UnknownHostException,
              java.io.IOException,
              NoDismanException,
              SnmpException
Create a Disman object associated with a given set of SNMP parameters. It is checked, whether the specified host is reachable, whether it runs an SNMP agent, whether the community is accepted and whether the agent supports the Script MIB. If one of these conditions to not hold, an appropriate exception is raised.
Parameters:
host - the host running the Script MIB agent
port - the port on the SNMP agent host
community - the SNMP community string to be used
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs
NoDismanException - if an SNMP connection to the Script MIB cannot be established
java.net.SocketException - if the SNMP socket communication fails
java.net.UnknownHostException - if the agent host name cannot be resolved

Disman

public Disman(java.lang.String host,
              java.lang.String community)
       throws java.net.SocketException,
              java.net.UnknownHostException,
              java.io.IOException,
              NoDismanException,
              SnmpException
Equivalent to Disman(host, 161, community). 161 is the standard port for SNMP agents.
Parameters:
host - the host running the Script MIB agent
community - the SNMP community string to be used
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs
NoDismanException - if an SNMP connection to the Script MIB cannot be established
java.net.SocketException - if the SNMP socket communication fails
java.net.UnknownHostException - if the agent host name cannot be resolved

Disman

public Disman(java.lang.String host)
       throws java.net.SocketException,
              java.net.UnknownHostException,
              java.io.IOException,
              NoDismanException,
              SnmpException
Equivalent to Disman(host, 161, "public"). 161 is the standard port for SNMP agents. "public" is a common default community.
Parameters:
host - the host running the Script MIB agent
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs
NoDismanException - if an SNMP connection to the Script MIB cannot be established
java.net.SocketException - if the SNMP socket communication fails
java.net.UnknownHostException - if the agent host name cannot be resolved

Disman

public Disman()
       throws java.net.SocketException,
              java.net.UnknownHostException,
              java.io.IOException,
              NoDismanException,
              SnmpException
Equivalent to Disman("localhost", 161, "public"). 161 is the standard port for SNMP agents. "public" is a common default community.
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs
NoDismanException - if an SNMP connection to the Script MIB cannot be established
java.net.SocketException - if the SNMP socket communication fails
java.net.UnknownHostException - if the agent host name cannot be resolved
Method Detail

setPollInterval

public void setPollInterval(int interval)
Set the start interval in milli seconds for methods of this Disman object that perform SNMP polling operations (default: 100).
Parameters:
interval - the interval in seconds

getPollInterval

public int getPollInterval()
Return the start interval in milli seconds for methods of this Disman object that perform SNMP polling operations (default: 100).
Returns:
the interval in seconds

setPollFactor

public void setPollFactor(int factor)
Set the percentage by which the poll interval increases between two polls. A value of 100 keeps the poll interval constant (default: 150).
Parameters:
factor - the interval factor

getPollFactor

public int getPollFactor()
Return the percentage by which the poll interval increases between two polls (default: 150).
Returns:
the interval factor

setPollTimeout

public void setPollTimeout(int timeout)
Set the maximum polling time in milli seconds for methods of this Disman object that perform SNMP polling operations (default: 10000).
Parameters:
limit - the maximum polling time in milli seconds

getPollTimeout

public int getPollTimeout()
Return the maximum polling time in milli seconds for methods of this Disman object that perform SNMP polling operations (default: 10000).
Returns:
the maximum polling time in milli seconds

getLanguage

public Language getLanguage(int[] oidarray)
                     throws SnmpException,
                            java.io.IOException
Get a Language object by a given OID. Standard language OIDs are assigned by IANA and defined in the IANA-LANGUAGE-MIB module. If no such language can be found, null is returned.
Parameters:
oidarray - array of OID sub-identifiers
Returns:
the Language object or null
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getLanguage

public Language getLanguage(int index)
                     throws SnmpException,
                            java.io.IOException
Get a Language object by an smLangTable index. If no such language can be found, null is returned.
Parameters:
index - index part of the Language table row
Returns:
the Language object or null
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getLanguage

public Language getLanguage(java.lang.String pattern)
                     throws SnmpException,
                            java.io.IOException
Get a Language object matching a description substring pattern. Note that only the first matching Language object is found. If no language can be found, null is returned.
Parameters:
pattern - the description substring pattern used for lookup
Returns:
the Language object or null
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getLanguages

public java.util.Vector getLanguages()
                              throws SnmpException,
                                     java.io.IOException
Get a vector of all Language objects.
Returns:
the vector of all Language objects
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getExtension

public Extension getExtension(int[] oidarray)
                       throws java.io.IOException,
                              SnmpException,
                              InconsistencyException
Get an Extension object by a given OID. If no such Extension can be found, null is returned.
Parameters:
oidarray - array of OID sub-identifiers
Returns:
the Extension object or null
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs
InconsistencyException - if a language/extension inconsistency occurs

getExtension

public Extension getExtension(java.lang.String pattern)
                       throws java.io.IOException,
                              SnmpException,
                              InconsistencyException
Get an Extension object matching a description substring pattern. Note that only the first matching Extension object is found. If no such Extension can be found, null is returned.
Parameters:
pattern - the description substring pattern used for lookup
Returns:
the Extension object or null
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs
InconsistencyException - if a language/extension inconsistency occurs

getExtensions

public java.util.Vector getExtensions()
                               throws java.io.IOException,
                                      SnmpException,
                                      InconsistencyException
Get a vector of all Extension objects.
Returns:
the vector of all Extension objects
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs
InconsistencyException - if a language/extension inconsistency occurs

getExtensions

public java.util.Vector getExtensions(Language language)
                               throws SnmpException,
                                      java.io.IOException
Get a vector of all Extension objects related to a given Language object.
Parameters:
the - Language object
Returns:
the vector of all matching Extension objects
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getScript

public Script getScript(java.lang.String owner,
                        java.lang.String name)
                 throws SnmpException,
                        java.io.IOException
Get a Script object by a given owner and name. If no such script can be found, null is returned.
Parameters:
owner - the owner to look for
name - the name of the script to look for
Returns:
the Script object or null
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getScripts

public java.util.Vector getScripts(java.lang.String owner)
                            throws SnmpException,
                                   java.io.IOException
Get a vector of all Script objects of a given owner.
Parameters:
owner - the owner to look for
Returns:
the vector of Script objects
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getScripts

public java.util.Vector getScripts(Language language)
                            throws SnmpException,
                                   java.io.IOException
Get a vector of all Script objects written in a given language.
Parameters:
language - the language to look for
Returns:
the vector of Script objects
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getScripts

public java.util.Vector getScripts()
                            throws SnmpException,
                                   java.io.IOException
Get a vector of all Script objects.
Returns:
the vector of Script objects
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

installScript

public Script installScript(java.lang.String owner,
                            java.lang.String name,
                            java.lang.String description,
                            Language language,
                            java.lang.String source)
                     throws EntryAlreadyExistsException,
                            ScriptEnableException,
                            TimeoutException,
                            SnmpException,
                            java.io.IOException,
                            IllegalNameException
Create and install a Script object by a given owner and name. Also set the description, language, and source, and enable it.
Parameters:
owner - the owner
name - the name of the script
description - the description string
language - the language this script is written in
source - the source URL (might be an empty string)
Returns:
the Script object
Throws:
TimeoutException - if any subsequent action cannot be finished in time
EntryAlreadyExistsException - if a matching script already exists
ScriptEnableException - if enabling the script fails
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs
IllegalNameException - if the script name or the owner string does not comply with the Script MIB definition

getLaunch

public Launch getLaunch(java.lang.String owner,
                        java.lang.String name)
                 throws SnmpException,
                        java.io.IOException
Get a Launch object by a given owner and name. If no such launch can be found, null is returned.
Parameters:
owner - the owner to look for
name - the name of the launch button to look for
Returns:
the Launch object or null
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getLaunches

public java.util.Vector getLaunches(java.lang.String owner)
                             throws SnmpException,
                                    java.io.IOException
Get a vector of all Launch objects of a given owner.
Parameters:
owner - the owner to look for
Returns:
the vector of Launch objects
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getLaunches

public java.util.Vector getLaunches(Script script)
                             throws SnmpException,
                                    java.io.IOException
Get a vector of all Launch objects associated with a given Script object.
Parameters:
script - the Script object
Returns:
the vector of Launch objects
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getLaunches

public java.util.Vector getLaunches()
                             throws SnmpException,
                                    java.io.IOException
Get a vector of all Launch objects.
Returns:
the vector of Launch objects
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

installLaunch

public Launch installLaunch(java.lang.String owner,
                            java.lang.String name,
                            Script script)
                     throws EntryAlreadyExistsException,
                            SnmpException,
                            java.io.IOException,
                            IllegalNameException
Create and install a Launch object by a given owner, name, and script.
Parameters:
owner - the owner
name - the name of the script
script - the script to be started by this launch button
Returns:
the Launch object
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs
EntryAlreadyExistsException - if a matching launch button already exists
IllegalNameException - if the launch name or the owner string does not comply with the Script MIB definition

getRun

public Run getRun(java.lang.String owner,
                  java.lang.String name,
                  int index)
           throws SnmpException,
                  java.io.IOException
Get a Run object by a given launch button owner, launch button name, and index. If no such launch can be found, null is returned.
Parameters:
owner - the owner to look for
name - the name of the launch button to look for
index - the run index to look for
Returns:
the Run object or null
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getRuns

public java.util.Vector getRuns(java.lang.String owner)
                         throws SnmpException,
                                java.io.IOException
Get a vector of all Run objects started from launch buttons of a given owner.
Parameters:
owner - the owner to look for
Returns:
the vector of Run objects
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getRuns

public java.util.Vector getRuns(Launch launch)
                         throws SnmpException,
                                java.io.IOException
Get a vector of all Run objects started from a given launch button.
Parameters:
launch - the launch button
Returns:
the vector of Run objects
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getRuns

public java.util.Vector getRuns()
                         throws SnmpException,
                                java.io.IOException
Get a vector of all Run objects.
Returns:
the vector of Run objects
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

call

public java.lang.String call(java.lang.String owner,
                             java.lang.String pattern,
                             java.lang.String source,
                             java.lang.String argument)
                      throws EntryAlreadyExistsException,
                             ScriptEnableException,
                             TimeoutException,
                             SnmpException,
                             java.io.IOException,
                             IllegalNameException
Run a script from a given URL written in a language described by a given description substring, with a given argument, and with a given owner. Block until it has been terminated and return the result string. The required script and launch button are created and deleted implicitly.
Parameters:
owner - the owner to use for the script and launch button
pattern - description substring pattern to look up the language
source - URL to fetch the script
argument - argument string to pass to the script
Returns:
the result string
Throws:
TimeoutException - if any subsequent action cannot be finished in time
EntryAlreadyExistsException - if a matching script already exists
ScriptEnableException - if enabling the script fails
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs
IllegalNameException - if the the owner string does not comply with the Script MIB definition

call

public java.lang.String call(java.lang.String owner,
                             Language language,
                             java.lang.String source,
                             java.lang.String argument)
                      throws EntryAlreadyExistsException,
                             ScriptEnableException,
                             TimeoutException,
                             SnmpException,
                             java.io.IOException,
                             IllegalNameException
Run a script from a given URL written in a given language, with a given argument, and with a given owner. Block until it has been terminated and return the result string. The required script and launch button are created and deleted implicitly.
Parameters:
owner - the owner to use for the script and launch button
language - the script's language
source - URL to fetch the script
argument - argument string to pass to the script
Returns:
the result string
Throws:
TimeoutException - if any subsequent action cannot be finished in time
EntryAlreadyExistsException - if a matching script already exists
ScriptEnableException - if enabling the script fails
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs
IllegalNameException - if the the owner string does not comply with the Script MIB definition

toString

public java.lang.String toString()
Return a String representation of the Disman object. Overrides java.lang.Object.
Overrides:
toString in class java.lang.Object

getLocalTime

public int[] getLocalTime()
                   throws java.io.IOException,
                          SnmpException
Return the local time from the scheduler as an array of integer values representing the MIB value's octets (schedLocalTime). This method should not be used by high level Schedule MIB applications.
Returns:
the array of octets of schedLocalTime
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getTime

public java.util.Date getTime()
                       throws java.io.IOException,
                              SnmpException
Get the local time from the scheduler as a Date object.
Returns:
the scheduler's notion of its local time.
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getSchedule

public Schedule getSchedule(java.lang.String owner,
                            java.lang.String name)
                     throws SnmpException,
                            java.io.IOException
Get a Schedule object by a given owner and name. If no such schedule can be found, null is returned.
Parameters:
owner - the owner to look for
name - the name of the schedule to look for
Returns:
the Schedule object or null
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getSchedules

public java.util.Vector getSchedules(java.lang.String owner)
                              throws SnmpException,
                                     java.io.IOException
Get a vector of all Schedule objects of a given owner.
Parameters:
owner - the owner to look for
Returns:
the vector of Schedule objects
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

getSchedules

public java.util.Vector getSchedules()
                              throws SnmpException,
                                     java.io.IOException
Get a vector of all Schedule objects.
Returns:
the vector of Schedule objects
Throws:
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs

installSchedule

public Schedule installSchedule(java.lang.String owner,
                                java.lang.String name,
                                java.lang.String description,
                                java.lang.String spec,
                                java.lang.String oid,
                                int value,
                                int type)
                         throws EntryAlreadyExistsException,
                                ScheduleEnableException,
                                TimeoutException,
                                SnmpException,
                                java.io.IOException,
                                IllegalNameException,
                                ScheduleSpecParseException
Create and install a Schedule object by a given owner and name. Also set the description, the calendar spec, the variable and value, and the schedule type, and enable it.
Parameters:
owner - the owner
name - the name of the schedule
description - the description string
spec - the calendar/interval spec string
variable - the OID string (dotted numerical)
value - the value to be set
Returns:
the Schedule object
Throws:
TimeoutException - if any subsequent action cannot be finished in time
EntryAlreadyExistsException - if a matching schedule already exists
ScheduleEnableException - if enabling the schedule fails
SnmpException - if an Snmp request fails
java.io.IOException - if a local I/O problem occurs
IllegalNameException - if the schedule name or the owner string does not comply with the Schedule MIB definition

intArrayToDate

protected java.util.Date intArrayToDate(int[] dat)
Convert a DateAndTime int array into a Date object.
Returns:
Date object representing the passed DateAndTime int array, or null if the DateAndTime int array is not valid.

getRequest

protected java.lang.String[] getRequest(jmgmt.snmp.io.Varbind[] varbinds)
                                 throws java.io.IOException,
                                        SnmpException,
                                        DismanReadException

setRequest

protected java.lang.String setRequest(java.lang.String oid,
                                      long value)
                               throws java.io.IOException,
                                      SnmpException,
                                      DismanWriteException

setRequestInt

protected java.lang.String setRequestInt(java.lang.String oid,
                                         long value)
                                  throws java.io.IOException,
                                         SnmpException,
                                         DismanWriteException

setRequest

protected java.lang.String setRequest(java.lang.String oid,
                                      jmgmt.asn1.OID value)
                               throws java.io.IOException,
                                      SnmpException,
                                      DismanWriteException

setRequest

protected java.lang.String setRequest(java.lang.String oid,
                                      java.lang.String value)
                               throws java.io.IOException,
                                      SnmpException,
                                      DismanWriteException

setRequest

protected java.lang.String setRequest(java.lang.String oid,
                                      byte[] value)
                               throws java.io.IOException,
                                      SnmpException,
                                      DismanWriteException

setRequest

protected java.lang.String setRequest(java.lang.String oid,
                                      java.util.BitSet value)
                               throws java.io.IOException,
                                      SnmpException,
                                      DismanWriteException