This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
description "Upstart script to run a nodejs app as a service" | |
author "Louis Chatriot" | |
env NODE_BIN=/usr/local/bin/node | |
env APP_DIR=/path/to/app/dir | |
env SCRIPT_FILE="scriptfile.js" # Entry point for the nodejs app | |
env LOG_FILE=/path/to/logfile.log | |
env RUN_AS="anyuser" # Upstart can only be run nicely as root, need to drop privileges | |
env SERVER_ENV="anything" # Usual apps can be run in different environments (development, test, production ...) | |
# I typically use the environment variable NODE_ENV (see below) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# | |
# This script needs "fpm". If you dont have it, | |
# run "gem install fpm" | |
# | |
# You also need to "apt-get install python-setuptools" (otherwise fpm fails) | |
clean() { | |
rm -rf whisper-0.9.9 carbon-0.9.9 graphite-web-0.9.9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#################################### | |
# BASIC REQUIREMENTS | |
# http://graphite.wikidot.com/installation | |
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/ | |
# Last tested & updated 10/13/2011 | |
#################################### | |
cd | |
sudo apt-get update | |
sudo apt-get upgrade |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(streams | |
(where (and metric (service "app1")(tagged "sign_in") | |
; We want to get alerted about failed sign ins. However we expect that there will be failures | |
; due to incorect passwords etc. So we only want to get alerted if more than 50% of the signins | |
; in a 60 second period are failures. The app tags failed signins with a warning state. | |
(fixed-time-window 60 | |
(smap (fn [events] | |
; count all warnings and count all received events and work out the percentage | |
(let [percent (/ (count (filter #(= (:state %) "warning") events)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http') | |
, fs = require('fs') | |
, PORT = process.argv[2] || 8080 | |
, HOST = process.argv[3] || '127.0.0.1'; | |
http.createServer(function (req, res) { | |
if (req.url == '/events') { | |
res.writeHead(200, { 'Content-Type' : 'text/event-stream' | |
, 'Cache-Control' : 'no-cache' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use '[clojure.contrib.shell-out :only [sh]]) | |
(defn sh-timeout [timeout-in-seconds & args] | |
(.get | |
(future-call #(apply sh args)) | |
timeout-in-seconds | |
(java.util.concurrent.TimeUnit/SECONDS))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns proc | |
(:import [java.lang ProcessBuilder]) | |
(:use [clojure.java.io :only [reader writer]])) | |
(defn spawn [& args] | |
(let [process (-> (ProcessBuilder. args) | |
(.start))] | |
{:out (-> process | |
(.getInputStream) | |
(reader)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns factual.riemann.latency | |
(:use riemann.streams | |
clojure.tools.logging)) | |
(def warning-latencies | |
"A map of service names to the minimum warning latency for that service." | |
(into {} (map (fn [[k v]] [(str "dsapi " k) v]) | |
{"extract post" 5000 | |
"get diffs" 1000 | |
"get inputs" 1000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns factual.riemann.latency | |
(:use riemann.streams | |
clojure.tools.logging)) | |
(def warning-latencies | |
"A map of service names to the minimum warning latency for that service." | |
(into {} (map (fn [[k v]] [(str "dsapi " k) v]) | |
{"extract post" 5000 | |
"get diffs" 1000 | |
"get inputs" 1000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Clock skew detection | |
(clock-skew | |
(by :host | |
(throttle 1 1 | |
(with :service "clock skew" | |
(where metric | |
(splitp < (abs metric) | |
10 (with :state "critical" index graph) | |
2 (with :state "warning" index graph) | |
(with :state "ok" index graph))))))) |