Building WHS & CodeSnippet: Building WHS Add-ins

10 October 2008 ,    2 Comments

Awhile ago I heard the saying “Microsoft is a platform company” (rather than lots and lots of products), one great example of that is Windows Home Server. WHS’s is built upon Windows Server 2003, so you can create apps and extend it much like any other Windows OS, but you can also extend the “Home Server Console” very easily using Visual Studio/.NET.

Requirements

Setting up your WHS Add-in

Create a .NET 2.0 Library Project (WHS does not ship with .NET 3.0/3.5, although they will work if installed), then you need to reference two libraries to build WHS add-ins which can be found on your WHS box. That’s right, there is no SDK download, the required libraries are found on your server.

From “C:\Program Files\Windows Home Server” copy HomeServerExt.dll and Microsoft.HomeServer.SDK.Interop.v1.dll from your server to your development machine, then reference both of them in your solution. This will give you the namespace Microsoft.HomeServer.SDK.Interop.v1. Alongside those, for the UI you’ll need to add references to System.Forms and System.Drawing.

WHS requires a particular assembly name structure, so right click on your project, change the Assembly name to “HomeServerConsoleTab.<yourprojectname>”, ie “HomeServerConsoleTab.WHSStats”

WHS Stats

image

WHS Stats uses Windows Management Interface (WMI) to return the names of several pieces of hardware on the server. This could be turned into a fully fledged hardware monitor, but I’m trying to keep it a very simply example that has more real world value than the veteran Hello World.

WHS Tab Add-ins (which appear in the main WHS Console screen versus Settings Add-in’s which appear after you click Settings from the Console) require two classes. In this case it’s WHSStats(.cs) which implements Microsoft.HomeServer.Extensibility.IConsoleTab and WHSStatsPanel(.cs), a UserControl, which contains the UI.

WHSStats.cs

using System;
using System.Text;
using Microsoft.HomeServer.Extensibility;
using Microsoft.HomeServer.SDK.Interop.v1;
using System.Drawing;
using System.Collections.Generic;
using System.Management;

namespace WHSTempAddin
{
    public class WHSTempAddin : Microsoft.HomeServer.Extensibility.IConsoleTab
    {

        private IConsoleServices services;
        private WHSTempAddinUI nPanel;
        private WHSInfoClass whsInfo;

        public WHSTempAddin(int width, int height, IConsoleServices consoleServices)
        {
            nPanel = new WHSTempAddinUI();
            whsInfo = new WHSInfoClass();

            this.services = consoleServices;
            nPanel.Load += new EventHandler(nPanel_Load);
        }

        public Bitmap TabImage
        {
            get { return Properties.Resources.WHSTempAddinImg; }
        }

        public bool GetHelp()
        {
            throw new NotImplementedException();
        }

        public Guid SettingsGuid
        {
            get { return Guid.Empty; }
        }

        public System.Windows.Forms.Control TabControl
        {
            get { return nPanel; }
        }

        public string TabText
        {
            get { return "WHS Stats"; }
        }

        void nPanel_Load(object sender, EventArgs e)
        {
            nPanel.lstCPUDetails.DataSource = getCPUDetails();
            nPanel.lstGPUDetails.DataSource = getGPUDetails();
            nPanel.lstNetworkDetails.DataSource = getNetworkInterfaceDetails();
        }

        private List<String> getCPUDetails()
        {
            List<String> data = new List<string>();
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT *
                                                                 from Win32_Processor");
            foreach (ManagementObject adapterObject in searcher.Get())
            {
                data.Add(adapterObject["Name"].ToString());
                data.Add("CPU Load: " + adapterObject["LoadPercentage"] + "%");
            }
            return data;
        }

        private List<String> getNetworkInterfaceDetails()
        {
            List<String> data = new List<string>();
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("select *
                                        from Win32_PerfRawData_Tcpip_NetworkInterface");
            foreach (ManagementObject adapterObject in searcher.Get())
            {
                UInt64 i = (UInt64)adapterObject["CurrentBandwidth"];
                data.Add("Adapter name: " + adapterObject["Name"]);
                data.Add("Current bandwidth: " + (i / 1000000) + "MB/s");
                data.Add("KBytes In/sec: " +
                         ((UInt64)adapterObject["BytesReceivedPersec"] / 100000) + "KB/s");
                data.Add("KBytes Out/sec: " +
                         ((UInt64)adapterObject["BytesSentPersec"] / 1000000) + "KB/s");
            }
            return data;
        }

        private List<String> getGPUDetails()
        {
            List<String> data = new List<string>();
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT *
                                                            from Win32_VideoController");
            foreach (ManagementObject adapterObject in searcher.Get())
                data.Add(adapterObject["Name"].ToString());
            return data;
        }
    }
}

The constructor, TabText, SettingsGuid, TabImage and GetHelp the minimum methods to implement for a WHS Add-in. Key things to note, TabImage is a Resource added to the project, its recommended to be a 32×32 image (I used one slightly larger, that could explain why it is skewed off to one side); TabText is what appears on the Tab to select your add-in so don’t make it too long!

The rest of the code is hooking up the listboxes (below) to WMI queries about the hardware.

WHSStatsPanel.cs

image

Building and deploying the project

These particular instructions are mostly copied from MSDN

