Skip to content

Instantly share code, notes, and snippets.

View gswallow's full-sized avatar

Greg Swallow gswallow

  • Indianapolis, IN, USA
View GitHub Profile
@gswallow
gswallow / gist:9b55e3b702dd1abd788c
Created August 26, 2015 16:07
Fun with git clone
git clone --mirror git@github.com:indigo-biosystems/ascent-assays.git
du -sh du -sh ascent-assays.git/
21M ascent-assays.git/
The second column, "1," is the number of hard links to the file:
ls -l ascent-assays.git/objects/pack/pack-612f3079a7f84b1fddeb091d9f35bb72ecd0d45a.*
-r--r--r-- 1 indigo_chef indigo_chef 596800 Aug 26 10:39 ascent-assays.git/objects/pack/pack-612f3079a7f84b1fddeb091d9f35bb72ecd0d45a.idx
-r--r--r-- 1 indigo_chef indigo_chef 20896217 Aug 26 10:39 ascent-assays.git/objects/pack/pack-612f3079a7f84b1fddeb091d9f35bb72ecd0d45a.pack
ruby_block "Comb through assays and create templates" do
block do
def find_assays(customer)
assays = Array.new
assays_dir = Dir.entries("/var/scripts/assays/#{customer}/current")
assays_dir.each { |e| assays << e unless e =~ /^\./ }
assays
end
# This file was created for hk01.qa1.indigobio.com
# by Chef
# Manual changes will be lost
input {
file {
'codec' => multiline {
'pattern' => "^[EI], \["
'negate' => "true"
'what' => "previous"
node.default['mongodb']['logstash_server_role'] = "logstash_allinone"
logstash_server = search(:node, "role:#{node['mongodb']['logstash_server_role']} AND chef_environment:#{node.chef_environment}").first
unless logstash_server.nil?
node.set['logstash']['patterns'] = {
"mongodb" => {
"WORDDASH" => '\b[\w-]+\b',
"MONGODB" => '%{SYSLOGTIMESTAMP:timestamp} \[%{WORD:component}\] %{GREEDYDATA:message}',
"SLOW_QUERY" => 'query %{WORDDASH:database}\.%{WORDDASH:collection} %{NOTSPACE}: \{ (?<query>(.*)(?<=(} )))%{WORD}:%{NONNEGINT:ntoreturn} %{WORD}:%{NONNEGINT:ntoskip} %{WORD}:%{NONNEGINT:nscanned} %{NOTSPACE:what}..*(?<duration>(?<= )[0-9]+)ms'
}
@gswallow
gswallow / gist:9011322
Last active August 29, 2015 13:56
grok patterns for mongodb logs
WORDDASH \b[\w-]+\b
QUERY \{ (?<={ ).*(?= } ntoreturn:) \}
MONGODB %{SYSLOGTIMESTAMP:timestamp} \[%{WORD:component}\] %{GREEDYDATA:message}
After extracting [message] using %{MONGODB}, pass [message] through grok once again using %{SLOWQUERY}
SLOWQUERY %{WORD} %{WORDDASH:database}\.%{WORDDASH:collection} %{WORD}: %{QUERY:query} %{WORD}:%{NONNEGINT:ntoreturn} %{WORD}:%{NONNEGINT:ntoskip} %{WORD}:%{NONNEGINT:nscanned}.*nreturned:%{NONNEGINT:nreturned}..+ (?<duration>[0-9]+)ms
query ascent_production_alere1.assay_configurations query: { converted_chromatogram_id: { $in: [ ObjectId('b1cbbf5ce3ab610d74830642') ] } } ntoreturn:1 ntoskip:0 nscanned:1 keyUpdates:0 locks(micros) r:268396 nreturned:1 reslen:1926148 268ms
"post-processors": [
{
"type": "vagrant",
"output": "{{.BuildName}}.box",
"only": [ "indigo_windows-2008r2-sp1-amd64-vmware", "indigo_windows-2008r2-sp1-amd64-virtualbox" ],
"keep_input_artifact": true,
"vagrantfile_template": "vmware/Vagrantfile.tmpl",
"override": {
"indigo_windows-2008r2-sp1-amd64-virtualbox": {
"vagrantfile_template": "virtualbox/Vagrantfile.tmpl"
checks = case
when Chef::Config[:solo]
data_bag("sensu_checks").map do |item|
data_bag_item("sensu_checks", item)
end
when Chef::DataBag.list.has_key?("sensu_checks")
search(:sensu_checks, "*:*")
else
Array.new
end
sudo chef-client -E qa1
Starting Chef Client, version 11.6.0
resolving cookbooks for run list: ["chef_handler", "chef_handler::hipchat", "chef_handler::updated_resources", "ulimit", "apt", "git", "resolvconf", "ntp", "ascent-common::linux", "ascent-common::users", "ascent-common::hostsfile", "ascent-wrappers::mongodb", "ascent-logs::mongodb"]
Synchronizing Cookbooks:
- chef_handler
- ulimit
- apt
- git
- dmg
- build-essential
@gswallow
gswallow / gist:10479197
Created April 11, 2014 15:48
Create an SSL cert data bag from raw certificate files
#!/usr/bin/env ruby
require 'json'
id = ARGV.shift
cert = Array.new
ARGV.each do |file|
File.open(file, 'r').each_line do |line|
cert << line.strip
end
{
"name": "qa1",
"description": "QA environment #1",
"cookbook_versions": {
"Rstats": "= 3.0.5",
"ant": "= 1.0.2",
"apache2": "= 1.8.14",
"application": "= 4.1.4",
"application_ruby": "= 3.0.2",
"apt": "= 1.9.2",