Skip to content

Instantly share code, notes, and snippets.

@ronbee
Last active January 3, 2016 02:29
Show Gist options
  • Select an option

  • Save ronbee/8396324 to your computer and use it in GitHub Desktop.

Select an option

Save ronbee/8396324 to your computer and use it in GitHub Desktop.

Revisions

  1. ronbee revised this gist Jan 13, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion poor-man-monitoring.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ Say you wanna monitor that your REST'ful service is up & working.


    1. treat gitted-file as a TAP unit-test
    2. define a TAP output project in Jenkins (that runs every xx minutes)
    2. define a TAP output project in Jenkins (that runs every xx minutes and sends email notifications)
    3. you're done

    _(in case of need, define more tests)_
  2. ronbee renamed this gist Jan 13, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. ronbee revised this gist Jan 13, 2014. 3 changed files with 10 additions and 5 deletions.
    5 changes: 0 additions & 5 deletions explain
    Original file line number Diff line number Diff line change
    @@ -1,5 +0,0 @@
    1) treat gitted-file as a TAP unit-test
    2) define a TAP output project in Jenkins (that runs every xx minutes)
    3) you're done

    (in case of need, define more tests)
    File renamed without changes.
    10 changes: 10 additions & 0 deletions poor-man-monitoring
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # A Poor Man's Monitoring

    Say you wanna monitor that your REST'ful service is up & working.


    1. treat gitted-file as a TAP unit-test
    2. define a TAP output project in Jenkins (that runs every xx minutes)
    3. you're done

    _(in case of need, define more tests)_
  4. ronbee created this gist Jan 13, 2014.
    5 changes: 5 additions & 0 deletions explain
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    1) treat gitted-file as a TAP unit-test
    2) define a TAP output project in Jenkins (that runs every xx minutes)
    3) you're done

    (in case of need, define more tests)
    25 changes: 25 additions & 0 deletions gitted-file
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    require 'json'
    require 'net/http'

    class Service_Status_Monitor

    TEST_SERVICES = [ 'http://111.111.111.111:8001/status' ] # this IS our config file..

    def run outf
    out = File.new( "#{File.dirname(__FILE__)}/#{outf}", "w" )
    out.puts "1..#{TEST_SERVICES.size}"
    TEST_SERVICES.each_with_index do |ustr,ii|
    begin
    reply = Net::HTTP.get_response( URI( ustr ) )
    body = JSON.parse( reply.body ) rescue { "status" => "no content / http code #{reply.code}" }

    out.puts "#{ ( reply.code == '200' and body["status"] == 'ok' ) ? "ok" : "not ok" } #{ii+1} - #{body}"
    rescue => err
    out.puts "not ok #{ii+1} - info: #{err}"
    end
    end
    out.close
    end
    end

    Service_Status_Monitor.new.run "monitor_status.out"