“Ahhh green”

At times life can be pretty complicated... backing up your home PCs and safeguarding your family files shouldn’t be, and when designing Windows Home Server the conscious decision was made to try to limit the number of configuration knobs and simply the information given so that in the end managing the server and knowing the general health of your home network would be pretty easy, even from a distance.

Instead of requiring an administrator to login daily or check their email to find out of anything had gone wrong, we bubble up a general health state which will alert not only the server administrator to potential problems, but also anyone else in the house.

The most commonly seen is through a notification icon that sits next to the clock of each client PC:


Within the console we also display the same value:


This same can be seen on the front of many OEM built Home Servers such as on the HP MediaSmart EX485:


and the Acer Aspire easyStore AH340-UA230N:



With the above one can simply say “ahhh green” (or blue) and know that all is well in the home... at least with regards to ones data

All of these work great... but require you to either be running the client tray app (with the “Display Network Health Notifications” option checked), be logged into the Home Server Console or be within visual range of ones Home Server.

Did you know you can use this same information in your own applications?

Unfortunately there is no quick and easy GetHealthState() method within the Windows Home Server SDK, instead the value is determined by going through each outstanding Notification and determining if any exist that are marked as a Warning or Error... and if so we consider the overall state to be same as the most severe, non-suppressed notification.

Over on MSDN there exists a bit of sample code that demonstrates how to do this on demand, though with a few minor tweaks you can turn it into something more asynchronous that will alert you as to when the health has changed:

        public class HealthChangedEventArgs : EventArgs
            public HealthState CurrentHealth { get; private set; }
            public HealthChangedEventArgs(HealthState health)
                this.CurrentHealth = health;
        public event EventHandler<HealthChangedEventArgs> HealthChanged;
        protected void OnHealthChanged(object sender, HealthChangedEventArgs e)
            EventHandler<HealthChangedEventArgs> temp = HealthChanged;
            if (temp != null)
                temp(sender, e);
        HealthState lastState;


And then update the NotificationChanged function ever so slightly:


   1:          public void NotificationChanged(string UniqueID, WHS_Notification_Type Type, WHS_Notification_Severity Severity, int IsSuppressed, string textHeader, string textDescription, string helpFilename, string helpSection, string helpLinkText)
   2:          {
   3:              NotificationItem item = new NotificationItem(UniqueID, Severity, IsSuppressed, textHeader, textDescription, helpFilename, helpSection, helpLinkText);
   5:              //if an add, add/overwrite item to existing list
   6:              if (Type == WHS_Notification_Type.WHS_NOTIFICATION_ADD)
   7:              {
   8:                  notificationItems[item.UniqueID] = item;
   9:              }
  10:              else if (Type == WHS_Notification_Type.WHS_NOTIFICATION_REMOVE)
  11:              {
  12:                  //If remove, if item exists remove it
  13:                  if (notificationItems.ContainsKey(item.UniqueID))
  14:                  {
  15:                      notificationItems.Remove(item.UniqueID);
  16:                  }
  17:              }
  19:              //Get current health, if different than last, raise event of new state
  20:              HealthState currentState = GetHealthState();
  21:              if (currentState != lastState)
  22:              {
  23:                  lastState = currentState;
  24:                  OnHealthChanged(this, new HealthChangedEventArgs(currentState));
  25:              }
  26:          }

It’s just that simple.

Best of all... this code can be run on the server or on any client PC that is joined to a Windows Home Server and where both are running and communicating, recently MVP Donovan West recently released his first add-in, @WHSTweet which publishes your health to twitter for remote monitoring using this same information.

Next week I’ll show another simple way you can take this information and leverage it to find out your general health from afar...ish.

Comments (0)

Skip to main content