Ricky Moorhouse

Blog

Introducing hem

hem is a synthetic monitoring tool which monitors HTTP resources on a regular schedule, storing details of the time taken and the reponse code returned.

I've been using Uptime at work for a while for endpoint monitoring and over the time we've been using it made a few tweaks or plugins for it - in particular being able to send metrics from Uptime to Graphite. There were also some more substantial changes we were considering making and we'd built up a number of supporting scripts to populate the checks via the Uptime API when hosts changed. We also have all our other monitoring dashboards in Grafana. In this context I decided that what would be nice is a simple tool that could replace the checking piece and feed that data into our graphite data store to be viewed and alerted on from Grafana.

hem runs from a simple config file with three main sections in it - discovery, tests and metrics. Both discovery and metrics have been designed as pluggable to give hem versatility - so far I've built discovery drivers for dns, consul and json/yaml and metrics drivers for graphite, kafka and the console. hem will iterate over the tests on a custom interval performing discovery each time to ensure it has the latest list of hosts for that test.

hem stats in Grafana steps

Getting started with hem

To start using hem, you can install it from PyPI with pip:

pip install hemApp

Then create a config file - it will look something like this:

    discovery:
      type: dns
    metrics:
      type: graphite
      server: 127.0.0.1
      port: 2003
    tests:
      homepage:
        path: /index.html
        secure: false
        hosts:
           - example.com
           - example.org

Run hem and start to see metrics flowing to graphite

hem -c config.yaml

In grafana I have the Discrete plugin installed to give the coloured bar look you see above.

Reducing our plastic use

Over the last few months we've started to try and reduce our use of plastics - especially single use plastics. Here are some of the areas where we've made changes.

Reusable drinks containers/straws

We've been making an effort to take our reusable cups, bottles and stainless steel straws with us when we're out and about - and if we don't have them asking for drinks in non-plastic cups.

Refillable Splosh cleaning

Splosh is the great new way to buy essentials like washing up liquid, laundry detergent and surface cleaners. It’s great value, more convenient than the supermarkets and miles better for the environment.You can read all about it on their website. If you use this special code 151F69 when you buy from Splosh you’ll get money off your first order.

Milk bottles

We've started to have milk (and occasionally juice) delivered by milk and more in glass bottles, which can then be returned for reuse.

Present wrapping

For birthdays and Christmas we’ve tried to wrap presents with tissue paper and string or reusing paper - for any wrapping material we’ve bought we tried to avoid the foil and laminated papers.

Soap instead of shower gel

Another area we seem to end up with a lot of un-necessary plastic is shower gels and shampoos so I've been attempting to reduce this with bar soap. The soap works well in place of shower gel and also can replace shaving foam but I've not found one thats a good shampoo substitute yet. The other issue with soaps is a lot of the soaps themselves are packaged in plastic as well so avoiding that adds another complication to it.

Supermarket awareness

Not buying drinks in plastic bottles. Choosing individual vegetables over prepackaged ones and not putting them in bags for weighing. Choosing drinks in glass bottles or cans instead of plastic.

View API Error detail

To view the details of the steps in an API in Analytics to assist in debugging you can do the following:

animated steps

