Skip to content

Instantly share code, notes, and snippets.

View ianrumford's full-sized avatar

Ian Rumford ianrumford

View GitHub Profile
@ianrumford
ianrumford / clojurereducersblog1
Created August 25, 2013 11:25
Some node examples of using Clojure's Redcuers
(ns reducers.blog1
[:require [clojure.core.reducers :as r]
[clojure.string :as string]])
;; The Families in the Village
(def village
[
{:home :north :family "smith" :name "sue" :age 37 :sex :f :role :parent}
{:home :north :family "smith" :name "stan" :age 35 :sex :m :role :parent}
@ianrumford
ianrumford / blog_feed_jmx2_jmxbeanconfigOperatingSystem.rb
Last active December 11, 2015 01:49
Riemann Feeds blog_feed_jmx2.jmxbeanconfigOperatingSystem.rb
# riemann feeds
# jmxbeanconfigOperatingSystem
# Some normalisation stuff
bytes2GB = (1024 * 1024 * 1024).to_f
bytes_2_gigabytes = ->(b) { b.to_f / bytes2GB }
{ bean_name: 'java.lang:type=OperatingSystem',
@ianrumford
ianrumford / blog_feed_jmx2_jmxbeanconfigNameNodeActivity.rb
Last active December 11, 2015 01:49
Riemann Feed blog_feed_jmx2.jxmbeanconfigNameNodeActivity.rb
# riemann feeds
# jmxbeanconfigNameNodeActivity
{ bean_name: 'Hadoop:service=NameNode,name=NameNodeActivity',
event_defaults: { tags: ['Activity', 'Files'] },
attributes: {include: ['files_created', 'files_deleted']},
}
@ianrumford
ianrumford / blog_feed_jmx2_feedspecNameNode.rb
Last active December 11, 2015 01:49
Riemann Feeds blog_feed_jmx2.feedspecNameNode.rb
# riemann feeds
# ./etc/feedspecNameNode.rb
config_home = './etc'
# Usual configuration
credentials_jmx_path = "#{config_home}/credentialsJMX.yaml"
@ianrumford
ianrumford / blog_feed_jmx2.rb
Last active December 11, 2015 01:49
RIemann Feeds blog_feed_jmx2.rb
#!/usr/bin/jruby
# riemann feeds
# A simple JMX feed monitoring the Hadoop YARN NameNode
require 'riemann-feeds' # bootstrap rieeman feeds
#$DEBUG = true # force diags
@ianrumford
ianrumford / blog_feed_jmx1_each_event.rb
Created January 13, 2013 16:13
Riemann Feeds blog_feed_jmx1_each_event.rb
def each_event
beanInst = find_jmx_bean_or_croak('Hadoop:service=NameNode,name=NameNodeActivity')
yield({host: '10.16.0.48', service: 'NameNode', status: 'ok', tags: ["YARN", "NameNode", "Activity", "Files"], metric: beanInst.files_created, description: 'files_created'})
yield({host: '10.16.0.48', service: 'NameNode', status: 'ok', tags: ["YARN", "NameNode", "Activity", "Files"], metric: beanInst.files_deleted, description: 'files_deleted'})
beanInst = find_jmx_bean_or_croak('java.lang:type=OperatingSystem')
(r = map_free_physical_memory_size_568369({host: '10.16.0.48', service: 'NameNode', status: 'ok', tags: ["YARN", "NameNode", "OS", "FreeMem"], metric: metric_free_physical_memory_size_710285(beanInst.free_physical_memory_size), description: 'free_physical_memory_size'})) && select_free_physical_memory_size_237256(r) && yield(r)
yield({host: '10.16.0.48', service: 'NameNode', status: 'ok', tags: ["YARN", "NameNode", "OS"], metric: beanInst.free_swap_space_size, description: 'free_swap_space_s
@ianrumford
ianrumford / blog_feed_jmx1.rb
Last active December 11, 2015 01:39
Riemann Feeds blog_feed_jmx1.rb
#!/usr/bin/jruby
# riemann feeds
# A simple JMX feed monitoring the Hadoop YARN NameNode
require 'riemann-feeds' # bootstrap rieeman feeds
#$DEBUG = true # force diags
@ianrumford
ianrumford / blog_feed_jmx0_each_event.rb
Last active December 11, 2015 01:38
Riemann Feeds blog_feed_jmx0_each_event.rb
def each_event
beanInst = find_jmx_bean_or_croak('Hadoop:service=NameNode,name=NameNodeActivity')
yield({host: '10.16.0.48', service: 'NameNode', status: 'ok', tags: ["YARN", "NameNode"], metric: beanInst.create_file_ops, description: 'create_file_ops'})
yield({host: '10.16.0.48', service: 'NameNode', status: 'ok', tags: ["YARN", "NameNode"], metric: beanInst.files_created, description: 'files_created'})
yield({host: '10.16.0.48', service: 'NameNode', status: 'ok', tags: ["YARN", "NameNode"], metric: beanInst.files_appended, description: 'files_appended'})
yield({host: '10.16.0.48', service: 'NameNode', status: 'ok', tags: ["YARN", "NameNode"], metric: beanInst.get_block_locations, description: 'get_block_locations'})
yield({host: '10.16.0.48', service: 'NameNode', status: 'ok', tags: ["YARN", "NameNode"], metric: beanInst.files_renamed, description: 'files_renamed'})
yield({host: '10.16.0.48', service: 'NameNode', status: 'ok', tags: ["YARN", "NameNode"], metric: beanInst.get_listing_ops, desc
@ianrumford
ianrumford / blog_feed_jmx0.rb
Last active December 10, 2015 18:28
Riemann Feeds blog_feed_jmx0
#!/usr/bin/jruby
# riemann feeds
# A simple JMX feed monitoring the Hadoop YARN NameNode
require 'riemann-feeds' # bootstrap reieman feeds
#$DEBUG = true # force diags
@ianrumford
ianrumford / blog_make_inline_functions1.clj
Created November 15, 2012 16:08
Contracts examples blog_make_inline_functions1
(ns contracts-examples.blog_make_inline_functions1
(:require [clojure.core.contracts :as ccc]))
;; Generate output contract - note the signature accepts anything
;; Require my modification to clojure.core.contracts
(def aspect-spit-a-number
(ccc/contract aspect-spit-a-number-cx
"enforce a number as the return value"
[& any]