Writing a Custom Hawk Plug-in And Registering it With The Existing Hawk Agent
Hawk is an extensible product and additional monitoring capabilities can be added by creating plug-ins to it. Every plug-in requires a .hma
file, which is a HMA configuration file, and a .jar
file, which is a Java implementation of various methods you want to expose via the Hawk subsystem. Follow the below steps to create a plug-in:
Refer to the HAWK_HOME
/examples/ma_plugin/DM*.hma
file for guidance.
|
—
|
Most important constituent of this .hma file is the main/startup class of the plug-in implementation. That is to be mentioned under the <classname> tag. For example: |
<classname>com.A.B.myPluginControllerClass</classname>
|
—
|
You can also specify some optional arguments that you would expect the users to configure externally without the need to change plug-in implementation. Such optional arguments should be mentioned under the <argmuents> tag. For example: |
<arguments><arg>-traceDir</arg><arg>C:/LogDir</arg></arguments>
|
—
|
Absolute path of the implementation .jar files and all the required third party libraries should be mentioned under <classpath> tag. For example: |
<classpath><path>C:/TPCL/libs/slf4j-api-1.6.4.jar</path></classpath>
|
2.
|
Place the .hma file into the folder CONFIG_FOLDER /plugin . |
If you have more than one Hawk plug-ins, please make sure that all .hma
files are present in the CONFIG_FOLDER
/plugin
subfolder.
|
3.
|
Edit the CONFIG_FOLDER /bin/hawkagent.cfg to set or uncomment the following parameter: |
-hma_plugin_dir ${CONFIG_FOLDER}/plugin.
|
4.
|
Ensure that you have created the implementation .jar file in the same folder that is specified in the <classpath> tag within the .hma file. |
Refer to the HAWK_HOME
/examples/ma_plugin/DM*.java
for guidance.
|
5.
|
Restart the Hawk agent. |
You should now be able to view your custom plug-in microagent and corresponding methods in Hawk Console.