Scheduled Downtime With Hyperic HQ

April 25th, 2008

As any user of the excellent open source software Hyperic HQ knows, there are many great features in Hyperic HQ. However, there are also a few short comings. One of these deficiencies in the software is it’s lack of a way to turn off alerts for scheduled downtime.

With the introduction of Hyperic HQ 3.2.2 a new feature was added called the HQU Plugin Framework. This framework gives developers access to the backend database in a fairly friendly API. Written in Groovy, which is a dynamic language for the Java VM. Built on top of java it really simplifies java development. I am a really big fan of groovy (and grails),but since this article is not about groovy or grails, I’ll point you to a great book on groovy by Scott Davis called Groovy Recipes

To install the Platform Alert Manager Plugin:

  1. Download the platalertman0_2.tgz file to your Hyperic server
  2. Run tar -zxvf platalertman0_2.tgz
  3. mv platalertman <hq_home>/hq-engine/server/default/deploy/hq.ear/hq.war/hqu

To test your Platform Alert Manager Plugin:

  1. cd <hq_home>/hq-engine/server/default/deploy/hq.ear/hq.war/hqu/platalertman/bin
  2. java HypericPlatformAlertManager hyperic-url username password [enable|disable] platform-name
  3.       For Example:
          java HypericPlatformAlertManager http://localhost:7080 hqadmin hqadmin disable myplatform

if it worked, you will get “result=OK”

  • Please note, that the platform name is the fqdn of the platform according to hyperic

To schedule downtime in Hyperic:

  1. Copy the platalertman/bin directory to a platform that you would like to schedule for downtime.
  2. Modify the enable.sh and disable.sh scripts to match the platform name
  3. In the hyperic ui, navigate to the platform and click the "Tools Menu" - "New Platform Service"
  4. Name your service something like "Disable Alerts <platform-name>"
  5. Choose a "Service Type" of "FileServer File"
  6. Click "Configuration Properties"
  7. In the "Path" field, put the fully qualified path to the disable.sh script from step 2
  8. Click the "Control" tab
  9. In the "Quick Control" section, change the "Control Action" to "run"
  10. Click the play button
  11. Verify the result in the "Command Status" field at the top of the page
  12. Schedule your down time by clicking the "New" button in the "Control Action Schedule" section
  13. Select "Run" from the "Control Action" menu
  14. In the "Schedule" section, you can schedule your events to run daily, weekly or monthly.
  • There is a pretty big JavaScript bug that prevents you from selecting the current month. To get around this, select “12 (Dec)” from the month drop down. In fact, all months are going to be one high because of this bug.
  • Also, this bug will change the date if you want to modify the schedule.
  • To summarize, be very careful when scheduling your downtime.

15. Repeat steps 3-14 to setup the “Enable Alerts <platform-name>”You now have a scheduled window of downtime that you can repeat daily, weekly or monthly. It’s not the perfect solution, but it is fully contained within the Hyperic UI.

The Platform Alert Manager plugin would benefit from a few more features. The future enhancement list includes:

  1. Custom plugin that integrates the control function by passing in the current platform.
  2. Auto add the "Platform Downtime Schedule" plugin to the inventory

Please feel free to leave me comments with any suggestions.

Writing to the Windows Event Viewer the Easy Way

December 21st, 2007

