Invoking Plugins Standalone
Invoking Plugins Standalone
The PDK provides a mechanism to invoke plugins outside of the server/agent from a command shell. It is possible to run metric collection, control, and autodiscovery using:
java -jar hq-product.jar
The main method sets up the classpath and dispatches commands to the plugins.
Command Line Arguments
| Argument | 2nd Argument | Description | Example |
|---|---|---|---|
| -p | Product plugin name, without "-plugin.jar" or "-plugin.xml". | -p jboss | |
| -t | The server or service's resource-type name. | -t "JBoss 4.0" -t "JBoss 4.0 JCA Connection Pool" |
|
| -m | <name of method> | Invoke the specified method | -m control -m metric -m discover -m track -m generate |
| lifecycle | Simply initializes the plugin and checks its syntax | -m lifecycle | |
| -a | Invoke the specified action | ||
| <name of control action> | Invoke the named control action | -a stop -a start -a restart |
|
| getvalue | The default action. Translates metric templates, invokes MeasurementPlugin.getValue, and displays the results | ||
| translate | Translate metric templates but don't invoke getValue | ||
| properties | Generate properties files containing the auto-discovered properties for each resource found. The files are put in ./plugin-properties with subdirectories for each resource type. The name of each property file is that of the resource name with invalid filename characters converted to '_'. The generated file also includes properties equivalent to the -p and -t switches so these files can easily be used to invoke metric or control for a specific resource. | ||
| metric | Get metrics values using the auto-discovered properties | ||
| log | Watch for log events and print events to stdout | ||
| config | Watch for config events and print events to stdout | ||
| help | Generate help (if any) for each resource type, output to .html files in the ./plugin-help directory. | ||
| metrics-txt | Generate a text formatted summary of supported metrics to stdout. | ||
| metrics-xml | Generate an xml formatted summary of supported metrics to stdout. | ||
| metrics-sgml | Generate an sgml formatted summary of supported metrics to stdout. | ||
| -D | Define the specified config property. These properties are used to create the ConfigResponse object for use by the plugins. These are the same properties displayed on the "Resource Configuration" screen for each resource. These properties can be generated using -m discover -a properties. | ||
| log | Set the log level | -Dlog=debug | |
| output.dir | Override output directory default '.' | -Doutput.dir=/tmp | |
| metric-collect | For use with metric method, only get metrics with defaultOn=true | -m metric -Dmetric-collect=default | |
| metric-indicator | For use with metric method, only get metrics with indicator=true | -m metric -Dmetric-indicator=true | |
| metric-cat | For use with metric method, only get metrics with the given category | -Dmetric-cat=AVAILABILITY | |
| metric-iter | For use with metric method, do n iterations of getValue for each metric, the time spent in millis is printed rather than the value. | -m metric -Dmetric-iter=100 |
Examples
Run auto-discovery for all products:
java -jar pdk/lib/hq-product.jar -m discover
Run auto-discovery for all products and save configuration to properties files in the plugin-properties directory:
java -jar pdk/lib/hq-product.jar -m discover -a properties
Run auto-discovery for a specific plugin:
java -jar pdk/lib/hq-product.jar -p jboss -m discover
Fetch metrics for a specific resource type:
java -jar pdk/lib/hq-product.jar -m metric -p jboss \ -t "JBoss 4.0 JMS Destination" \ -Djms.destination=DLQ \ -Djava.naming.naming.url=jnp://localhost:1099
Fetch metrics using auto-discovered configuration:
java -jar pdk/lib/hq-product.jar -m metric \ plugin-properties/jboss-4.0/hammer_JBoss_4.0_all.properties
Execute stop control action:
java -jar pdk/lib/hq-product.jar -m control -a stop \ plugin-properties/jboss-4.0/hammer_JBoss_4.0_all.properties
Execute start control action:
java -jar pdk/lib/hq-product.jar -m control -a start \ plugin-properties/jboss-4.0/hammer_JBoss_4.0_all.properties
Execute control action without using properties file:
java -jar pdk/lib/hq-product.jar -m control -p jboss -a removeAllMessages \ -t "JBoss 4.0 JMS Destination" \ -Djms.destination=DLQ \ -Djava.naming.naming.url=jnp://localhost:1099
Watch for log events:
java -jar pdk/lib/hq-product.jar -p apache -t "Apache 2.0" -m track -a log \ -Dserver.log_track.files=/var/log/httpd/error_log
Watch for config events:
java -jar pdk/lib/hq-product.jar -p apache -t "Apache 2.0" -m track -a config \
-Dserver.config_track.files=/etc/httpd/httpd.conf