Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.5.3.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.hyperic.hq.product
Class ServerDetector

    java.lang.Object
      org.hyperic.hq.product.GenericPlugin
          org.hyperic.hq.product.ServerDetector

All Implemented Interfaces:
  RuntimeDiscoverer

Direct Known Subclasses:
  DaemonDetector, PlatformServiceDetector

    public abstract class ServerDetector

extends GenericPlugin
implements RuntimeDiscoverer

Encapsulate the know-how to determine all kinds of server-specific information about a single type of server.

Field Summary
`protected static String` | `AUTOINVENTORY_NAME`
`protected static String` | `INSTALLPATH`
`protected static String` | `INVENTORY_ID`

Fields inherited from class org.hyperic.hq.product.GenericPlugin
`config, FILE_DELIM, FILE_DELIM_ESC, PROP_NAME`

Constructor Summary
`ServerDetector()`

Method Summary
`protected ServerResource` | `createServerResource(String installpath)` Initialize an ServerResource with default values.
`protected ServiceResource` | `createServiceResource(String type)`
`RuntimeResourceReport` | `discoverResources(int serverId, AIPlatformValue platform, org.hyperic.util.config.ConfigResponse config)` Deprecated. - Plugins should not use this method.
`protected List` | `discoverServers(org.hyperic.util.config.ConfigResponse config)` Override to discover servers for the server type of the plugin instance.
`protected List` | `discoverServices(org.hyperic.util.config.ConfigResponse config)` Override to discover services for the server type of the plugin instance.
`protected Set` | `discoverServiceTypes(org.hyperic.util.config.ConfigResponse config)`
`protected File` | `findVersionFile(File dir, Pattern pattern)`
`protected String` | `formatAutoInventoryName(String type, org.hyperic.util.config.ConfigResponse parentConfig, org.hyperic.util.config.ConfigResponse config, org.hyperic.util.config.ConfigResponse cprops)` Format the auto-inventory name as defined by the plugin, for example: %value%s are replaced using the ConfigResponse parameters.
`protected String` | `formatName(String name, org.hyperic.util.config.ConfigResponse parentConfig, org.hyperic.util.config.ConfigResponse config, org.hyperic.util.config.ConfigResponse cprops)`
`protected static String` | `getCanonicalPath(String installpath)` Fixup the installpath.
`protected org.hyperic.util.config.ConfigSchema` | `getConfigSchema(String name, int type)`
`String` | `getConnectionProtocol(String port)`
`protected Document` | `getDocument(File file)` DocumentBuilder.parse() wrapper
`protected String` | `getListenAddress(long port)`
`protected String` | `getListenAddress(String port)`
`AutoinventoryPluginManager` | `getManager()`
`protected static String` | `getParentDir(String path)`
`protected static String` | `getParentDir(String path, int levels)`
`protected static long[]` | `getPids(String query)` Wrapper for Sigar's ProcessFinder.find method.
`protected static String[]` | `getProcArgs(long pid)` Wrapper for Sigar.getProcArgs which catches SigarException and returns a String[] with length 0 if the SigarException is caught.
`protected static String` | `getProcCwd(long pid)` Attempt to get the current working directory of a process.
`protected static String` | `getProcExe(long pid)`
`protected static String` | `getProcExe(long pid, String name)` Attempt to find the absolute name of the process executable.
`protected static List` | `getProcModules(long pid)` Wrapper for Sigar.getProcModules which catches SigarException and returns a String[] with length 0 if the SigarException is caught.
`List` | `getRegistryScanKeys()` Helper for RegistryServerDetector implementors.
`RuntimeDiscoverer` | `getRuntimeDiscoverer()` Deprecated. - Plugins should not use this method.
`int` | `getScanOrder()`
`ServerSignature` | `getServerSignature()` The server signature is defined by plugins in etc/hq-plugin.xml if the plugin implements FileServerDetector or RegistryServerDetector.
`List` | `getServiceConfigs(String type)`
`Map` | `getServiceInventoryPlugins()`
`protected static org.hyperic.sigar.SigarProxy` | `getSigar()`
`String` | `getTypeProperty(String type, String name)` Get a value defined by a <property> tag in the plugin's hq-plugin.xml, within a <server> or <service> tag for this plugin's type.
`protected String` | `getXPathValue(File file, String xpath)`
`protected String` | `getXPathValue(Node node, String xpath)` XPathAPI.eval() wrapper.
`void` | `init(PluginManager manager)` Called when the plugin is loaded on the server and on the agent side.
`protected boolean` | `isInstallTypeVersion(String installpath)` Test if server type version filters apply: VERSION_FILE - Return true if given file exists within installpath INSTALLPATH_MATCH - Return true if installpath matches given substring INSTALLPATH_NOMATCH - Return false if installpath matches given substring
`boolean` | `isRuntimeDiscoverySupported()` If plugins do not override discoverServers or discoverServices, returning false here will prevent those methods from being called.
`boolean` | `isSSLPort(String port)`
`boolean` | `isWin32ServiceRunning(String name)`
`protected void` | `setControlConfig(ServerResource server, org.hyperic.util.config.ConfigResponse config)` Merge default values from server's control ConfigSchema and saves to ServerResource.setControlConfig.
`protected void` | `setControlConfig(ServiceResource service, org.hyperic.util.config.ConfigResponse config)` Merge default values from services's control ConfigSchema and saves to ServiceResource.setControlConfig.
`protected void` | `setCustomProperties(org.hyperic.util.config.ConfigResponse cprops)`
`protected void` | `setCustomProperties(ServerResource server, org.hyperic.util.config.ConfigResponse config)` Merge default values from server's Custom Properties schema and saves to ServerResource.setCustomProperties.
`protected void` | `setDescription(String description)`
`protected void` | `setMeasurementConfig(ServerResource server, org.hyperic.util.config.ConfigResponse config)` Merge default values from server's measurement ConfigSchema and saves to ServerResource.setMeasurementConfig.
`protected void` | `setMeasurementConfig(ServiceResource service, org.hyperic.util.config.ConfigResponse config)` Merge default values from service's measurement ConfigSchema and saves to ServiceResource.setMeasurementConfig.
`protected void` | `setProductConfig(ServerResource server, org.hyperic.util.config.ConfigResponse config)` Merge default values from server's product ConfigSchema and saves to ServerResource.setProductConfig.
`protected void` | `setProductConfig(ServiceResource service, org.hyperic.util.config.ConfigResponse config)` Merge default values from service's product ConfigSchema and saves to ServiceResource.setProductConfig.

