Heartbeat starting my resources twice... why?

While working on implementing failover for a JBoss application in heartbeat I had it sometimes fail miserably. After examining the logs files for a while I noticed that it tried to start my service twice.. why?

This was due to multiple errors from my side:

  1. I hadn’t implemented the status call for my heartbeat resource script
  2. My script didn’t return true when asked to start and it was already started.

According to LSB standard your start / stop scripts should return true even though your service is already started.

Note to self: Learn to read the documentation and not just assume you know how it works (especially not with failover clusters… they are meant to have uptime you know.

Good readings about heartbeat and the resouces scripts.

HTTP POST requests from command line with curl

One of our customers have a JBoss application which they wanted to monitor with a script (in the long run Heartbeat2). By making a specific HTTP POST request to which the answer is known, it is possible to check if the server is running as expected. The HTTP POST request consist of a header and a body. The header is automaticaly generate from the parameters you provide curl and the body is provided in the --data parameter.

The following is an example close to what I used, and beneath a description of the parameters used parameters:

curl --insecure \
     --user monitor_user:heykcnhre \
     --header extra-header:12345678 \
     --include \
     --data '

    7
    get_email
' https://localhost:5011/check
  • --insecure ignores unverified SSL certificates
  • --user authentication information need to access the server and make the http request in the first place.
  • --header provides extra header information. You can add as many of theese as you need.
  • --include includes the header in the response (not only the body)

Curl takes many different parameters use man curl for more info.

Website moved to new server

As of right now I have moved my website to new server out in town on a 100MBit line, so it should be fairly fast. This is the first step in shutting down my server at home entirely. Lets see how it works out.

crossing my fingers and praying to the internet gods

Update: Now debianart.dk have been moved as well.

Gaim: get back Ctrl + Enter to send message

Some time ago I think it was when I made the switch from Gaim 1.x to 2.x sending my instant messages with Ctrl + Enter stopped working. I have lived with it for along time but it kept annoying me… a good friend of mine found the solution on another website and today I took the time to actually do it.

The thing beneath is kinda ripoff / copy-paste :D

Create the file .gtkrc-2.0 in your home directory with the following content:

gtk-key-theme-name = "Emacs"
gtk-can-change-accels = 1
binding "gaim" {
    bind "Return" { "message_send" () }
    bind "Return" { "insert-at-cursor" ("\n") }
}
widget "*gaim_gtkconv_entry" binding "gaim"

Mono coding: Capturing right clicks in a Gtk.TreeView

I had a hard time figuring out how to capture a right click on a TreeView, which I needed to be able to make a context menu or popup menu or what ever you wanna call it. The way I expected it would work didn’t… I think it have something to do with a change in Mono some time ago (Why don’t I get ButtonPressEvents from my Button/Treeview?).

This example is based on the “Shortcuts - Writing Less Code” example from the www.mono-project.com website. The main difference is that the TreeView is no longer setup in the main class but is now a separate class with the function OnButtonPressEvent overwritten.

public class TreeViewExample {
	public static void Main ()
	{
		Gtk.Application.Init ();
		new TreeViewExample ();
		Gtk.Application.Run ();
	}

	public TreeViewExample ()
	{
		Gtk.Window window = new Gtk.Window ("TreeView Example");
		window.SetSizeRequest (500,200);

		MusicTreeView tree = new MusicTreeView ();
		window.Add (tree);
		window.ShowAll ();
	}
}

// Creating a new class MusicTreeView which is derived from the TreeView class
public class MusicTreeView : Gtk.TreeView {

        public MusicTreeView ()
        {
        		Gtk.ListStore musicListStore = new Gtk.ListStore (typeof (string), typeof (string));

        		this.AppendColumn ("Artist", new Gtk.CellRendererText (), "text", 0);
        		this.AppendColumn ("Title", new Gtk.CellRendererText (), "text", 1);

        		musicListStore.AppendValues ("Garbage", "Dog New Tricks");
        		this.Model = musicListStore;
        }

        // The TreeView has a build in function which is called upon a OnButtonPressEvent
        // We override the function to capture right clicks with the mouse
        protected override bool OnButtonPressEvent (Gdk.EventButton evnt)
        {
                if(evnt.Button == 3) {
                        System.Console.WriteLine ("Right click");
                        return true;
                }
                // Now if we would ever get this far
                // we run the TreeViews OnButtonPressEvent function
                // to make sure everything else works as normal
                return base.OnButtonPressEvent(evnt);
        }
}

Update: I wrote a new “right click in Gtk.TreeView” example.