Friday, June 04, 2010

IP Address to Country Map

I’m learning how to use the F# HashMultiMap and I thought up a sample exercise – do a lookup in memory of IP address to a country code. This is a task I’ve seen embedded in a relational table before but that seemed daft – it’s on disk so it will be slow. It seems smarter to do this all in memory and just serve out a result.

It’s relatively easy to get hold of IP address country/region/ISP lookups in the form of a single file, for example http://software77.net/geo-ip/ provide one for country lookups under a GNU license.

First I load up the text file:

open System
open System.IO
open System.Text.RegularExpressions

let (|ActiveRegex|_|) regex str =
let ms = Regex(regex).Matches(str)
if ms.Count > 0
then Some ((Seq.cast ms : Match seq))
else None

let matches s re =
match s with
| ActiveRegex re results -> results
| _ -> Seq.empty

let capturesSeq s p =
seq{
for m in matches s p ->
Seq.skip 1 (seq{for g in m.Groups -> g.Value})
}
|> Seq.concat


let csvRegex = "\"([\w\s:;'`~!@#$%\^&\*_<>,\.\\\/\|\[\]\{\}\(\)\-\+\?]*)(?:\",|\"$)"

let isInt64 i =
let v,_ = Int64.TryParse(i)
v

let parseIpToCountryLine lineNo (line:String) =
try
let
values =
capturesSeq line csvRegex
|> Seq.toArray

isInt64 values.[0] |> fun test -> if not test then failwith (sprintf "Bad IP FROM on line %i" lineNo)
isInt64 values.[1] |> fun test -> if not test then failwith (sprintf "Bad IP TO on line %i" lineNo)
int64 values.[0], int64 values.[1], string values.[6]
with
| :? System.IndexOutOfRangeException -> failwithf "Failed on line %A, contents: %A" lineNo line

let IpToCountryLines = File.ReadAllLines(@"c:\temp\IpToCountry.csv", Text.Encoding.Default)

(*
File format like this... detail in the header comments of the file
# IP FROM IP TO REGISTRY ASSIGNED CTRY CNTRY COUNTRY
# "1346797568","1346801663","ripencc","20010601","il","isr","Israel"

there is a tricky line in there, it contains an 'Å' character which seems to require that I explicitly define the text encoding. Don't see why since it's just default...
*)

let getIpToCountry (lines:string []) =
lines
|> Seq.filter (fun i -> not(i.StartsWith("#")))
|> Seq.mapi parseIpToCountryLine

let Ip2Country = getIpToCountry IpToCountryLines

Then a function to create a numeric form of an IP address:

let numIP (a:int) (b:int) (c:int) (d:int) = (int64 d) + ((int64 c)*256L) + ((int64 b)*256L*256L) + ((int64 a)*256L*256L*256L)


 


Then the hash and a quick test:

#r "FSharp.PowerPack.dll"
// count down until a key is found - could be speed up by creating extra entries when to-from is a large gap
let Ip2Country3 = HashMultiMap<_,_>(
Ip2Country
|> Seq.map (fun (ipFrom,ipTo,country) -> ipFrom, country )
, HashIdentity.Structural)

let rec countryFromIP (ip:int64) =
if Ip2Country3.ContainsKey(ip) then
Ip2Country3.[ip]
else
countryFromIP (ip-1L)


// test with 10 addresses taken from our public site web logs
let testIPs = [… in the interests of confidentiality stick some of your own in here… as (a,b,c,d) tuples…]

let time f x =
let timer = System.Diagnostics.Stopwatch.StartNew()
try f x finally
printf "Execution duration: %gms\n" timer.Elapsed.TotalMilliseconds;;

testIPs |> List.map (fun (a,b,c,d) -> numIP a b c d) |> time List.map (fun nIP -> countryFromIP nIP)

I’ve found it takes about 1 millisecond for 10 random lookups on my virtual workstation instance (running under Hyper-V with 3GB allocated on a desktop Dell Optiplex 760).

Wednesday, May 26, 2010

