Skip to content

Instantly share code, notes, and snippets.

@jmara
jmara / gist:8035c07a86ff111465d9
Last active August 29, 2015 14:12
If distribution is Debian/Ubuntu
<?php
// Simple socket server
// See http://php.net/manual/en/function.stream-socket-server.php
$port = $argv[1];
$mysql_port = $argv[2];
$mysql = "/usr/bin/mysql";
$query = "SHOW SLAVE STATUS";
function set_weight($lag){
# Write your own rules here
if ($lag == 'NULL'){
@jmara
jmara / chefdk.sh
Last active August 29, 2015 14:09
chefdk.sh
#!/bin/bash
name="chefdk-0.3.2-1"
dmg="https://opscode-omnibus-packages.s3.amazonaws.com/mac_os_x/10.8/x86_64/${name}.dmg"
pkg="${name}.pkg"
mnt="/Volumes/Chef Development Kit"
test -f ${name}.dmg||curl -O ${dmg}
hdiutil attach ${name}.dmg
include_recipe "apache"
include_recipe "php"
# Just to make it clear ;)
node.default["myface"]["template"] = "production.conf.erb"
if node.recipes.include?("myface::dev")
include_recipe "myface::dev"
end
do shell script "xcode-select --install"
do shell script "sleep 1"
tell application "System Events"
tell process "Install Command Line Developer Tools"
keystroke return
click button "Agree" of window "License Agreement"
end tell
end tell
file "/opt/local-user.txt" do
action :create
owner "root"
group "root"
content "jmara"
mode 00644
end
if File.exist?("/opt/local-user.txt")
user = File.read("/opt/local-user.txt")
@jmara
jmara / gist:3608788
Created September 3, 2012 11:52
VIP for a node with a working service
Control a VIP based on a location constrain but not the actual resource ...
node $id="55f27a97-c277-4287-997e-79da9ebfe879" node-1
node $id="bd7d0d7a-4e5a-43f7-9065-24ee3da8617d" node-2
primitive apache lsb:apache2 \
meta is-managed="false" \
op monitor interval="60s"
@jmara
jmara / gist:3532506
Created August 30, 2012 16:32
check_mysql_health
wget http://labs.consol.de/wp-content/uploads/2011/08/check_mysql_health-2.1.7.tar.gz
tar xfz check_mysql_health-2.1.7.tar.gz
cd check_mysql_health-2.1.7/
./configure
make && make install
Depends on Perl MySQL DBI / DBD
English docs: http://labs.consol.de/lang/en/nagios/check_mysql_health/