While working with Hyperic (http://www.hyperic.com) I found that to help control the Hyperic alerting, I could write a message to the Windows Event Viewer.

LOG4J (http://logging.apache.org/log4j/1.2/index.html), has a built-in appender called NTEventLogAppender. This makes it very simple.

Here is some source code to get you started:


import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.nt.NTEventLogAppender;

public class WindowsEventLogger {
    private static Logger logger = Logger.getLogger(WindowsEventLogger.class);

    public static void main(String[] args) {
        BasicConfigurator.configure();
        NTEventLogAppender eventLogAppender = new NTEventLogAppender();
        eventLogAppender.setSource(source);
        eventLogAppender.setLayout(new PatternLayout(”%m”));
        eventLogAppender.activateOptions();
        logger.addAppender(eventLogAppender);

        logger.info(”Hello World!”);
    }
}

Don’t forget to put the NTEventLogAppender.dll in your JAVA.LIBRARY.PATH. In windows, putting the DLL at the root directory of your class should do the trick.

The NTEventLogAppender.dll is in the root directory of the Log4J download.

Ubuntu JEOS (Just Enough Operating System)

November 8th, 2007

Ubuntu finally released the files for the JEOS version of Linux.

More information can be found here in the press release:
http://www.ubuntu.com/news/ubuntu-jeos

The download is here:

http://ftp.heanet.ie/disk1/ubuntu-cdimage/jeos/releases/7.10/release/ubuntu-7.10-jeos-i386.iso

http://preview.tinyurl.com/23vht7

I Found a Bug in Pocket Excel

October 22nd, 2007

Now that I am commuting to work via the metra train, I figured it would be useful to have the train schedule on my Treo 700w.  I pull out Microsoft Pocket Excel to input the train schedule into a new spread sheet - only to find an annoying bug.  I put the times in as strings such as 512 for 512pm.  When I put num-lock on for a cell, and then started typing the numbers, the num-lock automatically shut-off after the first number.  For example, if I tried to input 512, I would end up with 5er.  This happens on every cell and made data entry very painful.

Useful Software Downloads

October 18th, 2007

This posting is as much for me as anyone else.  I seem to rebuild enough machines that it is helpful to have a list of all my commonly used apps in one place.

Applications
Firefox http://getfirefox.com
7zip http://www.7zip.org
Gimp http://www.gimp.org
UltraVNC http://www.uvnc.com/
VMWare Server http://www.vmware.com
AVG Anti-virus http://free.grisoft.com
Burn 4 Free http://www.burn4free.com/
Print Drivers  
PrimoPDF http://www.primopdf.com/
Development  
Java http://www.javasoft.com
PHP http://www.php.net/
Eclipse http://www.eclipse.org
Tortoise SVN http://tortoisesvn.tigris.org/
Ant http://ant.apache.org
JUnit http://www.junit.org
Servers
Ubuntu Linux http://www.ubuntu.org
OpenSolaris http://www.opensolaris.org
Apache Tomcat http://tomcat.apache.org
XAMPP http://www.apachefriends.org
Subversion http://subversion.tigris.org/
JBoss http://www.jboss.org
FreeNAS http://www.freenas.org
Miscellaneous Utilities
Putty http://chiark.greenend.org.uk/~sgtatham/putty/
WinSCP http://www.winscp.org
Messengers
AIM http://www.aim.com
Yahoo http://messenger.yahoo.com
Skype http://www.skype.com
Pidgin http://www.pidgin.im

Apple to open iPhone to developers

October 17th, 2007

I just read on Apple Hot News that Apple is going to release a developer SDK for the iPhone in February of 2008.  This is great news for the mobile smart phone market as it will lead to some amazing innovation.

Mobile smart phone technology is exploding right now and the iPhone is leading the charge.  Traditionally smart phones have been reserved for business users checking email with their Blackberries or Palm Treos.  Now it seems like they are popping up everywhere.  With this kind of adoption rate, I agree with Apple’s decision to have a verification process before an application can be approved for the iPhone.  It is simply too risky to let just anyone write an application that can install on anyone’s iPhone.

Getting Started with Hyperic Custom Auto-Discovery Plug-ins

October 15th, 2007

After reading through the documentation on the Hyperic website, I found it easy to get started writing custom scripts for monitoring, but not for writing custom plugins using Java.  This posting will walk you through setting up your development environment and writing a plugin that will be auto-discovered by Hyperic.  I assume that the reader is comfortable with Eclipse IDE, reading & writing Java code, and working with the Hyperic system.   You will need to have the Hyperic Agent and Server setup and configured correctly.  Additionally, the Hyperic Agent will need to be unzipped on the local machine.

My Environment

Creating the Eclipse Project

From the Eclipse IDE, create a new “Java Project” with the Eclipse new Project wizard.  Use the following options.  Note: It is very important to use the J2SE1.4 execution environment.  The Hyperic VMWare  Open Source 3.1.0 Appliance and has Java 1.4 installed.  You will get class version errors if you use J2SE1.5 or 1.6.


Once created, configure the build-path by right-clicking on the project name and choosing  “Build Path” - “Add External Jars”.  Select the <local-hyperic-install-dir>\hyperic-hq-agent-3.1.1\pdk\lib directory and select both the hq-product.jar and hyperic-util.jar.

Creating the Auto-Discovery Plug-in class

Inside the Eclipse IDE, right-click on the src folder and choose “New” -> “Class.”  Fill-in the the details to match the below screencap.

That gives us a new class with one method.

List getServerResources(ConfigResponse platformConfig) throws PluginException {
}

The getServerResources is called by Hyperic to enumerate the server resources for auto-discovery.  The getServerResources method returns a List of ServerResources, one for each server.  Below is a simple implementation that creates three hypothetical servers.  This doesn’t do very much as everything is hard-coded, but it is a good starting point for getting the plug-in integrated into Hyperic.

package com.citytechinc.articles.hyperic.plugin;

import java.util.ArrayList;
import java.util.List;

import org.hyperic.hq.product.AutoServerDetector;
import org.hyperic.hq.product.PluginException;
import org.hyperic.hq.product.ServerDetector;
import org.hyperic.hq.product.ServerResource;
import org.hyperic.util.config.ConfigResponse;

public class MyAutoDiscoveryServerDetector extends ServerDetector implements
		AutoServerDetector {

	public List getServerResources(ConfigResponse platformConfig)
			throws PluginException {

		List servers = new ArrayList();

	        for (int x=0; x<3; x++) {
        	    ServerResource server = createServerResource("My Auto-Discovery Server -> " + (x+1));

	            ConfigResponse productConfig = new ConfigResponse();

        	    productConfig.setValue("myTimeout", String.valueOf((x+1)*1000));
	            productConfig.setValue("myUrl", "http://127.0.0." + (x+1));
        	    productConfig.setValue("Description", "Description - My Auto Discovery Description ->"+(x+1));
	            server.setProductConfig(productConfig);

        	    servers.add(server);
	        }
        	return servers;
	}
}

The only code worth mentioning from above is the ConfigResponse object.  This object stores name/value pairs that will populate the configuration data for each server.  The configuration properties are defined in the hq-plugin.xml file.

Creating the hq-plugin.xml file.

Create a directory called “etc” by right-clicking on the project and choosing “New” -> “Folder”.  To create the hq-plugin.xml file, right-click on the newly created etc directory and choose “New” -> “File.”  Paste the following code into the  hq-plugin.xml file.  Note:  This file must be named hq-plugin.xml

<?xml version="1.0"?>

<plugin package="com.citytechinc.articles.hyperic.plugin">
  <filter name="domain" value="My Auto Discovery"/>
  <server name="MyAutoDiscoverServer" version="0.1c" platforms="Unix">
    <plugin type="autoinventory" class="MyAutoDiscoveryServerDetector"/>
    <config>
      <option name="myUrl"
              description="Enter the URL for this resource"
              default="http://127.0.0.1"/>
      <option name="Description"
              description="Enter the description for this plug-in"
              default="Default My Auto Discovery Description"/>
      <option name="myTimeout"
              description="Timeout for something in My plug-in"
              default="0"/>
    </config>
  </server>
</plugin>

The above XML defines everything Hyperic needs to configure our plug-in.  The <plugin> tag defines the package where our classes will reside.  The <server> tag defines the name concatenated with the version that will appear for resource name on the Hyperic UI.  The second <plugin> tag defines the type of our plug-in, which in this case is “autoinventory” and then our class name.  The <config> tag defines the options that can be configured by a Hyperic user.  The MyAutoDiscoveryServerDetector automatically configures all of the parameters listed above, but that is not a requirement.

Creating the Plug-in Jar File

To create the jar file, right-click on the project in the Eclipse UI and click the “Export” option.  Choose “Jar File” from the menu.  Fill in the options as described in the below screen capture.  Note: The plug-in filename should end in “-plugin.jar”

Deploying the Plug-in

To deploy the plug-in, copy the jar file created above to both the Hyperic server and the agent.  On the VMWare appliance, that is the following directories:

server - /home/hyperic/server-3.1.0/hq-engine/server/default/deploy/hq.ear/hq-plugins/
agent - /home/hyperic/agent-3.1.0/pdk/plugins/

For some reason, I couldn’t get the server to hot-deploy my jar file, so I had to restart both the server and the agent by running the following commands from the VMWare console:

/etc/init.d/hq-agent stop
/etc/init.d/hq-server restart
/etc/init.d/hq-agent start

Verifying the Plug-in Deployment

Once restarted, open the Hyperic website and you should see something similar to the following.

Notice under the Auto-Discovery section Hyperic found our three hard-coded servers.  Click the “Add to Inventory” button to enable Hyperic to monitor our servers.

Configuring the My Auto Discovery Plug-in

Click on the “Server Total” link in the bottom left corner of the dashboard - you will then see a screen like below.

In the above screen capture, you see that our three hard-coded servers are deployed to Hyperic.  All three have their availability listed as “?.”  This is because we haven’t coded any functionality into our plug-in.  This will be done in a separate posting.

Click on the “I” icon to the left of one of our servers and you will see a webpage that looks like below.

Here you can see that the plug-in was correctly configured in our java code.  You can edit these settings by clicking on the Edit button in the webpage.

Conclusion

In this posting we successfully created an auto-deployment plug-in for Hyperic.  An exercise for the reader is to write custom logic to find their own servers.  There are plenty of examples of writing this logic in the source archive available on the Hyperic website.  The plug-in source is available in the: C:\\hyperic-hq-src-3.1.1-490\hq\plugins directory.