  1. Add New Project, select Setup and Deployment Projects, and then select Setup Project.
  2. In the File System editor (of the Setup Project), select the Application Folder node. Right-click the Application Folder, point to Add, then select Project Output.In the Add Project Output Group dialog, verify that Primary Output is highlighted. Click OK to add the project output and close the dialog box.
  3. In the File System editor, right-click Application Folder and then click Properties Window. In the properties window, in DefaultLocation, type [ProgramFilesFolder]\Windows Home Server.
  4. In the Solution Explorer, expand the Detected Dependencies. Right-click HomeServerExt.dll and Microsoft.HomeServer.SDK.Interop.v1.dll, then click Exclude.
  5. Now in Visual Studio 2008, you’ll need to set the .NET Framework under Launch Conditions to .NET 2.0.That is View –> Editor –> Launch Conditions. Regardless of whether you’ve selected .NET 2.0, 3.0, 3.5 or 3.5 SP1, this needs to be set. VS2008 defaults to .NET 3.5 in the launch conditions, which stops the installer from even running!
  6. This step is “sort of” optional. If you plan to Remote Desktop into your server and run the installer that way, you don’t need to do this…but if you plan to run the installer through the Windows Home Server console, you need to place the installer in \\Server\Software\Add-Ins. Even then, you need to insert the “WHSLogo” property (and set it to 1) in the MSI before WHS will pick it up.

    To do this, you’ll need ORCA (it’s in the Windows SDK, see above for the links to that; Once you install the SDK, you’ll find the ORCA installer in C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\Orca.MSI). image

    • With ORCA open, click File, click Open, browse to the location of the MSI file that contains your Add-in, and then click Open.
    • In the Tables column, click Property.
    • Right-click anywhere in the column area where the Property and Value columns are listed, and then click Add Row.
    • In the Add Row dialog, type WHSLogo for the Property, click Value, and then type 1. Click OK to enter the property and to close the dialog.
    • Click File, click Save, and then click Exit to close ORCA.

image


 

Building WHS: Remote Desktop instead of Console

16 September 2008    No Comments

One of the cool things about WHS is the ability to remotely connect to the server via a webserver, or if you need a bit more control you can use RDP to connect to any running  (that is, turned on and running the Connector app) inside your network. By default you can’t remote into the server – you get the “Home Server Console”.

If you do want the full remote desktop, open up C:\Inetpub\remote\rdupload.aspx in Notepad, find the line MsRdpClient.SecuredSettings.StartProgram = “HomeServerConsole.exe -b” and replace (or copy and comment out the first line) with MsRdpClient.SecuredSettings.StartProgram = “explorer.exe”.

Save and exit, and you’re done.

Be aware this gives you full access to your server, so you really should use as strong a password as what you can manage.


 

Build a Windows Home Server: Building Hardware

14 August 2008    11 Comments

Parts list

Changing technology has slightly altered my build list. With the launch of Intel’s G45 motherboards, I decided to upgrade my HTPC with a Gigabyte GA-EG45M-DS2H, meaning I had a spare Asus P5K-VM which knocks the previously selected motherboard off the list.

I decided to go for a single 1TB drive – while it didn’t represent the best price per gigabyte (currently 640gb HDD’s do, something like 14c/GB vs 18c/GB), it wasn’t overly expensive, gave me the convenience of a single drive with a lot of storage, and means I’ll have more filespace by the time I exceed all my SATA ports (P5K-VM has four SATA ports).

Part Model Price (AUD)
CPU Intel Celeron E1200 $45
Motherboard Asus P5K-VM ~$120*
Case Antec NSK6850 $135
Power supply 430w Earthwatts Included with above case
Hard drive Western Digital "Green Power" 1TB SATA $182
RAM 1gb A-DATA DDR2-800 $25
CPU Cooler Scythe Mini Ninja $59
     
