Skip to content

Instantly share code, notes, and snippets.

View zehome's full-sized avatar

Laurent Coustet zehome

View GitHub Profile
@zehome
zehome / gist:6011570
Created July 16, 2013 18:59
activate timeseries highcharts in graph-explorer
diff --git a/templates/snippet.graph-deps.tpl b/templates/snippet.graph-deps.tpl
index c484ba7..431b0a7 100644
--- a/templates/snippet.graph-deps.tpl
+++ b/templates/snippet.graph-deps.tpl
@@ -9,6 +9,8 @@
<script src="../timeserieswidget/flot/jquery.flot.selection.js"></script>
<script src="../timeserieswidget/flot/jquery.flot.time.js"></script>
<script src="../timeserieswidget/flot/jquery.flot.stack.js"></script>
+<script src="../timeserieswidget/highcharts/highcharts.js"></script>
+<script src="../timeserieswidget/highcharts/modules/exporting.js"></script>
--- a/app.py
+++ b/app.py
@@ -436,7 +436,7 @@ def build_graphs_from_targets(targets, query={}):
graph_config['targets'].append(targets[0])
else:
t = {
- 'target': 'sumSeries(%s)' % (','.join([t['graphite_metric'] for t in targets])),
+ 'target': 'sumSeries(%s)' % (','.join([t['target'] for t in targets])),
'graphite_metric': [t['graphite_metric'] for t in targets],
'variables': targets[0]['variables']
@zehome
zehome / gist:6122038
Last active December 20, 2015 11:19
use simple hash function to avoid re-sending all targets as alias
diff --git a/jquery.tswidget.js b/jquery.tswidget.js
index b30e77a..f300745 100755
--- a/jquery.tswidget.js
+++ b/jquery.tswidget.js
@@ -4,6 +4,9 @@ function strip_ending_slash(str) {
}
return str;
}
+function hash_target(target) {
+ return target.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a;},0);
@zehome
zehome / gist:6213872
Created August 12, 2013 18:53
Django reverse proxy for graphite
# Requirement: httplib2
import httplib2
class Httplib2ProxyMixin(object):
def _proxy(self, method, uri, body=None):
assert(method in ("GET", "POST"))
http = httplib2.Http()
resp, content = http.request(uri, method,
headers={'cache-control': 'no-cache'},
body=body)
@zehome
zehome / cross_request_origin_graphite.md
Last active December 21, 2015 17:29
Enable cross request for graphite/gunicorn

Create this file in your graphite installation directory: lib/python2.7/site-packages/graphite/crossmiddleware.py

import re
 
from django.utils.text import compress_string
from django.utils.cache import patch_vary_headers
 
from django import http
settings = {
core = {
real_name = "xx";
user_name = "xx";
nick = "xx";
recode_out_default_charset = "ISO-8859-15";
recode_autodetect_utf8 = "Yes";
recode_transliterate = "Yes";
};
"fe-text" = { actlist_sort = "refnum"; };
@zehome
zehome / upgrade_openbsd58_openbsd59.yml
Last active June 29, 2016 12:14
Dirty incomplete upgrade OpenBSD 5.8 to 5.9 using ansible 2
---
- hosts: all
gather_facts: yes
vars:
mirror: http://ftp.eu.openbsd.org/pub/OpenBSD
release: 5.9
arch: amd64
tasks:
- name: installboot on sd0
command: installboot -v sd0
@zehome
zehome / mlvpn_updown.sh
Created May 25, 2016 14:39
mlvpn updown.sh for linux without tunnel ip address required
#!/bin/sh
# up/down script for MLVPN.
#
# MLVPN calls this script with at least 2 arguments:
# $1 : interface name
# $2 : "command"
# command can be:
# - "tuntap_up"
# - "tuntap_down"
@zehome
zehome / upgrade_openbsd60.yml
Created September 19, 2016 07:48
Upgrade to OpenBSD 6.0 using ansible
---
- hosts: all
gather_facts: yes
vars:
mirror: http://ftp.fr.openbsd.org/pub/OpenBSD
release: 6.0
arch: amd64
files:
- SHA256
- SHA256.sig
@zehome
zehome / gitlab_upgrade.sh
Created December 26, 2016 16:35
Upgrading source installation of gitlab in one script
#!/bin/bash
set -e
version="v8.15.1"
systemctl stop gitlab
cd /home/git/gitlab
echo Stash