Bottom LineThe following is a quick introduction to what it takes to write an agent plugin. Details on each point are flushed out throughout the rest of this site.
What is a plugin?A plugin provides a way to integrate specific software packages (typically called "resources" in RHQ nomenclature) into the RHQ platform. The plugin provides a description of what the external software package is and what features of the RHQ platform it will utilize. The plugin also contains the code necessary to actually connect to the resource and perform the requested operations on it. Put more simply, plugins make the RHQ platform useful for specific needs. Need to inventory and monitor a Postgres database? The Postgres plugin provides the ability. Want to see CPU and network adapter metrics? The platform plugin provides the hook into your machine to retrieve these values. Have a need to manage a product that is not currently supported? Want to tie in your own applications and leverage all of the features of the platform? That's where the Plugin Community comes in. Open APIs provide a way for anyone to integrate a specific set of needs into the platform. What can I do with a plugin?For each resource type defined in a plugin, any combination of a number of core subsystems can be used to provide a customized, rich feature set for resources of that type. For more information on the set of subsystems available, visit the subsystems page. What are the pieces that make up a plugin?A plugin is packaged into a single JAR file. This file is present on both the server and agent. See the section on deploying for more information on how plugins are sent between the server and agent. There are two main pieces of any plugin: Plugin DescriptorA plugin descriptor is a description of what the plugin provides for the platform. At it's simplest level, it defines the types of resources that are supported by the plugin. By this means, plugins are able to introduce new types into the platform, along with a detailed description of the resource type's capabilities. The plugin descriptor is written as an XML document. In all plugins, it must be named rhq-plugin.xml and be located in the plugin's META-INF directory. The schema is provided as part of the Plugin Developer's Kit. A plugin descriptor may define any of the following for each resource type. Keep in mind that multiple resource types may be defined per plugin.
Plugin API ImplementationsIn order for the RHQ agent, or more specifically the plugin container, to interact with the plugin, the plugin must implement a set of the provided plugin API classes. These implementations provide the concrete code that will be executed by the plugin container to fulfill the functionality defined in the plugin descriptor. The set of APIs that must be implemented correspond to the features exposed in the plugin descriptor. In other words, if the plugin descriptor defines metrics for a resource type, the metric APIs must be implemented to provide the necessary hook. Plugins may also bundle in any external libraries or dependencies they need. The plugin container takes care to keep the plugin classloaders separate to prevent any conflicts in dependency versions between plugins. Resource Type ChecklistIn summary, the following tasks need to be accomplished for each resource type defined in the plugin. Plugin Descriptor Metadata Code Implementations How do I write a plugin?The easiest way to write a plugin is to start with our skeleton plugin and add whatever else you need. The skeleton plugin will provide the necessary project structure and maven POM files to build the plugin and put the necessary files in their required locations. The skeleton plugin also provides a stubbed out plugin descriptor to get started with. See the Skeleton Plugin page for more details on how to get started using it. How do I deploy a new plugin?Plugin Deployment Checklist
Plugin deployment is simple. Plugins are initially deployed to the RHQ server, which is as simple as copying the packaged plugin (a JAR file) to the server's dropbox plugins directory at <server-install-dir>/plugins. This dropbox was not supported in RHQ 2.3 or earlier; for those versions, you copy the agent plugin to the directory directory: After that, it's as simple as starting the agent. At startup, the RHQ agent will contact the server and download any new or updated plugins automatically. Alternatively, plugins can be updated by going to the agent console and running the command: plugins update or (if you have the RHQ Agent imported into inventory) you can execute the agent operation to update plugins. |