My Regex Lessons (Probably 1 of many…)

OK, that previous post had a couple of minor problems.

First that regular expression – terribly unwieldy. I haven’t managed to shorten it fully yet, but this is marginally better:

"([\w\s:;… add whatever characters are valid here…]*)(?:\",|\"$)


Secondly, I wasn’t fully thinking through the matches/groups/captures hierarchy. I kept getting empty captures being reported back without understanding why I was getting them.



Updated code here:



open System
open System.Text.RegularExpressions

let (|ActiveRegex|_|) regex str =
let ms = Regex(regex).Matches(str)
if ms.Count > 0
then Some ((Seq.cast ms : Match seq))
else None

let matches s re =
match s with
| ActiveRegex re results -> results
| _ -> Seq.empty

let capturesSeq s p =
seq{
for m in matches s p ->
Seq.skip 1 (seq{for g in m.Groups -> g.Value})
}
|> Seq.concat

let csvRegex = "\"([\w\s:;~!@#$%\^&\*_<>,\.\\\/\|\[\]\{\}\(\)\-\+\?]*)(?:\",|\"$)"

let testLine = "\"31\",\"a 1\",\"b-2\",\"c+3\",\",.;~!@#$%^&*()\/?><,.|{}[]_+-\",\"\",\"14/05/2010 12:12:20 a.m.\",\"1: 2; 3. 4? 5[ 6] 7& 8*\",\"a,b\""

capturesSeq testLine csvRegex
|> Seq.iter (fun x -> printfn "%A" x)

Tuesday, May 25, 2010

Parsing CSV Escaped with Speech Marks

I just know this isn’t the right way to do this but what the heck it seems to work for me. 

The simple match is "([\w,]*)",+|"([\w,]*)"$ but I needed to account for all the other commonly occurring characters such as %&* etc. ( I would’ve thought I could just use .* but I can’t seem to get it to work.)

I’m using the F# Active Pattern approach to divvy up the matches – and returning the Match objects into the seq rather than breaking out the capture in the active pattern. This was more useful to me when I was using the matches later on in the code.

open System.Text.RegularExpressions

let (|ActiveRegex|_|) regex str =
let ms = Regex(regex).Matches(str)
if ms.Count > 0
then Some ([ for m in ms -> m ])
else None

let matches s re =
match s with
| ActiveRegex re results -> results
| _ -> []

let testLine = "\"31\",\"a 1\",\"b-2\",\"c+3\",\",.;~!@#$%^&*()\/?><,.|{}[]_+-\",\"\",\"14/05/2010 12:12:20 a.m.\",\"1: 2; 3. 4? 5[ 6] 7& 8*\",\"a,b\""

matches testLine "\"([\w\s:;~!@#$%\^&\*_<>,\.\\\/\|\[\]\{\}\(\)\-\+\?]*)\",+|\"([\w\s:;~!@#$%\^&\*_<>,\.\\\/\|\[\]\{\}\(\)\-\+\?]*)\"$"
let printMatches s p =
for m in matches s p do
seq{for g in m.Groups -> g}
|> Seq.skip 1
|> Seq.iter (fun x -> printfn "%A" x)

printMatches testLine "\"([\w\s:;~!@#$%\^&\*_<>,\.\\\/\|\[\]\{\}\(\)\-\+\?]*)\",+|\"([\w\s:;~!@#$%\^&\*_<>,\.\\\/\|\[\]\{\}\(\)\-\+\?]*)\"$"
  

Thursday, May 20, 2010

System Center Operations Manager Health Explorer Context

I’ve been wondering for a while why the Health Explorer doesn’t always display the context for a state change. I found one recent link through both Bing and Google that explains what’s going on: http://social.technet.microsoft.com/Forums/en-US/systemcenteressentials/thread/df725076-e307-4d63-9be9-5d875c6924b5/.

Basically, at Entity level if there are multiple sources for state change information then the UI doesn’t know how to represent that information so it just says “No context was available for this state change event” and it displays a bunch of state changes with no text… something like this:

image

