Skip to content

Instantly share code, notes, and snippets.

View mikepea's full-sized avatar

Mike Pountney mikepea

View GitHub Profile
diff --git a/lib/mcollective/util.rb b/lib/mcollective/util.rb
index abd5791..6870709 100644
--- a/lib/mcollective/util.rb
+++ b/lib/mcollective/util.rb
@@ -55,10 +55,19 @@ module MCollective
# If the passed value starts with a / it's assumed to be regex
# and will use regex to match
def self.has_fact?(fact, value)
- value = Regexp.new(value.gsub("\/", "")) if value.match("^/")
-
@mikepea
mikepea / gist:637418
Created October 20, 2010 22:01
beginnings of NEC IR code
void send_38khz_pulse(void) {
PORTB ^= irOut;
PORTB ^= redMask;
delay_x_us(26); // 17 works
}
void send_38khz_space(void) {
PORTB ^= bogusMask;
PORTB ^= bogusMask;
delay_x_us(26); // 17 works
@mikepea
mikepea / gist:8491609
Last active January 3, 2016 16:49
Setting up a Raspberry Pi for headless Arduino fun
sudo apt-get install arduino-core arduino-mk
sudo apt-get install screen
sudo apt-get install git
cd /usr/share/arduino/libraries
sudo git clone https://github.com/adafruit/Adafruit_NeoPixel.git
@mikepea
mikepea / graphite-calc.rb
Last active August 29, 2015 14:05
Graphite whisper file sizing calculator
#!/usr/bin/env ruby
#
# eg: graphite-calc.rb 10s:10d,5m:400d,24h:20y 20
# to calculate sizing for 20 hosts, 1000 metrics per host, 10s metric update interval
#
graphite_policy = ARGV.shift
num_hosts = ARGV.shift || 1
num_metrics = ARGV.shift || 1000
update_interval = ARGV.shift || 10
@mikepea
mikepea / gist:a3ebbada343c7c1f07b4
Created October 20, 2014 11:14
MongoDB replSet primary flip (secondary node goes primary) log file snippet
Mon Oct 20 00:22:38 [rsHealthPoll] DBClientCursor::init call() failed
Mon Oct 20 00:22:38 [rsHealthPoll] replSet info mongodb-02.local:27017 is down (or slow to respond): DBClientBase::findN: transport error: mongodb-02
.local:27017 query: { replSetHeartbeat: "rs0", v: 3, pv: 1, checkEmpty: false, from: "10.3.13.10:27017" }
Mon Oct 20 00:22:38 [rsHealthPoll] replSet member mongodb-02.local:27017 is now in state DOWN
Mon Oct 20 00:22:38 [rsMgr] replSet info electSelf 0
Mon Oct 20 00:22:38 [rsMgr] replSet PRIMARY
Mon Oct 20 00:22:40 [rsHealthPoll] replSet member mongodb-02.local:27017 is up
Mon Oct 20 00:22:40 [rsHealthPoll] replSet member mongodb-02.local:27017 is now in state RECOVERING
Mon Oct 20 00:22:42 [rsHealthPoll] replSet member mongodb-02.local:27017 is now in state SECONDARY
@mikepea
mikepea / gist:71b613676e5cfdd6fe03
Last active August 29, 2015 14:08
MongoDB upgrade plan

Mongo Migration Plan

Pre-migration work

This can be performed at any time prior to the migration, but as running Skyscape instances will be provisioned in the process it makes sense to do so when we have committed to a migration date.

  • Switch current mongo nodes over to vXXX (TODO) mongodb-formula, run update. This will reduce the management of the existing mongodb nodes, but still allow us to affect change on them.
@mikepea
mikepea / gist:443d1e07c430d447fd73
Created November 5, 2014 12:11
Logstash Best Practises WIP

Logstash Best Practises

Fix at the source first if you can

  • Log in json_event format where possible
  • Add as much markup information as possible, it's easier when you have context.

Generally we need to

@mikepea
mikepea / gist:07b1cede92c119e4f297
Last active February 24, 2022 10:53
Grafana Scripted Dashboard example for collectd with SeparateInstances and StoreRates enabled
/* global _ */
/*
* Complex scripted dashboard
* This script generates a dashboard object that Grafana can load. It also takes a number of user
* supplied URL parameters (int ARGS variable)
*
* Global accessable variables
* window, document, $, jQuery, ARGS, moment
*
* Return a dashboard object, or a function
@mikepea
mikepea / overview.js
Created November 11, 2014 20:17
Grafana scripted dashboard: node overview
/* global _ */
/*
* Grafana Scripted Dashboard to:
* * Give overview of all nodes in a cluster: CPU, Load, Memory
* * Provide links to other - more complex - dashboard for each node.
*
* Global accessable variables
* window, document, $, jQuery, ARGS, moment
*
* Return a dashboard object, or a function
@mikepea
mikepea / playbook.md
Created November 20, 2014 17:23
Graphite Carbon Cache Size Playbook

Graphite Carbon Cache Size Playbook