Sunday, February 5, 2012

Home Circuit Power Monitoring - Part 2

It has been about 6 months from when I installed per circuit power monitoring in my home (http://www.mikepoulson.com/2011/07/new-home-power-monitor.html).

In January 2012 I started injecting all my power data into a SQL DB (SQL Express).  This has allowed me to use Tableau (www.tableausoftware.com) to analyze the utilization.

Here is an example of that power consumption in my House. 


You can see my office plugs (where my Media Center is located) is my #1 consumer of power.  You can see that the TV and Kitchen outlets are in second place.

I used the data shown here to determine that my 1st floor lights use a lot of power.   This weekend I replaced those 400 Watts of lights with new LEDs (Phillips Ambient LED, http://www.amazon.com/Philips-409904-Dimmable-AmbientLED-12-5-Watt/dp/B004IUMGV4).

You can see from the graph below how much power I used to watch the "BIG GAME".

Based off this and a power cost of $.09/Kwh it cost ~$.24 to watch the game.
(539 watts /1000 = .539Kw * 5 hours = 2.70KwH * .09 = $.245)

This does not include the cost of beer, snacks, the cookies, steaks or stress. 

To get this to work I use tenEcmServer and tenEcmDB from http://tenholder.net/tenWare2/tenEcmServer/default.aspx.  The tenEcmDB needed a little modification to work with SQL Server.  By default it works with SQLLight.  With the tenEcm components I can monitor my BrulTech equipment and provided extensive reporting on it.

Wednesday, October 5, 2011

Not a big fan of new Microsoft Touch mouse

I upgraded from the Microsoft Touch Arch mouse to the new TouchMouse.  I must say I am not a fan.

The new mouse looks nice and all but does not work as well as I would like.


The new TouchMouse has a single button.  It utilizes touch sensors to detect if you are using the left or right finger to press down.  The problem that I have it is I rest my fingers on my mouse.  This causes the mouse to think I am using the multi-touch (two finger) to minimize or maximize windows. It also sometimes thinks I am pressing the right button when I press the left.

Tuesday, August 16, 2011

Home Automation with Insteon - New Ceiling fan

I got my first Insteon switches and setup in 2005. At the time it was an early product and still had issues and did not have the number of options that exist today.

I live in a 4 story townhome that faces southwest. Because of this the top floor can get super warm in the summer time. To help resolve this we desided to install a ceiling fan where there was just a light before.

There are 2x 3 way switches that control the light at the top of my stairs. There are also lights on the wall controlled by the same switches.


Here is how it looked before I started.



Insteon

I replaced the 2 standard decora switches with Insteon KeypadLinc Switches .  Then added 2 wire-in controllers.  1 dimming controller and 1 non-Dimming controller.

Once all that was done I installed the new fan and wired the fan load to the non-dimming controller and the lights to the dimming controller.

Here is what it looks like now.

Friday, August 5, 2011

WDS and Symbolic Links

Windows Deployment Services (WDS) is all my team and I use for OS deployments. We regularly use the $OEM$\$1 option to copy files and scripts to the target install. More on $OEM$

Recently we started updating scripts that are in a $OEM$, $$ or $1 folder. This was very time consuming because you had to update a large number (~50) different images.

The solution to this problem: Hard Links http://msdn.microsoft.com/en-us/library/aa365006(v=vs.85).aspx
We use the Mklink command to create a Hard link to a “source file”. WDS follows this link and copies the script\file to the target OS during install. This allows us to have a GOLD set of scripts that will get copied yet we only have to make a change in 1 location.

The important thing when making the link with mklink is to pass the /k argument. This will tell mklink to make a hard link not a Symbolic link. You can find more on Mklink at http://technet.microsoft.com/en-us/library/cc753194(WS.10).aspx


WDS will not work with a Symbolic link and will throw an error like:
Windows cannot copy files from \$OEM$ to C:\$WINDOWS.~LS\Sources. The files do not exist. Make sure all files required for installation are available, and restart the installation. Error code: 0x80070003]


This works on Windows Server 2008, Windows Server 2008 R2.

Wednesday, July 27, 2011

Windows Server 2008 Hyper-V Geographically Dispersed Cluster with IBM XIV Storage iSCSI

Here is a paper that I worked on at my team at Microsoft. The Enterprise Engineering Center (http://www.microsoft.com/eec) has a IBM XIV array that we used with the other array on campus.

Windows Server 2008 Hyper-V Geographically Dispersed Cluster with IBM XIV Storage iSCSI

You can find more info on the Tunnel used in this whitepaper at http://www.mikepoulson.com/2011/06/l2tpv3-performance-tweaks-for-hyperv.html

How to create differencing disk VM from template on SCVMM 2012 via powershell

This quick post will provide an example of how to create a Virtual Machine (VM) based off an VMM template that utilizes differencing disks. 

This is special because VMM does not support this natively.  So you have to contact the target HyperV host (via WMI) to create the Diff disk.  In addition to need to make sure that the HyperV host has the parent VHD already in place. 

The Powershell cmdlet below does the following
  1. Looks up the specified Hardware profile
  2. Looks up the specified template (this is used to get the parent VHD location/name)
  3. Looks up info on the specified target HyperV host (so we can find the placement drive)
  4. Checks to see if the ParentVHD already exists on the HyperV hosts Placement Drive
  5. If the VHD does not exist it copies it to the HyperV host
  6. Creates Diff Disk via WMI on hyperV host pointing to parent VHD
  7. Creates the VM via the New-SCVirtualMachine cmdlet using the UseLocalVirtualHardDisk command. (this tells VMM to allow Diff disks).
It can be downloaded from http://dl.dropbox.com/u/3275573/Create_Diff_VM_From_Template.ps1
    param($VMName,$TemplateName = "Windows Server 2008 R2 SP1 Enterprise", $HardwareProfileName = "ServerHardware", $VMMHost = "SCVMM",$targethostname = $null)
    
    $Err = 0
    
    If ($VMName -eq $null)
    {
      Write-Host "`nERROR: Incorrect arguments" -foregroundcolor red -backgroundcolor black
       Write-Host "`nREQUIRED ARGUMENTS:" -foregroundcolor cyan
       Write-Host "`n   -VMName `"Name of the VM to create`"" -foregroundcolor cyan
       Write-Host "`n   -TemplateName `"Name of the VMM Template`"" -foregroundcolor cyan
       Write-Host "`n   -HardwareProfileName `"Name of the VMM Hardware Profile to use with the template`"" -foregroundcolor cyan
       Write-Host "`n   -VMMHost `"VMM Computername`"" -foregroundcolor cyan
       Write-Host "`n   -targetHostname `"Computername of HyperV host to target`"" -foregroundcolor cyan
      Exit $Err
    }
    
    function CreateDiffDiskOnHost
    {
                    param([string]$hostComputerName, [string]$childPath, [string]$parentPath)
                    #get the image mgmt service instance for the host computer
                    $VHDService = get-wmiobject -class "Msvm_ImageManagementService" -namespace "root\virtualization" -computername $hostComputerName
                    
                    #create a differencing disk from the base disk
                    $Result = $VHDService.CreateDifferencingVirtualHardDisk($childPath, $parentPath)
    }
    function TestFileLock {
        ## Attempts to open a file and trap the resulting error if the file is already open/locked
        param ([string]$filePath )
        $filelocked = $false
        $fileInfo = New-Object System.IO.FileInfo $filePath
        trap {
            Set-Variable -name locked -value $true -scope 1
            continue
        }
        $fileStream = $fileInfo.Open( [System.IO.FileMode]::OpenOrCreate, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None )
        if ($fileStream) {
            $fileStream.Close()
        }
        $obj = New-Object Object
        $obj | Add-Member Noteproperty FilePath -value $filePath
        $obj | Add-Member Noteproperty IsLocked -value $filelocked
        $obj
    }
    
    
    write-host "VMName is $VMName"
    write-host "Template is $TemplateName"
    write-host "Hardware Profile is $HardwareProfileName"
    write-host "VMMHost is $VMMHost"
    write-host "Target Host is $targethostname"
    
    $guid = [guid]::NewGuid()
    
    write-host "Lookup the base hardware Profile $HardwareProfileName"
    $HardwareProfile = Get-SCHardwareProfile -VMMServer $VMMHost  | where {$_.Name -eq $HardwareProfileName}
    if ($HardwareProfile -eq $null)
        {
            write-host "Failed to lookup HardwareProfile $HardwareProfileName"  -foregroundcolor red -backgroundcolor black
         EXIT 1
        }
    
    write-host "Getting information for template $TemplateName"
    $Template = Get-SCVMTemplate -VMMServer $VMMHost  -All | where {$_.Name -eq $TemplateName}
     if ($Template -eq $null)
        {
            write-host "Failed to lookup Template $TemplateName"  -foregroundcolor red -backgroundcolor black
         EXIT 1
        }
        
    #Get the VHD info for the template
    $VHD =  Get-SCVirtualharddisk | where {$_.Name -eq $template.VirtualDiskDrives[0].VirtualHardDisk}
    
    write-host "Template VHD Path " $VHD.SharePath
    
    if ($targethostname -eq $null)
    {
        write-host "Invalid targethostname"  -foregroundcolor red -backgroundcolor black
        exit 1
    }
    $vmhost = Get-SCVMHost $targethostname
    
    $vmHostPath = [string]$vmhost.vmpaths
    write-host "Target VMHost: "  $vmhost.name
    write-host "Target Drive: "  $vmhost.VMPaths
    
    $remotePath = "\\" + $vmhost.name + "\" + $vmHostPath.substring(0,1) + "$\" + [system.io.path]::GetFileName($VHD.SharePath)
    "Checking to see if Parent VHD exists on HV Host Drive"
    "RemotePath: $remotePath"
    
    if (Test-Path $remotePath)
    {
     "Parent VHD already exists on HV Host"
    }
    else
    {
     "$RemotePath does not exist, going to Copy"
     [System.IO.File]::Copy($VHD.SharePath,$remotePath); 
    }
    
    "Creating Diff Disk"
    $targetVHDPath = $vmHostPath + $VMName + ".vhd"
    $ParentVHDPath = $vmHostPath + [system.io.path]::GetFileName($VHD.SharePath)
    CreateDiffDiskOnHost "$vmhost" "$targetVHDPath" "$ParentVHDPath"
    Start-Sleep -s 20
    
    $targetVHDRemotePath = "\\" + $vmhost.name + "\" + $vmHostPath.substring(0,1) + "$\" + $VMName + ".vhd"
    if (Test-Path $targetVHDRemotePath)
    {
     "Diff Disk Created at:$targetVHDRemotePath"
    }
    else
    {
     "$targetVHDRemotePath does not exist yet.  Sleeping for a few"
     Start-Sleep -s 30
        if (Test-Path $targetVHDRemotePath)
        {
            "Disk was created."
        }
        else
        {
            write-host "Failed to find VHD $targetVHDRemotePath after sleep, exiting" -foregroundcolor red -backgroundcolor black
            exit 1
        }
    
    }
    #Set a random startup delay to reduce VM startup IOPs overload
    $startDelay = Get-Random -minimum 1 -maximum 30
    
    
    $lockstate = TestFileLock "$targetVHDRemotePath"
    if ($lockstate.IsLocked)
    {
        "File locked, sleeping"
        Start-Sleep -s 30
    }
    
    $mv = move-SCvirtualharddisk -Bus 0 -Lun 0 -IDE -path $targetVHDPath  -jobgroup $guid
    $description = $template.tag
    New-SCVirtualMachine -Name $vmName -VMHost $vmHost -VMTemplate $template -UseLocalVirtualHardDisk -HardwareProfile $HardwareProfile -ComputerName $vmName -path $vmHostPath -delaystartseconds $startDelay  -Description "$description" -mergeanswerfile $true -BlockDynamicOptimization $false -StartVM -JobGroup "$guid" -RunAsynchronously -StartAction "AlwaysAutoTurnOnVM" -StopAction "SaveVM"
    

    Monday, July 18, 2011

    Home Circuit Power Monitoring

    Ever wonder why your home power bill is so high?   Or just want to know how much power you use in various parts of your house through the whole day? 
      
    I have one of the Blue Line Power monitors for Microsoft Hohm (http://www.bluelineinnovations.com/Products/PowerCost-Monitor/).  This product did not allow me to see how much a single room or circuit was using.  It was a start. 

    I have the LCD display in my living room near the TV so that I can quickly see how much energy my home is consuming.

    Microsoft Hohm Data (Sunday, Got up at ~9am)

    For my 30th birthday I got all the parts I need to do per-circuit power monitoring for my whole house. By doing branch circuit monitoring I can answer many questions about my enery usage.

    • What does this mean?  I can tell you things like:
    • Exactly how much does it cost me for it to run
      • How much power does my house use when I turn off all my normal items
    • Leaving things like laptop and cell phone chargers on
      • How much does it cost me to run my AC in the summer?  Is it worth leaving on all day or turning on just when I get home
    • Or in my case thanks to Insteon I can turn it on before I leave work!
      
    The Solution:
    I got the ECM1240 system from Brultech.com.  Specifically the PP3-200-X (http://www.brultech.com/home/store/product.php?id_product=34)
      
    I installed solid core CTs on each breaker on my home circuit panel.  

      

    To hold the ECM1240 brains I installed a PVC box just next to my main panel to hold all the low voltage items.  

      
    The ECM1240 allows me to view my data in real-time via the my1240.com website, read the data from google powermeter or push it into my own data collection environment.
      
    The CONS about the 1240 system are:
    1. The software to manage the 1240 collection devices has more bugs in it than Windows ME. It crashes often and overall is a piece of junk.
    2. The solution by default only supports Google powermeter not www.Microsoft-hohm.com
      • While google powermeter has its ups one thing that is has a serious issue with it is the User interface sucks
      • The ability to export the data into CSV format from google is nice. Not an option on www.Microsoft-hohm.com
      • The ability to share access to my power data from google is nice. Not an option on www.Microsoft-hohm.com
    3. With Google Powermeter and Microsoft-hohm.com being retired I will have to find a new way to view my power data.

    Google Power Meter Data





    My1240.com Data

    Controller 1
    Controller 2
    Controller 3



    Sunday, July 17, 2011

    The Delta Touch2O faucet

    How I love my Delta Touch2O faucet.

    http://www.youtube.com/watch?v=niy8WlqHw3M

    We had to have an additional hole drilled so that we could install it. Most of the videos/blogs talk about how it is a big pain to install. But I found it quite simple. We don't have a lot of room under the sink but i was able to get it done by myself in less than 1 hour.

    Also we read that there are issues with the batteries draining quickly and needing replacements often. We have had the same batteries installed for over 1 year now. It is used everyday by 3 sometimes 4 people.

    I cannot wait to get one for the bathrooms!

    Managing Microsoft IIS, Active Directory and DNS from .net

    Update 7/17/2011:  New links

    This code was one of my first coding project from 11-10-2006

    Today I am posting sample code on how to manage IIS 6 and Active directory using ADSI in VB.NET.
    And managing DNS (creating zones, records and enumeration) using WMI in VB.NET.
    There are four separate projects. 
    This code is posted as-is!  It is to be used as a sample on how to do the work.  It is not intended to be used in production!
    http://dl.dropbox.com/u/3275573/blog/web.zip - ADSI management of IIS 6 Sites and AppPools
    http://dl.dropbox.com/u/3275573/blog/DNS.zip - WMI management of Microsoft DNS Zones and Records
    http://dl.dropbox.com/u/3275573/blog/ActiveDirectory.zip- ADSI management of Active Directory contacts, Groups, Users, Recipient Policies, Accepted Domains objects (Exchange 2007)
    http://dl.dropbox.com/u/3275573/blog/IISSiteID.zip - C# code on generating IIS SiteID

    Saturday, June 18, 2011

    Managing lots of Cisco consoles from one location

    Repost from old blog

    Any who. The issue: Lets say you have 16 or so Cisco devices (extreme works also) that connect to various parts of your network. Now you want to be able to manage these devices remotely but not make a huge security hole using Vlans and attempting to keep it all secure with ACLs.

    So the easy way is to do all the management via the console port. No ACLs to worry about and easier to secure.

    So I have 16+ Cisco devices from Routers to switches (2950s, 3550s, 2621s, 2651s, 3750s, 4912s and even an AS5300) all in my lab. So with all those in my lab I got myself a DIGI portserver TS 16 Rack mount device (we use them for kernel debugging also). With a special digi to cisco cable (yes I will give you the pin-outs if you want them) I connect each cisco's console port to the digi and then the DIGI's Ethernet port to my "management network". The management network is where my management workstation lives.

    The digi device will let you telnet or ssh (SSH is better) into it. Then from there connect to each of its ports (using the connect command). Now where the fun comes in is how to setup the DIGI to talk to the cisco. Then create a menu so you dont alway have to know the port number each device is connected to.

    So below are the steps to allow you to connect the DIGI to the cisco (once you have the cable).
    1.Make sure your device is up to date. I am using 82000685_E.bin and 82000684_L.bin
    2.Know your port numbers (we are going to use ports 1-16)
    3.Set the port type to printer (set ports range=1-16 dev=prn)
    4.set the ip on your digi (set config dhcp=off ip= submask=)

    At this point you should be able to use "connect 1" and connect to port 1. A few hits of the enter key and it should show you the cisco console.

    Now we need to secure the device a little more by turning off things that are not needed. This will leave only telnet and ssh on (I would turn off telnet also but if you dont have an ssh client then it is kinda hard to use).
    1.set secureaccess http=off snmp=off rlogin=off rsh=off https=off realport=off securerealport=off
    2.set secureaccess reversessh=off securesockets=off reversetcp=off reversetelnet=off

    We need to make our menu before we assign a user to use it. This will be an example of ports 1-3 with a title bar
    1.set menu range=1 t1="Cisco management" t2="Make sure you save!" name=menu1
    2.set menu range=1 m1="cisco 1" c1="connect 1"
    3.set menu range=1 m2="cisco 2" c2="connect 2"
    4.set menu range=1 m3="cisco 3" c3="connect 3"

    Now lets make a user that we will connect with to see our menu
    1.set user name= defaultaccess=menu menu=1

    Set the password for our new digi user
    1.newpass name=

    Now a little know tip. When use the default escape char with digi it will leave the port open and not let you reconnect until you do a kill tty= (you can see the ttys by running the 'who' command). But if you use the escapekill command (default is a . (that is a period)) then it will close the tty when you escape. So the default escape command is "+]" . Now add a period after that and hit enter and you will kill the connection not just disconnect so a "+].". Now you press the control and ] key in one key stroke then the period in another.

    Now you should be able to telnet or ssh into your ip and get a menu. Press 1 to connect cisco 1, 2 to connect to cisco 2, and 3 to connect to cisco 3.

    How great!

    Disk Quota and .net (WMI and Microsoft.DiskQuota.1)

    Repost from old Blog

    Today I had a con-call to talk about disk quota and how to automate the setting and reading of Quota. So i thought that I would post a little about Disk quota stuff.

    There are 2 okay options.

    #1 WMI (way to slow for a lot of things (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/disk_quota_provider.asp))

    #2 Microsoft.DiskQuota.1

    So my team needed a way to enumerate a users current quota limits and then + or - from them. WMI was very slow to do this. But DiskQuota.1 is quite fast. It is not well documented that it works on remote servers either. So I wrote a little something up.

    So here is some cs (and vb.net) that has functions on how to get and set quota info with Microsoft.diskquota.1

    CSharp: http://dl.dropbox.com/u/3275573/blog/QuotaFunctions.cs.txt
    VB.NET: http://dl.dropbox.com/u/3275573/blog/QuotaFunctions.vb.txt

    10 Years from last post

     Well world!   After the last almost 10 years I have been up to a few things in life and work.  Most recently I was working at Microsoft on ...