What you need to do is drill down into Availability/Configuration/Performance etc and as you do you’ll get the state change context appearing.

Wednesday, May 19, 2010

Pascal’s Triangle in F#

Fun with F# :)

let rec PascalsTriangle = seq { 
yield [1];
for aLine in PascalsTriangle ->
List.append (1::Seq.toList (Seq.map (fun (x,y) -> x+y) (Seq.pairwise aLine))) ([1])
}



> PascalsTriangle |> Seq.take 10 |> Seq.toList;;
val it : int list list =
[[1]; [1; 1]; [1; 2; 1]; [1; 3; 3; 1]; [1; 4; 6; 4; 1]; [1; 5; 10; 10; 5; 1];
[1; 6; 15; 20; 15; 6; 1]; [1; 7; 21; 35; 35; 21; 7; 1];
[1; 8; 28; 56; 70; 56; 28; 8; 1]; [1; 9; 36; 84; 126; 126; 84; 36; 9; 1]]
>


 



I actually started this with a pipe forward approach, but ( at least with my knowledge of the syntax) it seemed longer to write down.



let rec PascalsTriangle1 = seq { 
yield [1];
for aLine in PascalsTriangle1 ->
let
newLine =
aLine
|> Seq.pairwise
|> Seq.map (fun (x,y) -> x+y)
|> Seq.toList
List.append (1::newLine) [1]
}

Friday, May 14, 2010

Discovering the presence of a database in a System Center Powershell script

I’m pretty sure there’s a better way to do this using the native SQL Server management pack but this worked for me (peppered with debugging statements). It looks for a database called staging and if it finds it, it returns the discovery information back.

      <Discovery ID="B.Staging.DiscoverProcessingComponent" Enabled="true" Target="B.Staging.ComputerRole" ConfirmDelivery="true" Remotable="true" Priority="Normal">
<
Category>Discovery</Category>
<
DiscoveryTypes>
<
DiscoveryClass TypeID="B.Staging.ProcessingComponent" />
</
DiscoveryTypes>
<
DataSource ID="PSScript" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<
IntervalSeconds>180</IntervalSeconds>
<
SyncTime />
<
ScriptName>DiscoverBStagingProcessingComponent.ps1</ScriptName>
<
ScriptBody><![CDATA[
param($sourceId, $managedEntityId, $computerName)

$api = New-Object -comObject 'MOM.ScriptAPI'
$api.LogScriptEvent("Processing discovery",101,2,"Created MOM.ScriptAPI with param sourceId = $sourceId , managedEntityId = $managedEntityId , computerName = $computerName ")

$discoveryData = $api.CreateDiscoveryData(0, $sourceId, $managedEntityId)
$api.LogScriptEvent("Processing discovery",101,2,"Executed CreateDiscoveryData")

[system.reflection.assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null

$s=new-object('Microsoft.SqlServer.Management.Smo.Server') $computerName
$dbs=$s.databases
$dbs | get-member -membertype property
$staging = ($dbs | select name | where {$_.name -eq 'staging'})."Name"
$api.LogScriptEvent("Processing discovery",101,2,"Found anything: $staging")

$instance = $discoveryData.CreateClassInstance("$MPElement[Name='B.Staging.ProcessingComponent']$")
$api.LogScriptEvent("Processing discovery",101,2,"Executed CreateClassInstance")

if ($staging -eq 'staging') {
$instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)
$instance.AddProperty("$MPElement[Name='B.Staging.ProcessingComponent']/B.Staging.ProcessingComponentKey$", "staging")

$api.LogScriptEvent("Processing discovery",101,2,"In the staging branch")

} else {
$instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", "")
$instance.AddProperty("$MPElement[Name='B.Staging.ProcessingComponent']/B.Staging.ProcessingComponentKey$", "")

$api.LogScriptEvent("Processing discovery",101,2,"In the not-staging branch")

}

$api.LogScriptEvent("Processing discovery",101,2,"About to AddInstance")

$discoveryData.AddInstance($instance)

$api.LogScriptEvent("Processing discovery",101,2,"About to return discoveryData")

$discoveryData

]]></ScriptBody>
<
Parameters>
<
Parameter>
<
Name>sourceID</Name>
<
Value>$MPElement$</Value>
</
Parameter>
<
Parameter>
<
Name>managedEntityID</Name>
<
Value>$Target/Id$</Value>
</
Parameter>
<
Parameter>
<
Name>computerName</Name>
<
Value>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Value>
</
Parameter>
</
Parameters>
<
TimeoutSeconds>300</TimeoutSeconds>
</
DataSource>
</
Discovery>