2018 Reading Log

  • Legion (Talon #4) - Julie Kagawa
  • Roads of Madness (Island of Fog #5)- Keith Robinson
  • Chamber of Ghosts (Island of Fog #6) - Keith Robinson
  • Valley of Monsters (Island of Fog #7) - Keith Robinson
  • Summer Crush (Tournament, #4) - B. B. Griffith
  • The Mysterious Affair at Styles - Agatha Christie
  • Against the Inquisition - Marcos Aguinis
  • The Nostradamus Equation (Sam Reilly #6) - Christopher Cartwright
  • Rising Force (Jesse McDermitt #13) - Wayne Stinnett
  • Wicked (Wicked Years #1) - Gregory Maguire
  • Son of a Witch (Wicked Years #2) - Gregory Maguire

2017 Reading Log

  • Yellow Ribbon (Dev Haskell #11) - Mike Faricy
  • Triple Trouble - Russell Blake
    • JET (JET #1)
    • JET - Betrayal (JET #2)
    • JET - Vengeance (JET #3)
  • Fallen Series - Wayne Stinnett
    • Fallen Out (Jesse McDermitt #1)
    • Fallen Palm (Jesse McDermitt #2)
    • Fallen Hunter (Jesse McDermitt #3)
  • Fallen Pride (Jesse McDermitt #4) - Wayne Stinnett
  • Fallen Tide (Jesse McDermitt #8) - Wayne Stinnett
  • Fallen Angel (Jesse McDermitt #9) - Wayne Stinnett
  • Fallen Hero (Jesse McDermitt #10) - Wayne Stinnett
  • Rising Storm (Jesse McDermitt #11) - Wayne Stinnett
  • The Tournament Trilogy - B. B. Griffith
    • Blue Fall (Tournament #1)
    • Grey Winter (Tournament #2)
    • Black Spring (Tournament #3)
  • A Thyme To Die - Jamie Lee Scott
  • Rogue Wave (Sam Reilly #4) - Christopher Cartwright, Kris Densley
  • The Cassidy Project (Sam Reilly #5) - Christopher Cartwright, Kris Densley
  • The Third Temple (Sam Reilly #7) - Christopher Cartwright, Kris Densley
  • Murder on the Orient Express (Hercule Poirot #10) - Agatha Christie
  • Death on the Nile (Hercule Poirot #17) - Agatha Christie
  • Murder in Mesopotamia (Poirot) (Hercule Poirot #14) - Agatha Christie
  • Cards on the Table (Poirot) (Hercule Poirot #15) - Agatha Christie
  • The Lost Plot (Invisible Library #4) - Genevieve Cogman

Pi Zero as a desklight

When we set up our office earlier in the year I decided on a standing desk which I put together using the Ikea Algot system.
In order to avoid using up desk space with a light I originally planned on a clip on light but then saw my Pi Zero and Unicorn pHat and thought they could make a good alternative.

Hardware

The Raspberry Pi Zero is in a simple case, mounted onto the underside of the shelf above my working space. Attached is it's power cable, a PiHut wireless adapter connected via USB and of course the Unicorn pHat. The power cable is routed down the side of the shelf to my PowerCube, which will eventually be mounted under my work surface but it's sticky pad wasn't strong enough to hold it on the underside of the desk!

Software

As I've not yet added any switch for my light, it all has to be controllable remotely, so I set up an API to set the colour of the light which I initially controlled via a web browser with urls like:

http://192.168.0.15:8009/colour/<red>/<green>/<blue>

As you can imagine that got a bit tedious - especially to turn off after I'd shut down my laptop! The next step was to add a simpler way to control the light through my phone so I set up iControl Web with buttons to adjust the light settings. Then when I saw the Home app on iOS 10, I researched ways to get my custom light controllable through that and came across Homebridge which I could point to my API via it's Better HTTP RGB plugin, a bit of config and a couple of changes to my API.

All the code for my API is on github and is very much a work in progress!

Hatching chicks at school

At Jessica's school, where I am a governor and Laura works, they've got an incubator of eggs from Living Eggs, so that the school can watch as they hatch into chicks.

On Monday I got a text from Laura wondering if it would be possible to set up a webcam to watch them hatch.  We happened to have a wireless webcam that wasn't being used so that evening I got it out to make sure it was working and configured it with an FTP server to upload photos every minute and if there was motion detected.

The next day I took the webcam into school and got it set up with the help of James who looks after the school computers and network. You can see the latest pictures from the webcam on the school website.

In the early hours of this morning the first egg hatched:

2016 Reading Log

  • The Watchmaker of Filigree Street - Natasha Pulley
  • Divergent (Divergent Trilogy, #1) - Veronica Roth
  • Insurgent (Divergent Trilogy, #2) - Veronica Roth
  • Last Shot (Dev Haskell #6) - Mike Faricy
  • The Chase (Isaac Bell #1) - Clive Cussler
  • JET - Ops Files: Prequel - Russell Blake
  • Mr Swirlee (Dev Haskell -#2) - Mike Faricy
  • The Eagle Tree - Ned Hayes
  • Torch Scene (Reed Ferguson #6) - Renee Pawlish
  • The Geronimo Breach - Russell Blake
  • Career of Evil (Cormoran Strike #3) - Robert Galbraith
  • Bite Me (Dev Haskell #3) - Mike Faricy
  • Soldier (Talon Saga, Book 3) - Julie Kagawa
  • Bulldog (Dev Haskell #9) - Mike Faricy
  • Insatiable (Sydney Rye #3) - Emily Kimelman
  • The Sam Reilly Collection - Christopher Cartwright
    • The Last Airship (Sam Reilly #1)
    • The Mahogany Ship (Sam Reilly #2)
    • Atlantis Stolen (Sam Reilly #3)
  • Dying Declaration - Randy Singer
  • The Enigma Strain (Harvey Bennett #1) - Nick Thacker
  • A Blind Eye (Adam Kaminski #1) - Jane Gorman
  • The Solomon Curse (Fargo Adventures #7) - Clive Cussler, Russell Blake
  • The Cosega Sequence - Brandt Legg
    • Cosega Search (Cosega Sequence #1)
    • Cosega Storm (Cosega Sequence #2)
    • Cosega Shift (Cosega Sequence #3)
  • Death By A HoneyBee (Josiah Reynolds #1) - Abigail Keam
  • The Last Airship (Sam Reilly #1) - Christopher Cartwright
  • Thunder Point (Sean Dillon Series, #2) - Jack Higgins
  • Dog Gone (Dev Haskell #12) - Mike Faricy
  • The Lady Who Sang High (Reed Ferguson #7) - Renee Pawlish
  • Island of Fog (Island of Fog #1) - Keith Robinson
  • Labyrinth of Fire (Island of Fog #2) - Keith Robinson
  • Mountain of Whispers (Island of Fog #3) - Keith Robinson
  • Murder In Paradise - Greg Wilson
  • Lake of Spirits (Island of Fog #4) - Keith Robinson
  • The Burning Page (Invisible Library #3) - Genevieve Cogman
  • Fly by Night (Jammer Davis #2) - Ward Larsen
  • The Amazon Code (Harvey Bennett #2) - Nick Thacker

Automatically publish your API when you push to github

Updated 11th October 2016 for API Connect

In less than half an hour I could update my project to automatically publish my API in IBM API Connect - Here's the steps...

Sign up for API Connect through Bluemix by creating an API Connect service instance - if you don't already have a Bluemix account you can sign up for a free trial account.

Install and configure the new toolkit CLI - replacing eu with au or us if you chose a different bluemix region:

npm install -g apiconnect 
apic config:set server=eu.apiconnect.ibmcloud.com
apic login

Create a product definition for your API:

apic create --type product --title "Travel Information" --apis product.yaml

Adjust the product definition as needed in your favourite editor

Add the x-ibm-configuration extensions to your swagger document to configure what happens when someone calls the API - in my case invoke the backend API

x-ibm-configuration:
  enforced: true
  phase: realized
  testable: true
  cors:
    enabled: true
  assembly:
    execute:
      - invoke:
          title: invoke
          target-url: '<backend url>'

Now switch over to your CodeShip account, load your project and go to the Deployment section of your project.

Add a custom script option and confiigure the following script (adding your details as needed):

npm install -g apiconnect
apic config:set server=eu.apiconnect.ibmcloud.com
apic login -u <username> -p <password>
apic config:set organization=<org>
apic push docs/swagger.yaml
apic stage --catalog=sb docs/travel-information.yaml
apic publish --catalog=sb docs/travel-information.yaml</code>

Commit and push to your repository and your updated API will be pushed to API Management! - Here is my example API

If you don't already have a CodeShip account you can sign up to CodeShip with your github account and create link in your github repository. You can then set up the tests and deployment steps in the project settings.

2015 Reading Log

  • Talon (Talon Saga #1) - Julie Kagawa
  • Moth (Moth Saga #1) - Daniel Arenson
  • The Pucelle Connection (Genevieve Lenard #6) - Estelle Ryan
  • The Silkworm (Cormoran Strike Book 2) - Robert Galbraith
  • Throne of Glass (Throne of Glass #1) - Sarah J. Maas
  • Crown of Midnight (Throne of Glass #2) - Sarah J. Maas
  • Heir of Fire (Throne of Glass #3) - Sarah J. Maas
  • Rise of the Dragons (Kings and Sorcerers #1) - Morgan Rice
  • Rise of the Valiant (Kings and Sorcerers #2) - Morgan Rice
  • Rogue (Talon Saga #2) - Julie Kagawa
  • A Quest of Heroes (Sorcerer's Ring #1) - Morgan Rice
  • A March of Kings (Sorcerer's Ring #2) - Morgan Rice
  • Heat Wave (Nikki Heat #1) - Richard Castle
  • A Fate of Dragons (Sorcerer's Ring #3) - Morgan Rice
  • A Cry of Honor (Sorcerer's Ring #4) - Morgan Rice
  • The Léger Connection (Genevieve Lenard #7) - Estelle Ryan
  • A Vow of Glory (Sorcerer's Ring #5) - Morgan Rice
  • Five Minutes Late - Rich Amooi
  • A Charge of Valor (Sorcerer's Ring #6) - Morgan Rice
  • Arena One: Slaverunners (Survival Trilogy #1) - Morgan Rice
  • Holy Island (DCI Ryan #1) - LJ Ross
  • Tapas, Carrot Cake and a Corpse (Charlotte Denver #1) - Sherri Bryan
  • Arena Two (Survival Trilogy #2) - Morgan Rice
  • A Meditation on Murder (An original Death in Paradise story) - Robert Thorogood
  • Hazardous Duty - Christy Barritt
  • A Rite of Swords (Sorcerer's Ring #7) - Morgan Rice
  • The Mystery of the Clockwork Sparrow (Sinclair's Mysteries) - Katherine Woodfine
  • The Beekeeper's Apprentice (A Mary Russell & Sherlock Holmes #1) - Laurie R. King
  • Night of the Assassin (Assassin Series Prequel) - Russell Blake
  • The Tombs (Fargo Adventures #4) - Clive Cussler, Thomas Perry
  • Mr Penumbra's 24-hour Bookstore - Robin Sloan
  • The Mayan Secrets (Fargo Adventures #5) - Clive Cussler, Thomas Perry
  • The Race (Isaac Bell #4) - Clive Cussler
  • Just One Damned Thing After Another (Chronicles of St Mary's #1) - Jodi Taylor
  • The Morisot Connection (Genevieve Lenard #8) - Estelle Ryan
  • A Sky of Spells (Sorcerer's Ring #9) - Morgan Rice
  • Spartan Gold (Fargo Adventures #1) - Clive Cussler
  • A Symphony of Echoes (Chronicles of St Mary's #2) - Jodi Taylor
  • A Second Chance (Chronicles of St Mary's #3) - Jodi Taylor
  • A Trail Through Time (Chronicles of St Mary's #4) - Jodi Taylor
  • No Time Like the Past (Chronicles of St Mary's #5) - Jodi Taylor
  • The Masked City (Invisible Library #2) - Genevieve Cogman
  • The Thief (Isaac Bell #5) - Clive Cussler, Justin Scott
  • Lost Empire (Fargo Adventures #2) - Clive Cussler