I have a written a three part series on how to write a simple RHQ plugin.
As an example scenario the plugin will try to reach a http server, see if the base URL is available and return the status code + the time it took to reach it.
Part one talks about the structure of RHQ itself
Part two introduces the involved components
and
Part three shows the package structure and the code.