Methods inherited from class org.hyperic.hq.product.GenericPlugin
`adjustClassPath, configure, getAbsoluteFiles, getConfig, getConfig, getConfigSchema, getCustomPropertiesSchema, getCustomPropertiesSchema, getCustomPropertiesSchema, getDefaultInstallPath, getLog, getLogName, getManagerProperty, getName, getPlatformName, getPluginClassName, getPluginData, getPluginProperty, getProductPlugin, getProperties, getScriptExtension, getScriptExtension, getScriptExtension, getTypeInfo, getTypeNameProperty, getTypeNameProperty, getTypeProperties, getTypeProperty, getTypeProperty, isNetStatEnabled, isWin32, openResource, setData, setName, setTypeInfo, shutdown, toFileList`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### INSTALLPATH

    protected static final String INSTALLPATH

See Also:
  Constant Field Values

### INVENTORY_ID

    protected static final String INVENTORY_ID

See Also:
  Constant Field Values

### AUTOINVENTORY_NAME

    protected static final String AUTOINVENTORY_NAME

See Also:
  Constant Field Values

Constructor Detail

### ServerDetector

    public ServerDetector()

Method Detail

### getRuntimeDiscoverer

    public RuntimeDiscoverer getRuntimeDiscoverer()

  Deprecated. - Plugins should not use this method.

  See Also:
    `discoverServers(org.hyperic.util.config.ConfigResponse)`, `discoverServices(org.hyperic.util.config.ConfigResponse)`