  Total $566

*Not the price I paid when I bought it, but current going price in Victoria

That’s $34 under budget! Had I bought the NSK4480 ($95) and gone for the cheaper GA-G31M-S2L ($61) the total would have come down to a much more impressive $467 (or $133 under budget, even less if you don’t mind more noise and could drop the Scythe CPU cooler).

I realise this doesn’t include the cost of Windows Home Server (~$200) which bumps it up to $766 (/$667 if you chose the cheaper parts). At this stage a simple NAS unit or something along the lines of an Apple Time Capsule ($699 for 1TB) may seem like better value, but the thing to remember is this system can be easily upgraded to 4TB of storage by just putting more drives in, or up to 9TB (then you approach physical limitation of the NSK6850) by adding a SATA controller card! Most simple NAS units (at least, cheaper than this WHS build) have only one or two drive bays!

Oh, and for the record, I was after the NSK4480 instead of the NSK6850, but my local MSY were out of stock at the time. The differences come down to size and price, where the NSK4480 is smaller (7 vs 9 expansion bays) and costs less ($95 vs $135).

The Cooler

IMG_8743_NoCrop

You may be wondering why spend so much on cooling such a low end CPU, when the stock cooler barely breaks a sweat on it? Well, despite ‘mini’ being part of it’s name, the Mini Ninja (above) is massive – it can take a lot of heat. Combine that with the slow spinning 120mm case fan included with the NSK6850, and temperatures have remained under 35c (mostly runs at 22c, while being under my desk in a low ventilated area) and the CPU cooler doesn’t contribute to noise generation at all – it’s hard to tell when this thing is operating!

Power usage

As I stated at the start of this series of posts, I wanted a system that had a low power draw. Measuring this system, it uses somewhere between 54 –> 65w, sitting mostly on 55w. To be perfectly honest, I’m a little disappointed, but it turns out the 430w EarthWatts PSU is ~70% or less efficient at these draw levels. With that in mind, that brings the realistic draw of the system down to 38 –> 45w. When I’ve got time, I’ll look at swapping in the 380w PSU from my HTPC, to see what the differences are.

At 60w (we’ll say this is the average draw), that equates to $68/year to run. (365days * 24hours * 60watts * $0.1294 (cost per kWh Origin Energy charge me) = $68.012)

Component choice helps keep the power levels low – the E1200 is a relatively low (processing) power CPU and as such uses less power than many other CPUs, the hard drive consumes up to half the amount of power of other drives at the expensive of throughput (the drive spins between 5400 and 7200RPM) and although negligible, a single RAM stick obviously consumes less than filling all four RAM slots.

Gallery

IMG_8744_NoCrop IMG_8739_NoCrop IMG_8741_NoCrop IMG_8743_NoCrop IMG_8781 IMG_8782


 

Build a Windows Home Server: Case and PSU

12 June 2008    No Comments

It’s been a month since part one (CPU+Motherboard), and I must admit the comments didn’t help me choose at all! Why? The comments didn’t lean one way or another.

I’ve decided in the end to go with an Intel E1200 and Gigabyte GA-G31M-S2L. Despite renewed searching for AMD power usage including the Semprons, the E1200 still seemed to have the edge (especially when you factor in pricing and availability). The difference in power at this end of the spectrum is pretty low – more power will be wasted by an inefficient PSU than an inefficient low end CPU.

This means going with the current market prices, the CPU is $50 and motherboard $70, meaning there is a healthy $480 in the budget for case, power supply, hard drive(s) and any third party cooling required.

My requirements

The ideal case would be a tiny unnoticeable case, yet somehow like the Tardis able to store 50 hard drives; and the ideal PSU would be 100% efficient, making no noise at all.  Neither are going to happen, but what’s the next best thing?

Since I’ve chosen to go with a motherboard with four hard drive ports, I want the case to be able to hold four hard drives. Optical drive really isn’t a concern, because (with any luck) I’ll only be installing WHS once.

Meet the Contenders

The reason I’ve chosen to combine both cases and power supplies is that although you can get some awesome looking cases, or some with fantastic functionality, those cases tend to go for AUD$200+, and then to get a “decent” (and by decent, I mean quiet and won’t burn out once you overload it by plugging in three hard drives, not 1kW) power supply will set you back another AUD$100->$150.

This system even on load and with 4 drives, will struggle to make it to 100w (actual draw, before factoring in power supply efficiency, would be about ~10w average per HDD, with a top of 40w for motherboard and cpu combined). Power supplies are less efficient at very low loads, so the closer the PSU’s maximum wattage is to the actual/projected draw, the higher the efficiency should be. On the PSU front its very hard to find anything below 300w that claim to meet “80PLUS” standards, with Seasonic making a hard to find (in Australia) 300w model, Zalman producing a 360w. Thermaltake have an interesting 5.25″ bay model which puts out 270w.

media That was until I found the picoPSU, which was looking like a real winner…until I realised it really only has one or two hard drive power connectors!This thing is really tiny and efficient though, “so tiny that 70 picoPSUs would fit inside the casing of a normal ATX power supply”!
nsk1300_q NSK4400_q To move onto something with more connectors, we’re looking at the standard size ATX PSU. The Antec EarthWatts line of power supplies are cheap, low noise, fairly efficient, and have a low wattage. I ended up with a 380w EarthWatts PSU in my HTPC build.The “New Solution” (NSK) range of cases from Antec provide pretty good price/performance, and all come with an Earthwatts PSU. The NSK1380 (350w, ~AUD$120), NSK3480 (380w, ~AUD$120), NSK4480 (380w, ~AUD$100) and NSK6580 (430w, ~AUD$135) all look like real contenders to me (the NSK2480 is what was used in my HTPC).

They all share roughly the same design – just larger than the model number below it, except for the NSK1380 which is a cube form.

(There is also the NSK4000 and NSK6000 which appear to be the NSK4480 and NSK6580 chassis respectively, sans power supply. The damage for the NSK4000 is only AUD$69 however, meaning it could be more suitable to be combined with the picoPSU.)

file1185764842437 I must admit CoolerMaster, while a well and truely established giant in the PC Case industry, isn’t one I’d normally choose from “low end” cases. I suppose it helps that this case is $200 without a PSU, meaning it is over budget and definitely not a low end case. The iTower 930 looks like your standard beige (make that silver and or black these days!) ATX case with one “small” difference – 4 hot-swappable SATA drives. It includes little caddies to put your drives in, then you just slot them into the computer.While not a new idea, being SATA means not only do you not have to open the case to add a drive, you don’t have to even shut down the machine!

There are other advantages too, the iTower 930 is made from mostly steel, meaning it should produce less vibration than cases with a majority of aluminium. Whether or not that’s the case is another matter.

Decision Time

Sure, the iTower is probably the most “featuresome” case on this list but coming in at ~AUD$200 seriously hampers the rest of the budget, especially when you consider it still needs a power supply. Can the iTower compete with the cheaper NSK series (with or without the EarthWatts PSU)? Is the Antec EarthWatts efficient enough to knock out a picoPSU? Can the picoPSU safely be fitted with adapters for more drives? Have I left anything off my list?


 

Build a Windows Home Server: CPU & Motherboard Selection

13 May 2008 , ,    9 Comments

Windows_Home_Server_logo

After my HTPC building series of blog posts, a Channel8‘er was disappointed that I didn’t include others in the building process of it. This time I’ve decided to make a Windows Home Server box, this time including the community to help me choose the parts.

Unlike Channel 8′s Max Builds a PC series, I cannot be giving this away (finances simply don’t allow it), so its’ purely for participation value. I’ll try and round up some prizes (maybe Expression Studio 2? I’ll have to see what restrictions the copy I’ll be getting has), but can’t promise anything.

Why build a server, based on WHS? WHS is easy. It’s easy to setup, it’s easy to use, it’s easy to maintain. I have better things to be doing that learning the ins and outs of either Windows Server or Linux to perform the same functions that WHS does out of the box. Well, that and Nick has one, so I’m jealous.

Minimum system requirements

The following specifications are the minimum defined by Microsoft for Windows Home Server

My requirements

When building most “normal” computers (desktop use/work use/whatever), the two main factors are usually performance and price. The usual process is to get as much power in to as small a budget as possible.

While this remains true for my desired server, there are other characteristics that have equal or greater importance. For example, low power usage is very important due to the “always on” nature of a server, and because of the location the server will run, low noise is equally important.

In order of importance, those key factors are:

Price

The budget for this project is AUD$600 (give or take $50) for case, power supply, hard drive(s), motherboard, CPU, ram and any additional cooling needed. This does not include the WHS license cost.

Meet today’s Contenders

This post looks specifically at CPUs and Motherboards. Why both? Well, for the lowest power/noise solutions, often the CPU either only comes with a motherboard or is actually soldered in.

From a CPU point of view, my research based on pricing and/or power usage leads me to believe that the “real” contenders are:

Information

From the motherboard point of view, it depends on the CPU chosen.

Decision Time…

What would you choose, for both CPU and motherboard, taking cost, power and features into consideration? Is limiting the server to 2TB (before buying a PCI/PCIe SATA controller) balanced out by low power usage of VIA, or do the ‘big boys’ from AMD and Intel win the day? Have I rounded up all the viable options?