Skip to content

Instantly share code, notes, and snippets.

[inodes_alert:log11] 2017/02/28 20:39:40 I! {"Name":"disk","Database":"","RetentionPolicy":"","Group":"host=aws-nv-u-csadb02,path=/net/zfs1/export/analyticsbinning","Dimensions":{"ByName":false,"TagNames":["host","path"]},"Tags":{"host":"aws-nv-u-csadb02","path":"/net/zfs1/export/analyticsbinning"},"Fields":{"inodes_used_percent":0},"Time":"2017-02-28T20:39:40Z"}
[inodes_alert:log11] 2017/02/28 20:39:40 I! {"Name":"disk","Database":"","RetentionPolicy":"","Group":"host=aws-nv-u-csadb02,path=/net/zfs1/export/analyticsdigital","Dimensions":{"ByName":false,"TagNames":["host","path"]},"Tags":{"host":"aws-nv-u-csadb02","path":"/net/zfs1/export/analyticsdigital"},"Fields":{"inodes_used_percent":0},"Time":"2017-02-28T20:39:40Z"}
[inodes_alert:log11] 2017/02/28 20:39:40 I! {"Name":"disk","Database":"","RetentionPolicy":"","Group":"host=aws-nv-u-csadb02,path=/net/zfs1/export/analyticsprojects","Dimensions":{"ByName":false,"TagNames":["host","path"]},"Tags":{"host":"aws-nv-u-csadb02","path":"/net/zfs1/export/analyti
@bayendor
bayendor / inodes_alert.tick
Created February 28, 2017 17:54
Kapacitor alert to warn on inodes percent used
// inodes_alert example
// DEFINE: kapacitor define inodes_alert -type stream -tick inodes_alert.tick -dbrp telegraf.ninety_days
// ENABLE: kapacitor enable inodes_alert
// Parameters
var period = 5m
var every = 30s
var warn = 90
var crit = 95
@bayendor
bayendor / keybase.md
Created April 22, 2016 15:44
keybase.md

Keybase proof

I hereby claim:

  • I am bayendor on github.
  • I am dbayendor (https://keybase.io/dbayendor) on keybase.
  • I have a public key ASB1V69Is1m_YenJTKqCUfMSmusHP5quka8emz0F5BjJNQo

To claim this, I am signing this object:

@bayendor
bayendor / puppet.vim
Created April 4, 2016 14:05
VIM Config settings for working with Puppet
" Set up puppet manifest and spec options
au BufRead,BufNewfile *.pp
\ set filetype=puppet
au BufRead,BufNewfile *_spec.rb
\ nmap <F8 :!rspec --color %<CR>
" Enable indentation matching for =>'s
filetype plugin indent on
" turn off auto adding comments on next line
@bayendor
bayendor / gist:7999530
Created December 17, 2013 03:24
Always use :inverse_of to connect two models in a belongs_to/has_many relationship. When you have two models in a belongs_to/has_many relationship, you should always use the :inverse_of option to tell ActiveRecord that they're two sides of the same association. By setting this option, Rails can optimize object loading so forum and forum.posts[0]…
class Forum < ActiveRecord::Base
has_many :posts, :inverse_of => :forum
end
class Post < ActiveRecord::Base
belongs_to :forum, :inverse_of => :posts
end
@bayendor
bayendor / gist:7385660
Created November 9, 2013 13:55
Ransack multiple selects
f.collection_select :some_id_in, Model.all, :id, :name, {}, {:multiple => true}
# I have to do the following to get the select field I want:
search_form_for @search do |f|
f.collection_select :level_in, Log.levels, :to_s, :to_s, {}, { size: Log.levels.length, multiple: true }
@bayendor
bayendor / gist:7385546
Last active December 27, 2015 20:39
Checkbox in ransack search
# model CLINIC has many TREATMENTS
<%= check_box_tag "q[treatments_id_eq_ALL][]", treatment.id, {} %>
= f.input :category_name_eq, :collection=>Estate::Category.all.map(&:name), :as=>:check_boxes
@bayendor
bayendor / gist:7380393
Created November 9, 2013 01:39
Csv import model logic
# controller
def proc_csv
import = Import.find(params[:id])
if import.load_csv
flash[:notice] = "woo"
redirect_to some_url
else
flash[:error] = "ohoh"
end
end
@bayendor
bayendor / sql_limit_return.erb
Last active December 25, 2015 21:39
Code to display the SQL query from an ActiveRecord Search & to limit number of results returned. From the ransack gem demo.
<p>SQL: <%= @users.to_sql %></p>
<h2>Your first #{search_limit} results</h2>
<table>
<thead>
<th><%= sort_link @search, :id, {}, :method => action_name == 'advanced_search' ? :post : :get %></th>
<th><%= sort_link @search, :first_name, {}, :method => action_name == 'advanced_search' ? :post : :get %></th>
# ...
</thead>
@bayendor
bayendor / docker
Last active October 6, 2015 15:56 — forked from chernjie/logrotate.d-docker
Logrotate docker logs, copy this file to /etc/logrotate.d/docker
/data/docker/containers/*/*-json.log {
daily
rotate 7
size 100M
compress
delaycompress
missingok
}