Lessons in System Center Operations Manager Discovery

Some quick notes before I forget them.

General Hints

  • Run through the Management Pack Authoring Guide first. It’s useful but I feel it didn’t give me enough of an explanation of what’s actually going on under the covers. Much of the inner workings of system center remain a mystery to me.
  • Setup a single all in one dev environment to allow yourself the chance to really play around when you’re not sure what’s going on. Then load on an agent onto your normal desktop workstation/laptop and test discoveries out on that machine at the same time as you begin deploying your management packs into the production environment.
  • Get a copy of Savision Live Maps – a 5 diagram copy is freely available. It has a simple, easy to use interface for finding your class instances and testing out your discoveries. And, I’ve just discovered – there’s a new version out – v5 is RTM - gotta try it.

Registry Discovery

  • Use the filtered registry discovery not the unfiltered discovery. This ensures you can get the Build Event Expression page which enables you to test for the existence of a registry key.

WMI Discovery

  • Use wbemtest.exe to try out queries and drill down into the CIM classes.
  • Documentation to help you with WMI is again weak. Classic example – at time of writing this there’s a community comment to highlight the fact that the SQL Server 2008 ComputerManagement namespace is incorrectly labelled (should be root\Microsoft\SqlServer\ComputerManagement10 – you can verify by using select * from __namespace under root\Microsoft\SqlServer).

Powershell Script Discovery

Thursday, May 06, 2010

Adding SCOM Class Properties to the DGML

Updated transform for SCOM/OpsMgr management pack diagramming with DGML. This time I added in the SCOM class attributes as properties on DGML nodes – perhaps I should’ve used categories?? The legend in the visual studio viewer then lets you highlight parts of the class model based upon properties.

scr1

Next thing would be to include attributes about relationships as properties on the links. Also, what about referencing other system center management packs?

<?xmlversion="1.0" encoding="utf-8"?>
<
xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://schemas.microsoft.com/vs/2009/dgml" version="1.0">
    <
xsl:outputmethod="xml" indent="yes"/>
    <
xsl:templatematch="/">
        <
DirectedGraph>
            <
Nodes>
                <
xsl:apply-templatesselect="ManagementPack/TypeDefinitions/EntityTypes/ClassTypes/ClassType" />
            </
Nodes>
            <
Links>
                <
xsl:apply-templatesselect="ManagementPack/TypeDefinitions/EntityTypes/RelationshipTypes/RelationshipType" />
            </
Links>
            <
Categories>
            </
Categories>
            <
Properties>
                <
PropertyId="Accessibility" Label="Accessibility" Description="Accessibility" DataType="System.String" />
                <
PropertyId="Abstract" Label="Abstract" Description="Whether this is an abstract class" DataType="System.Boolean" />
                <
PropertyId="Base" Label="Base" Description="Whether this is a base class" DataType="System.String"/>
                <
PropertyId="Hosted" Label="Hosted" Description="Whether this is hosted" DataType="System.Boolean"/>
                <
PropertyId="Singleton" Label="Singleton" Description="Whether this is singleton" DataType="System.Boolean"/>
            </
Properties>
        </
DirectedGraph>
    </
xsl:template>
    <
xsl:templatematch="ManagementPack/TypeDefinitions/EntityTypes/ClassTypes/ClassType">
        <
xsl:elementname="Node">
            <
xsl:attributename="Id">
                <
xsl:value-ofselect="@ID"/>
            </
xsl:attribute>
            <
