Skip to content

Instantly share code, notes, and snippets.

View skihero's full-sized avatar

Kish skihero

  • Amazon Mechanical Turk
  • Ooty
View GitHub Profile
@skihero
skihero / cfg_dir_nagios
Created September 29, 2014 06:31
cfg_dir_nagios
Format: cfg_file=<file_name>
Example: cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg
cfg_file=/usr/local/nagios/etc/commands.cfg
Actuals on the machine:
# object configuration files (see the cfg_file and cfg_dir options above).
@skihero
skihero / ping.c
Created September 29, 2014 12:04
ping -c
if ping -c 1 "$host" > /dev/null 2>&1; then
@skihero
skihero / gen_nagios_command_of_filesd
Created October 1, 2014 07:02
command conf construction helper nagios
# get a list of files
for f in `ls`
do
echo "command[${f}]=/usr/lib/nagios/plugins/${f} -H localhost -db apigee -u nagios --dbpass random_password # -w -c "
done
@skihero
skihero / include_dir_file
Created October 27, 2014 16:14
Include a conf directory and a file from the template, chef
include_dir = "#{node['nrpe']['conf_dir']}/nrpe.d"
directory include_dir do
owner node['nrpe']['user']
group node['nrpe']['group']
mode '0755'
end
template "#{node['nrpe']['conf_dir']}/nrpe.cfg" do
source 'nrpe.cfg.erb'
@skihero
skihero / nagios_nrpecheck
Created October 27, 2014 16:16
add or remove an nrpecheck
examples $ cat base_monitoring.rb
#
# Cookbook Name:: monitoring
# Recipe:: base_monitoring
#
# Copyright 2013, Example Company, Inc.
#
# This recipe defines the necessary NRPE commands for base system monitoring
# in Example Company Inc's Chef environment.
@skihero
skihero / nrpe.cfg.erb
Created October 27, 2014 16:16
templates/default/nrpe.cfg.erb
cat templates/default/nrpe.cfg.erb
# Autogenerated by Chef.
<%= "log_facility=#{node['nrpe']['log_facility']}" unless node['nrpe']['log_facility'].nil? %>
<%= "allow_bash_command_substitution=#{node['nrpe']['allow_bash_command_substitution']}" unless node['nrpe']['allow_bash_command_substitution'].nil? %>
<%= "command_prefix=#{node['nrpe']['command_prefix']}" unless node['nrpe']['command_prefix'].nil? %>
pid_file=<%= node['nrpe']['pid_file'] %>
server_port=<%= node['nrpe']['server_port'] %>
<%= "server_address=#{node['nrpe']['server_address']}" unless node['nrpe']['server_address'].nil? %>
nrpe_user=<%= node['nrpe']['user'] %>
@skihero
skihero / attributes_default.rb
Created October 27, 2014 16:17
attributes/default.rb
cat attributes/default.rb
# nrpe packge options
default['nrpe']['package']['options'] = nil
# nrpe daemon user/group
default['nrpe']['user'] = 'nagios'
default['nrpe']['group'] = 'nagios'
# config file options
default['nrpe']['allow_bash_command_substitution'] = nil
@skihero
skihero / mem_info.pl
Created November 5, 2014 09:44
mem_info extraction in perl
my @meminfo = `/bin/cat /proc/meminfo`;
foreach (@meminfo) {
chomp;
if (/^Mem(Total|Free):\s+(\d+) kB/) {
my $counter_name = $1;
@skihero
skihero / action_info_pg.pl
Created November 5, 2014 12:34
action_info
Quick hash to put normal action information in one place:
our $action_info = {
# Name # clusterwide? # helpstring
archive_ready => [1, 'Check the number of WAL files ready in the pg_xlog/archive_status'],
autovac_freeze => [1, 'Checks how close databases are to autovacuum_freeze_max_age.'],
backends => [1, 'Number of connections, compared to max_connections.'],
bloat => [0, 'Check for table and index bloat.'],
checkpoint => [1, 'Checks how long since the last checkpoint'],
cluster_id => [1, 'Checks the Database System Identifier'],
commitratio => [0, 'Report if the commit ratio of a database is too low.'],
@skihero
skihero / buff_tessy
Created December 16, 2014 12:33
buff
from Tkinter import *
from PIL import Image, ImageTk, ImageDraw
import urllib2
IMG_URI = "https://raw.githubusercontent.com/skihero/cor3/master/image_sample.jpg"
IMG_NAME = "image_sample.jpg"
bbox = [ (16, 17, 118, 152),