Ducksboard API for .Net

Last time, I wrote about how neat I thought the Ducksboard app was.   I found a nice little project over on github that wrapped up the update components of the api pretty well.  So I could easily create a dashboard, and configure my application to push data to Ducksboard using a .NET component with nuget support and coding techniques I’m used to.

I started playing and noticed that the Dashboard API (used to create Ducksboard dashboards, not update them) wasn’t implemented, and I kind of needed it.  We have a product that could use a dashboard, and I wanted the dashboard functionality  to go something like this:

App starts up, checks to see if there’s a Ducksboard dashboard for client x.  If not, create it, populate it with widgets, and then go on doing work stuff, occasionally updating the Ducksboard dashboard with metrics, etc.

All this creation stuff happens at ducksboard with their Dashboard API.

The Dashboard API can be used to manipulate all objects found in Ducksboard: dashboards, widgets, external accounts, public access tokens and so on.

I contacted the author of the Ducksboard API for .NET to see if he was working on this api, and he wasn’t, so I coded up what I needed trying to stick with the original authors api design as much as possible, submitted a pull request, and now it’s part of the project.  What the heck did we do before OSS? :)

Anyhow, there’s some awkwardness in the code there (mostly due to my limited knowledge of json serialization, but also due to some constraints of their api), but it is working pretty nicely if you know what you want to do with their api.  For example, the following few lines of code creates a dashboard with a leader board component :

One thing I’m grappling with is the long term viability of using Ducksboard for corporate dashboards.  I’m exploring the idea, but am waiting to see if our clients will go for a super nice, accessible-from-anywhere dashboard, with reduced complexity on in house servers, and all of the benefit that that brings, or if they think it’s too risky to send out data to a third party…  For now, I’m happy to have it there as an option for those that want to use it.

Posted in .NET, Cloud Hosting | 2 Comments

A Log4Net Ducksboard Appender

Ducksboard, is absolutely the most fun I’ve had on a web api in a long time.. “Monitor your metrics with Ducksboard, a real time visualization of your key performance indicators..”  Basically, you make dashboards with it.  It’s got built in pugins for tons of other apps (basecamp, github, twitter, pingdom etc. etc.) and a really nicely done restful api where you can manage your dashboards.

I’m just playing at this point, but I’m thinking that I’d like to use it to create some customer dashboards to show real-time metrics that are applicable to our apps.  One thing I was thinking was an uptime dashboard that could show the health of our services and devices, sort of like this.

Screen Shot 2013-01-26 at 6.29.28 PM

One way I can easily post to this board whenever there is an error in any of our apps is to create a Ducksboard Appender for log4net.  I used a nice little .net wrapper for Ducksboard and made the following appender :

Configure it like this :

I’m hoping to contribute to the Ducksboard api for .NET and add the dashboard API, which allows you to create dashboards in code.  A new installation of one of our services could create a new monitoring dashboard, add all of the relevant graph and informational displays, then start updating it.

Disclaimer : I recently asked Ducksboard to become “Friends” of CodeBetter.Com so you’ll see them linked at the bottom of the site, but this post is unrelated.

Posted in .NET | Leave a comment

Fun with the Nancy Self Host!

Nancy Logo

If you’re not familiar with the Nancy framework for hosting HTTP services in .net, you owe it to yourself to check it out.

From the docs:

Nancy is a lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono. The goal of the framework is to stay out of the way as much as possible and provide a super-duper-happy-path to all interactions.

For a nice audio introduction, check out this recent episode of Hanselminutes Understanding NancyFx With Richard Cirerol.

One of the things I like best about Nancy, other than it’s super fun and easy to stand up and build HTTP services, is the Self-Host.

At work, one thing we make are some networked edge-devices for things like kiosks that are normally deployed into the field at our client sites.  One of the things I find super helpful for configuration, debugging and troubleshooting, is a simple HTTP endpoint.

Imagine a problem with an edge device out in the field – like a kiosk, camera, DIO controller, etc.  One of the first things a sysop may do is browse to the device’s HTTP endpoint, pull up a web page, check configuration and logging.  There are certainly more sophisticated ways of going about management and troubleshooting, but for simple cases an administration web page works well. It often can save a sysop a trip out into a hazardous environment if a quick fix can be done remotely, even better using a secure browser session.

So what are your options for doing this?  If you already have an existing .NET application running on your device, with state, etc. spinning up IIS and a web site isn’t a great option.. You will have to tackle issues of sharing data, installation of the web site every time you setup a new device, the overhead of running IIS, IIS security, just to name a few.  What if there was a simple way of generating an HTTP endpoint? – Enter Nancy Self Hosting.