### isRuntimeDiscoverySupported

    public boolean isRuntimeDiscoverySupported()

  If plugins do not override discoverServers or discoverServices, returning false here will prevent those methods from being called.

  Returns:
    true by default.

### discoverResources

    public RuntimeResourceReport discoverResources(int serverId,
                                                   AIPlatformValue platform,
                                                   org.hyperic.util.config.ConfigResponse config)
                                            throws PluginException

  Deprecated. - Plugins should not use this method.

  Description copied from interface: `RuntimeDiscoverer`
  This method is called by the autoinventory code that runs within the agent. It is used to discover resources for a particular server by communicating directly with the server as it is running.

  Specified by:
    `discoverResources` in interface `RuntimeDiscoverer`
  Parameters:
    `serverId` - The server ID to use when constructing AIServerValue objects and other resources to put into the RuntimeResourceReport.
    `platform` - The current platform. This should be used when detecting servers on the current platform.
    `config` - The config response to use when querying for resources.
  Returns:
    A RuntimeResourceReport object that describes the services, groups and other resources that are detected. This method can return null if nothing is detected.
  Throws:
    `PluginException` - TODO
  See Also:
    `discoverServers(org.hyperic.util.config.ConfigResponse)`, `discoverServices(org.hyperic.util.config.ConfigResponse)`, `discoverServiceTypes(org.hyperic.util.config.ConfigResponse)`

### setDescription

    protected void setDescription(String description)

### setCustomProperties

    protected void setCustomProperties(org.hyperic.util.config.ConfigResponse cprops)

### discoverServers

    protected List discoverServers(org.hyperic.util.config.ConfigResponse config)
                            throws PluginException

  Override to discover servers for the server type of the plugin instance. In most cases plugins will override discoverServices rather than this method. The general use of this method is where a plugin FileServerDetector or AutoServerDetector finds the Admin server and this method discovers the managed server nodes. Such plugins include WebLogic, WebSphere and iPlanet.

  Parameters:
    `config` - Configuration of the parent server resource.
  Returns:
    List of type ServerResource
  Throws:
    `PluginException` - If an error occured during discovery.
  Since:
    1.7
  See Also:
    `discoverServices(org.hyperic.util.config.ConfigResponse)`, `ServerResource`

### discoverServices

    protected List discoverServices(org.hyperic.util.config.ConfigResponse config)
                             throws PluginException

  Override to discover services for the server type of the plugin instance.

  Parameters:
    `config` - Configuration of the parent server resource.
  Returns:
    List of type ServiceResource.
  Throws:
    `PluginException` - If an error occured during discovery.

### discoverServiceTypes

    protected Set discoverServiceTypes(org.hyperic.util.config.ConfigResponse config)
                                throws PluginException

  Throws:
    `PluginException`

### init

    public void init(PluginManager manager)
              throws PluginException

  Description copied from class: `GenericPlugin`
  Called when the plugin is loaded on the server and on the agent side.

  Overrides:
    `init` in class `GenericPlugin`
  Parameters:
    `manager` - The plugin manager for this plugin type.
  Throws:
    `PluginException`

### getManager

    public AutoinventoryPluginManager getManager()

  Returns:
    The plugin manager for this plugin.

### getTypeProperty

    public String getTypeProperty(String type,
                                  String name)

  Description copied from class: `GenericPlugin`
  Get a value defined by a <property> tag in the plugin's hq-plugin.xml, within a <server> or <service> tag for this plugin's type.

  Same as: `getProperty(type + "." + name);`

  Overrides:
    `getTypeProperty` in class `GenericPlugin`

### getRegistryScanKeys

    public List getRegistryScanKeys()

  Helper for RegistryServerDetector implementors. Gets the scan keys from hq-plugin.xml

