Sponsored By Aspose - File Format APIs for .NET

Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!

Enter Hawkeye

At work we have a lot of WinServices, and monitoring their health can often take a complex blend of implementation knowledge and log reading ability. To help reach across the DevOps divide and help my fellow brothers in IT I have often wanted a way to show them (and anyone really) if a given application is healthy or not.

Thanks to my buddy Chris for hooking me up with some sweet wrappers around the framework built in HttpListener I now have the beginnings of something that I think will do just that, enter the Hawkeye.

Hawkeye is a VERY simple, self hosting web server combined with a very simple interface that will let you implement red/green health checks. We use this to confirm that the application is talking to the correct database, that it can open and close connections. That it can find its MSMQ Queue and has the needed ACLs. Currently the output looks like this (note: I am not a designer)

hawkeye screenshot

Not pretty but it gets the message across. :)

How do you write a validator, you say. Why like this:

public class MyCheck :
    EnvironmentValidator
{
    //currently requires a default constructor
    //future versions will support using your container
    public void Vote(Vote vote)
    {
        if(DateTime.Now.Second % 2 == 0)
        {
            vote.Fatal("ERROR");
            return;
        }

        vote.Healthy();
    }
}

But how do I host it? Like this:

static void Main(string[] args)
{
    HawkeyeConfigurator.Configure(cfg=>
    {
        //type scanning is high on the list
        cfg.RegisterValidator<MyCheck>();
        cfg.RegisterValidator<CheckTwo>();

        cfg.HostInProcess(8008); //the port to bind to
    });

    Console.ReadKey(true);
}

So that is the gist of hawkeye. We are just starting to use it at work and it is already becoming quite helpful. Both in documenting everything that we need to have care and feeding of but also just double checking that we haven’t forgotten anything.

I would expect to see some kind of aggregator show up in topshelf as a ‘shelf’ module soon as well, so that topshelf, and masstransit, etc can take advantage of this functionality.

source @ github

About Dru Sellers

Sr. Software Engineer at Dovetail Software.
This entry was posted in Small Ideas. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • ping g15

    Pretty! This was a really wonderful article.. After read it, I’m very impressed.
    Thank you for your provided information.

  • Titleist AP2

    Pretty! This was a really wonderful article.. After read it, I’m very impressed.
    Thank you for your provided information.

  • Hakeem

    Yep, that’s what I was thinking of. Maybe have an overload of Vote that takes the service name. Or, perhaps a lambda that returns more than the service name?

    On a related note, do you plan to have another group for this and the Stact framework, or have questions answered on the MT group or continue here on CB 😉

    Thanks!
    Hakeem

  • Anonymous

    You could change this pretty easily to go after any existing service. I don’t yet have a solid way to dynamically add additional checks, but this works today.

    public class LocalServiceValidator :
    EnvironmentValidator
    {
    public void Vote(Ballot ballot)
    {
    using(var c = new ServiceController(“MSMQ”))
    {
    if(c.Status != ServiceControllerStatus.Running)
    {
    ballot.Fatal(“Netlogin is not running.”);
    return;
    }
    ballot.Healthy();
    }
    }
    }

  • Anonymous

    Took me a bit to grok what you are looking for but yes this should be completely doable. Let me see if I can do it this week. :)

  • Hakeem

    Hi Dru,

    This is really awesome! Something we needed as we had so many services. I had a question about applying this to services in the wild. Is that done in the Vote implementation where you query the health of the service using ServiceController or some such class and return the ballot based on that?

    Thanks!
    Hakeem

  • http://hawkeye.codeplex.com Olivier

    I noticed you renamed your tool as Klinger! Sounds great!
    By the way, I am maintaining (when I can find enough spare time) the “other” Hawkeye. And its up-to-date home is now http://hawkeye.codeplex.com/ – free ad :).

    Regarding your own Klinger/Hawkeye, it seems pretty valuable and I am in the process of downloading it.

  • Anonymous

    Yup, but for that I have other evil plans. Mwa ha ha ha.

    Yeah, I am thinking about ways to add in metric gathering as well. Right now I am focusing on just the basic health checks and making it easy to use and collectable from multiple points. If it is something that you are really interested in having, email me and I can share what I have in mind in more detail.

    :)
    -d

  • http://twitter.com/dingwallr Rich

    Would it be possible to add an overload for Vote.Healthy(string message) e.g. to provide a version number, or “Database up (ping: 3ms)” message?

  • Anonymous

    Just pushed an update that includes a timer and type scanning. as well as getting things set up for port forwarding.

  • http://twitter.com/dingwallr Rich

    Very cool! Got some apps to throw this in right now..

  • Scott

    EagleEye?

  • Anonymous

    I have been informed that there are a few and am considering renaming the project. :)

  • http://twitter.com/ondrejsv Ondrej Svacina

    This is exactly what I was looking for just two days ago!

  • Tudor

    There is another very popular tool with the same name: http://www.acorns.com.au/Projects/Hawkeye/

  • Pingback: The Morning Brew - Chris Alcock » The Morning Brew #752

  • Pingback: Tweets that mention Enter Hawkeye | Dru Sellers -- Topsy.com