xsl:attributename="Accessibility">
                <
xsl:value-ofselect="@Accessibility"/>
            </
xsl:attribute>
            <
xsl:attributename="Abstract">
                <
xsl:value-ofselect="@Abstract"/>
            </
xsl:attribute>
            <
xsl:attributename="Base">
                <
xsl:value-ofselect="@Base"/>
            </
xsl:attribute>
            <
xsl:attributename="Hosted">
                <
xsl:value-ofselect="@Hosted"/>
            </
xsl:attribute>
            <
xsl:attributename="Singleton">
                <
xsl:value-ofselect="@Singleton"/>
            </
xsl:attribute>
        </
xsl:element>
    </
xsl:template>

    <
xsl:templatematch="ManagementPack/TypeDefinitions/EntityTypes/RelationshipTypes/RelationshipType">
        <
Link>
            <
xsl:attributename="Source">
                <
xsl:value-ofselect="Source"/>
            </
xsl:attribute>
            <
xsl:attributename="Target">
                <
xsl:value-ofselect="Target"/>
            </
xsl:attribute>
        </
Link>
    </
xsl:template>
</
xsl:stylesheet>

Monday, May 03, 2010

WMI Web Site Discovery with System Center Operations Manager

Learning how to perform a discovery with WMI under SCOM/OpsMgr isn’t easy – documentation is appalling and there’s few examples on the net. Here’s my, eventually, successful attempt with some lessons learned along the way.

First off a quick description of the original problem – I want to discover multiple instances of web services running on servers.

After much, much time spent building a single server SCOM/OpsMgr development environment (just exactly what do people call this product anyway?) and figuring my way tentatively through SCOM and the SCOM Authoring Console I defined a class based on Microsoft.Windows.LocalApplication. If you ever have any issues with this stuff a good place to go is the Operations Manager Authoring discussion board – one of my questions and the helpful response from Elizabeth 1978 is here.

clip_image002[17]

Then I created a discovery based upon a wmi query against the root\webadministration namespace to retrieve a list of sites. (Try it out in Powershell first: get-wmiobject –query “select * from site” –namespace root\webadministration.)

 clip_image002[19]

 

Now try to simulate this (learning to use the simulate tool as an experiment in itself – remember to load the MP into SCOM then click the arrow heads to attach to your development RMS so expressions can be resolved)… and it doesn’t work.

clip_image002[21]

clip_image002[23]

clip_image002[29]

Strange. Then by trial and error I find that the asterisk doesn’t allow SCOM to pick up the data element for the name from the WMI query. Basically it seems to need you to identify each value you want returned in the WMI query to be sure you can map it in the Authoring Console mapper screen.

So this works:

clip_image002[25]

You can check by running a simulation.

clip_image002[27]

And to be doubly sure I imported the management pack into the SCOM environment with a monitor that targeted the class and checked when the ASP.NET Apps v4.0.30319 Requests/Sec counter was in excess of 10 requests/second.