### getServerSignature

    public ServerSignature getServerSignature()

  The server signature is defined by plugins in etc/hq-plugin.xml if the plugin implements FileServerDetector or RegistryServerDetector.

### findVersionFile

    protected File findVersionFile(File dir,
                                   Pattern pattern)

### isInstallTypeVersion

    protected boolean isInstallTypeVersion(String installpath)

  Test if server type version filters apply: VERSION_FILE - Return true if given file exists within installpath INSTALLPATH_MATCH - Return true if installpath matches given substring INSTALLPATH_NOMATCH - Return false if installpath matches given substring

  Parameters:
    `installpath` - The server instance installpath
  Returns:
    false installpath does not match type version criteria, true otherwise

### createServerResource

    protected ServerResource createServerResource(String installpath)

  Initialize an ServerResource with default values. Defaults are set for:
  - Type - Using getTypeInfo().getName()
  - Name - Using getPlatformName() + " " + Type
  - InstallPath - The installpath param passed to getCanonicalPath.
  - Identifier - The installpath param.

  Parameters:
    `installpath` - Used to set InstallPath and Identifier

### createServiceResource

    protected ServiceResource createServiceResource(String type)

  Returns:
    ServiceResource with setType(this, type)

### formatName

    protected String formatName(String name,
                                org.hyperic.util.config.ConfigResponse parentConfig,
                                org.hyperic.util.config.ConfigResponse config,
                                org.hyperic.util.config.ConfigResponse cprops)

### formatAutoInventoryName

    protected String formatAutoInventoryName(String type,
                                             org.hyperic.util.config.ConfigResponse parentConfig,
                                             org.hyperic.util.config.ConfigResponse config,
                                             org.hyperic.util.config.ConfigResponse cprops)

  Format the auto-inventory name as defined by the plugin, for example: %value%s are replaced using the ConfigResponse parameters.

  Parameters:
    `type` - The resource type name used to lookup AUTOINVENTORY_NAME
    `parentConfig` - The platform or server configuration
    `config` - The server or services configuration
    `cprops` - Custom properties
  Returns:
    The formatted name or null if AUTOINVENTORY_NAME is not defined for the given resource type name

### getParentDir

    protected static String getParentDir(String path)

  See Also:
    `FileUtil.getParentDir(String)`

### getParentDir

    protected static String getParentDir(String path,
                                         int levels)

  See Also:
    `FileUtil.getParentDir(String, int)`

### getCanonicalPath

    protected static String getCanonicalPath(String installpath)

  Fixup the installpath. Quotes are removed. Canonicalized to removing double slashes, uppercase drive letter, etc.

### getSigar

    protected static org.hyperic.sigar.SigarProxy getSigar()

  Returns:
    A SigarProxyCache instance with an expiration time of 10 minutes. The cache is cleared by the plugin manager after all AutoServerDetectors have been run.

### getListenAddress

    protected String getListenAddress(String port)

### getListenAddress

    protected String getListenAddress(long port)

### getProcArgs

    protected static String[] getProcArgs(long pid)

  Wrapper for Sigar.getProcArgs which catches SigarException and returns a String[] with length 0 if the SigarException is caught.

  Parameters:
    `pid` - Process identifier
  Returns:
    Arguments that were passed to the process.

### getProcModules

    protected static List getProcModules(long pid)

  Wrapper for Sigar.getProcModules which catches SigarException and returns a String[] with length 0 if the SigarException is caught.

  Parameters:
    `pid` - Process identifier

### getProcExe

    protected static String getProcExe(long pid)

### getProcExe

    protected static String getProcExe(long pid,
                                       String name)

  Attempt to find the absolute name of the process executable. If the name cannot be determined, `null` is returned.

  Parameters:
    `pid` - Process identifier
    `name` - Binary base name to match against
  Returns:
    The process executable name.

