vCenter

 View Only
  • 1.  help with a custom plugin that involes a control action

    Posted Dec 11, 2009 10:22 PM
    Hello

    I am working on creating a plug-in that will allow me to trigger a control action if an alert occurs. I am using puppet now since the process goes down now and then but I want to expand this out to other software so that I can minimize the involvement of our support teams.

    here is the plugin

    <?xml version="1.0"?>

    <!DOCTYPE plugin [
    <!ENTITY process-metrics SYSTEM "/pdk/plugins/process-metrics.xml">
    ]>

    <plugin>

    <server name="Puppet">

    <!-- Use this helper class -->

    <plugin type="control" class="org.hyperic.hq.product.ScriptControlPlugin"/>

    <!-- Actions visible in UI-->
    <actions include="start,stop,restart,status"/>

    <property name="DEFAULT_PROGRAM" value="/sbin/service puppet "/>
    <property name="BACKGROUND_COMMAND" value="true"/>

    <property name="PROC_QUERY"
    value="Pid.PidFile.eq=/var/run/puppet/puppetd.pid"/>

    <property name="INVENTORY_ID" value="${PROC_QUERY}"/>

    <property name="DEFAULT_CONF"
    value="/etc/puppet/puppet.conf"/>

    <config>
    <option name="process.query"
    description="Process Query"
    default="${PROC_QUERY}"/>
    </config>

    <plugin type="autoinventory"
    class="org.hyperic.hq.product.DaemonDetector"/>

    <plugin type="measurement"
    class="org.hyperic.hq.product.MeasurementPlugin"/>

    <plugin type="config_track"
    class="org.hyperic.hq.product.ConfigFileTrackPlugin"/>

    <metric name="Availability"
    template="sigar:Type=ProcState,Arg=%process.query%:State"
    indicator="true"/>

    &process-metrics;

    </server>

    </plugin>

    When I deploy the plug-in in HQ I can see the metrics being collected and I can see the control options. The path to puppet control program is not right, its /usr/lib/ruby instead of the path I defined in the plug-in. The only that confuses me is how HQ actually restarts the process. Can I use the standard service command such as "/sbin/service puppet restart" or do I have to make a script that takes input and then deploy the script with the plug-in? This plug-in seems to work expect for the control action section

    Thanks

    Ed


  • 2.  RE: help with a custom plugin that involes a control action

    Posted Dec 13, 2009 08:19 AM
    Hi,

    while I was writing a program I had to set BACKGROUND_COMMAND to false:

    <property name="BACKGROUND_COMMAND" value="false"/>

    I am not sure if the DEFAULT_PROGRAM can caontain white spaces. It is probably safer to write a wrapper that calls "/sbin/server puppet", passes the arguments like stop, start etc. and make it part of the plugin.
    <property name="DEFAULT_PROGRAM" value="/sbin/service puppet "/>

    Before you deploy the plugin and use it to create resources, it is recommended to run the plugin standalone. You will also find an example how to run control actions. It makes the debugging a lot easier.
    Have a look at:
    http://support.hyperic.com/display/DOC/Invoking+Plugins+Standalone

    hope this helps,
    Mirko


  • 3.  RE: help with a custom plugin that involes a control action

    Posted Dec 13, 2009 07:54 PM
    I know how to manually invoke a plugin from the command line. I would like more information regarding how to invoke the control action. I would prefer to use a system tool such as the service command instead of having to write a wrapper script but if that is the answer then so be it. Thanks for your input.

    Ed