With the Nancy Self-Host, you can easily make your HTTP endpoint part of your existing application, which means you can share state, installation process, security, authentication etc.  And you can do it all on the “Super Duper Happy Path.”  Here’s how easy it is to host Nancy in a console app:

How about from a Service?  Here’s how easy it is to host Nancy from within your own TopShelf service.

I’ve put a quick repo up on Github as a demo for hosting Nancy under TopShelf.

In short, I personally see a huge sweet spot for Nancy in these cases where you need a simple management endpoint.  Next time, I’ll blog about how to do this from NServiceBus when using the NSB host – even sharing the NSB IOC container.

Happy Self  Hosting!

Posted in .NET, Uncategorized | Tagged , , , | 3 Comments

Setting up Munin with Nginx and Ubuntu 12.10 (Quantal Quetzal)

A few years ago, I posted about our over-architected setup here at Codebetter. I had fun working with Rackspace cloud slices, and getting this all to run on ridiculously cheap, 256 M linux hosts.   One of the tools I’ve come to depend on for monitoring is Munin.

Munin is a networked resource monitoring tool that can help analyze resource trends and “what just happened to kill our performance?” problems. It is designed to be very plug and play. A default installation provides a lot of graphs with almost no work.

Here’s the graph of CPU usage since yesterday. Munin let’s you drill down into almost any aspect of your system, with plugins to allow you to monitor almost any service you may be running, and even support for monitoring Windows boxes.

Munin CPU monitoring

Check out this graph from Codebetter’s main app server’s CPU. How nice is that?

I’ve recently migrated to new servers yet again, and I ran into a few gotcha’s for Ubuntu 12.10 users that I’d like to post here.    It seems that most apps (WordPress for example) are much easier to configure under Apache than Nginx, and Munin is no different. If you crave the performance and configurability that Nginx brings, you’ll probably be used to taking a few extra steps to get applications to run properly.  This page from the Munin docs has some good starting points for setting up under Nginx, but even so I got stuck.  There’s one sentence that says the following:

Note: Depending on your installation method, the “munin-*-graph” programs may be in another directory. Check Makefile.config if you installed from source, or your package manager if you used that to install.

This may be obvious to some, but I ran into all sorts of problems until I understood what changes I had to make for everything to work.

1) Correct the path to the munin-cgi-graph and munin-cgi-script perl files, when you create your fast-cgi sockets

2) Correct NGINX configuration, here’s mine. Notice the location /muni-cgi/ changes to /cgi-bin/. Also notice that I’m running Munin at /, not /munin/ on my web server.

That’s it!  Happy monitoring!

Posted in Monitoring, Munin, Nginx, Ubuntu | 3 Comments

Updates to CodeBetter.Com’s Cloud Setup

A few weeks ago I mentioned that we were now hosting CodeBetter.Com in the Rackspace cloud.   Overall I was happy with the setup, but one thing kept bugging me. Apache was using a LOT of RAM, and I had to end up scaling the middle tier to two 500M cloud slices  in order to keep the site running smoothly.  I got one comment that made me cringe since I knew I was having to throw too much hardware at this problem:

Err.. why do you need this much hardware? Surely a blog with 32k subscribers doesn’t need 4 machines, or even decoupled web and database stacks!

I responded that these cloud slices are cheap (and they are @$15/month) and I DO stand behind the decision of having a tiered deployment should we have to scale, but at the same time he was right.  A site as small as ours shouldn’t need that much of a footprint.  Don’t get me wrong – it’s nice to know that we can scale out should we need to, but I was determined to downsize our current deployment.

I had heard that it was possible to run WordPress under NGINX (the highly performant web server alternative to Apache) but to do it right, you have to jump through some hoops to get it up and running, like building PHP and configuring it to run within the PHP FastCGI Process Manager. After a couple of days of tweaking, we’re happily up and running on ONE NGINX/PHP-FPM middle tier server with 256M ram (behind one NGINX reverse proxy and in front of our MySql server)!  It’s probably still overkill, but I like it :)

I found a few resources which helped me get NGINX/PHP/Wordpress Multisite working, one WordPress support topic and this excellent series of posts by Pranav Rastogi with step by step instructions.  If you’re going to do this I suggest checking these out.  Also,  should you be interested in the gory details of getting this setup,  I’ve modified these steps and created a Fabric configuration script to automate this process, which you can find up at my github account.

-Brendan

Posted in Uncategorized | 1 Comment