As a web service I used a wcf service – just a simple hello world affair (in F# – why is there no template in visual studio??) and executed from a powershell console.

1..1000 | foreach-object {(new-object system.net.webclient).downloadstring(“http://localhost/service.svc”) }

Thursday, April 22, 2010

“Ah Ha” Moment

So if I can convert a system definition model from OpsMgr/SCOM to directed graph markup language… then presumably I could use VS2010 to create my architecture model and then generate the framework for my OpsMgr/SCOM management pack!

Update... it seems to me that none fo the vs2010 model types make sense with scom. Guess that it might be better waiting till the system center team publish a modelling tool.

Wednesday, April 21, 2010

SCOM Class Hierarchy to Directed Graph Markup

As part of a struggle to get to grips with management pack authoring for Systems Center Operations Manager I wanted a way to diagram the relationships between classes. You can do it with the OpsMgr Authoring kit and Visio… but I don’t have it on my machine. However, with the management pack being xml, it seemed a simple job to transform to directed graph markup language to view inside Visual Studio 2010. Here’s a sample xsl transform.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
</Nodes>
<Links>
<xsl:for-each select="ManagementPack/TypeDefinitions/EntityTypes/RelationshipTypes/RelationshipType">
<Link>
<xsl:attribute name="Source"><xsl:value-of select="Source"/></xsl:attribute>
<xsl:attribute name="Target"><xsl:value-of select="Target"/></xsl:attribute>
</Link>
</xsl:for-each>
</Links>
<Categories>
</Categories>
</DirectedGraph>
</xsl:template>
</xsl:stylesheet>




This seems to work with the sample management pack created on Brian Wren’s blog for an article about embedded Powershell scripts. Using the transform and either the Altova xslt1 processor or the native transform in VS2010 I got a dgml file that displays like this.



image

Monday, January 18, 2010

PowerShell Data Munging

There’s a data munging exercise on Rosetta Code which was missing a PowerShell solution. Since I spend a lot of time importing data to graph and present in my day job – often using PowerShell, I thought I’d add a couple of PowerShell options for the import of the data in the Data Munging 2 problem.

First just using iteration alone to look up good values.

$dateHash = @{}
$goodLineCount = 0
get-content c:\temp\readings.txt
ForEach-Object {
$line = $_.split(" `t",2)
if ($dateHash.containskey($line[0])) {
$line[0] + " is duplicated"
} else {
$dateHash.add($line[0], $line[1])
}
# split up the 24 instrument values and count the total number of entries with flag >=1
$readings = $line[1].split()
$goodLine = $true
if ($readings.count -ne 48) { $goodLine = $false; "incorrect line length : $line[0]" }
for ($i=0; $i -lt $readings.count; $i++) {
if ($i % 2 -ne 0) {
if ([int]$readings[$i] -lt 1) {
$goodLine = $false
}
}
}
if ($goodLine) { $goodLineCount++ }
}
$goodLineCount




And secondly taking advantage of the regular expression syntax.



$dateHash = @{}
$goodLineCount = 0
ForEach ($rawLine in ( get-content c:\temp\readings.txt) ){
$line = $rawLine.split(" `t",2)
if ($dateHash.containskey($line[0])) {
$line[0] + " is duplicated"
} else {
$dateHash.add($line[0], $line[1])
}
$readings = [regex]::matches($line[1],"\d+\.\d+\s-?\d")
if ($readings.count -ne 24) { "incorrect number of readings for date " + $line[0] }
$goodLine = $true
foreach ($flagMatch in [regex]::matches($line[1],"\d\.\d*\s(?<flag>-?\d)")) {
if ([int][string]$flagMatch.groups["flag"].value -lt 1) {
$goodLine = $false
}
}
if ($goodLine) { $goodLineCount++}
}
[string]$goodLineCount + " good lines"




The F# solution on the site includes use of seq.forall – I thought maybe this would be useful to implement for the PowerShell solution as well – but I couldn't figure it out. Fortunately the good folks at stackoverflow helped out on that...

Wednesday, November 04, 2009

Connecting to SCOM from the Powershell ISE

Temporary interlude, figuring out how to get some numbers from our IT environment to create some models for complexity in our technology environment. I thought System Center Operations Manager should be useful here but running powershell from the SCOM shell isn't that clever. It'd be much nicer in a decent editor... but how? I couldn't find this anywhere else on the net... so here's how I managed to get SCOM (R2) accessible from the Powershell ISE...

import-module "C:\Program Files\System Center Operations Manager 2007\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.dll"

&"C:\Program Files\System Center Operations Manager 2007\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Functions.ps1"

Start-OperationsManagerClientShell -ManagementServerName: somemachinename -PersistConnection: $true -Interactive: $True

Wednesday, March 18, 2009

S&G Night Heron – Fibreglassing the Outside

Quick notes from here on as the exterior was considerably easier than the interior.

I bias cut the fibrglass for the exterior to get it to drape better. The epoxy application was much simpler than inside although I did find a few areas that ended up a bit on the dry side. Main reason for this was I ended up working into the evenings and the lighting was awful. This also resulted in a couple of unnecessary floating bubbles and drips – but all easily fixed. So much easier after having done the interior first.

One tip (I think) was to fibreglass across the sheer line; that is, when I fibreglassed the deck, I went to about an inch beyond the deck-hull join, and likewise when I fibreglassed the hull, so that the join between deck and hull was secured with interior tape and a doubling of the exterior glass.

I doubled the glass on the exterior hull from the sheer line to the keel so that under my body I ended up with 4 layers of 200g (6oz) fibreglass.

Having read about the difficulties of making a lightweight boat I spent a lot of time checking the weight as I progressed. One very useful thing here (especially to avoid wastage) was a cheap digital scale. I bought this from a supermarket for $16 and used it to successfully mix epoxy down to 1g hardener and 5g epoxy. I recorded the weight of each batch of epoxy and I weighed the boat after each major application so I could clearly see the increase from 12kg prior to exterior glassing to 19kg after the fill coats were complete.

I found the fill coats a little painful. I seemed to never quite get the right amount on. I’d put a coat on, sand some off, then try again; many times over. What was particularly irritating here was that to avoid excessive exposure to the epoxy while curing I would make myself wait a few days before any sanding. The time just seemed to drag!

If I was doing it again I’d make two changes.

Firstly, I’d use a slow hardener and warm epoxy/conditions. I found that on a few of my (autumn) evenings the temperature had dropped to maybe 15C and the epoxy had thickened and would spread easily. You want it to spread really easily so a really hot day with a slow hardener would be a better combination.

Secondly, I’d use a random orbital sander more extensively. I spent far too much time continuing on with hand sanding when I should have just used the ROS. The pads clog up quick but crikey it does a hell of a job!

S&G Night Heron – Varnishing and Outfitting

I was initially unsure what to use for the final coat: varnish or polyurethane. The documentation on the net seemed a little confusing. In the end I’ve gone with a varnish from Altex. Not sure if this was the best choice, I suspect it’s more expensive than the equivalent products I could have just bought at Mitre 10 or Placemakers. Nevermind.

The can said 6 to 10 coats. I think I’ve run up 7 on the top and 6 on the bottom. Hard to remember!

I used the ROS with 180 grit pads and this seems to produce a good surface. I’ve still got a fair 250mls left so I’ll put that on sometime in winter.

I enjoyed this part much more than the epoxy. No special safety gear required and it could be done at an enjoyable pace.

I put the kayak in the garage – there was some dust but it pails into insignificance when viewed from a few feet. Runs were definitely a problem. Sponge applicators helped but invariably I’d come back the next day and find a few runs that had formed.

For the outfitting I’ve kept to a bare minimum, at least for the moment. I used window weather stripping for the hatches – seems a bit leaky but I’m sure I’ll be able to tune it better.

I used plastic foot pegs; very light but they also seem a bit flimsy. In retrospect I’d go aluminium.

The back rest provided in the Night Heron plans seems quite effective without any padding. In fact, I spent $80 on closed cell foam and so far haven’t put any in yet, but it doesn’t seem to be especially uncomfortable so I’m in no great rush to finish it.

For the spray deck I ended up, after a few false starts, with getting one made by someone (Gabi) in Nelson. You can get hold of them on TradeMe and I’d recommend the product. Other options include Rasdex and BackOfBeyond.

And the final result? Well, here I am on the inaugural launch in the Waikanae River at the Otaihanga domain. Beautiful spot; you can head out at high tide down the 2kms to the river mouth, play in the sea, then come back with the salt water washed off in the river.DSC03342

 

In the end I guess I spent 10 hours / week from the middle of November 2008 until the first week of March this year. So that’s about 160 hours. The cost is approximately $1000. It’s easy to spend more if you don’t hunt around for good prices on ply, fibreglass, epoxy and varnish.

And performance? Well, I’m very familiar with the plastic sea kayaks that you can hire. My Night Heron is faster, feels more manoeuvrable (and it doesn’t have a rudder) and it’s much lighter. So all in all – I LOVE IT!