### getProcCwd

    protected static String getProcCwd(long pid)

  Attempt to get the current working directory of a process. If the directory cannot be determined, `null` is returned.

  Parameters:
    `pid` - Process identifier
  Returns:
    The process current working directory.

### getPids

    protected static long[] getPids(String query)

  Wrapper for Sigar's ProcessFinder.find method.

  Parameters:
    `query` - SIGAR Process Table Query
  Returns:
    Array of pids that match the query, length == 0 if there were no matches.

### isWin32ServiceRunning

    public boolean isWin32ServiceRunning(String name)

  Parameters:
    `name` - The Service name shown in the Windows service panel Properties General tab, not the Display name. For example, "Terminal Services" is the Display name, "TermService" is the Service name that should be used here.
  Returns:
    true If the service exists and is running, false otherwise.

### isSSLPort

    public boolean isSSLPort(String port)

### getConnectionProtocol

    public String getConnectionProtocol(String port)

### getDocument

    protected Document getDocument(File file)
                            throws IOException

  DocumentBuilder.parse() wrapper

  Parameters:
    `file` - File to parse
  Returns:
    parsed Document
  Throws:
    `IOException` - For any exception

### getXPathValue

    protected String getXPathValue(Node node,
                                   String xpath)

  XPathAPI.eval() wrapper. XPathAPI.eval never returns null, however this wrapper method will return null if XObject.toString().length() == 0

  Parameters:
    `node` - Node to search
    `xpath` - XPath string
  Returns:
    XObject.toString() or null if Exception is caught

### getXPathValue

    protected String getXPathValue(File file,
                                   String xpath)

### getConfigSchema

    protected org.hyperic.util.config.ConfigSchema getConfigSchema(String name,
                                                                   int type)

### setProductConfig

    protected void setProductConfig(ServerResource server,
                                    org.hyperic.util.config.ConfigResponse config)

  Merge default values from server's product ConfigSchema and saves to ServerResource.setProductConfig.

### setMeasurementConfig

    protected void setMeasurementConfig(ServerResource server,
                                        org.hyperic.util.config.ConfigResponse config)

  Merge default values from server's measurement ConfigSchema and saves to ServerResource.setMeasurementConfig.

### setCustomProperties

    protected void setCustomProperties(ServerResource server,
                                       org.hyperic.util.config.ConfigResponse config)

  Merge default values from server's Custom Properties schema and saves to ServerResource.setCustomProperties.

### setControlConfig

    protected void setControlConfig(ServerResource server,
                                    org.hyperic.util.config.ConfigResponse config)

  Merge default values from server's control ConfigSchema and saves to ServerResource.setControlConfig.

### setProductConfig

    protected void setProductConfig(ServiceResource service,
                                    org.hyperic.util.config.ConfigResponse config)

  Merge default values from service's product ConfigSchema and saves to ServiceResource.setProductConfig.

### setMeasurementConfig

    protected void setMeasurementConfig(ServiceResource service,
                                        org.hyperic.util.config.ConfigResponse config)

  Merge default values from service's measurement ConfigSchema and saves to ServiceResource.setMeasurementConfig.

### setControlConfig

    protected void setControlConfig(ServiceResource service,
                                    org.hyperic.util.config.ConfigResponse config)

  Merge default values from services's control ConfigSchema and saves to ServiceResource.setControlConfig.

### getServiceInventoryPlugins

    public Map getServiceInventoryPlugins()

### getServiceConfigs

    public List getServiceConfigs(String type)

### getScanOrder

    public int getScanOrder()

  Returns:
    The order in which this ServerDetector should be executed as compared with other ServerDetectors in the same scan. This allows for one ServerDetector to "win" if multiple plugins detect Servers with the same autoinventory identifier. The ServerDetector that returns the lowest number will call the shots. If the same server is detected later, it will be ignored and not sent back to the Hyperic server.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.5.3.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2010 Hyperic, Inc. support@hyperic.net, All Rights Reserved.