Skip to content

Instantly share code, notes, and snippets.

@chenryn
chenryn / maxminddb.p6
Created October 9, 2015 11:55
a perl6 script to call libmaxminddb using NativeCall
#!/usr/bin/env perl6-m
use v6;
use NativeCall;
class MaxMindDB {
enum MMDB_DATA_TYPE (
MMDB_DATA_TYPE_EXTENDED => 0,
MMDB_DATA_TYPE_POINTER => 1,
MMDB_DATA_TYPE_UTF8_STRING => 2,
MMDB_DATA_TYPE_DOUBLE => 3,
{"cluster_name":"es1003","version":97,"master_node":"Ut88M5SETsW5XsyyQyKbTQ","blocks":{"indices":{"logstash-weiboad-2015.07.13":{"4":{"description":"index closed","retryable":false,"levels":["read","write"]}},"logstash-weiboad-2015.07.02":{"4":{"description":"index closed","retryable":false,"levels":["read","write"]}},"logstash-weiboad-2015.07.12":{"4":{"description":"index closed","retryable":false,"levels":["read","write"]}},"logstash-weiboad-2015.07.01":{"4":{"description":"index closed","retryable":false,"levels":["read","write"]}},"logstash-weiboad-2015.07.11":{"4":{"description":"index closed","retryable":false,"levels":["read","write"]}},"logstash-weiboad-2015.07.10":{"4":{"description":"index closed","retryable":false,"levels":["read","write"]}},"logstash-weiboad-2015.07.06":{"4":{"description":"index closed","retryable":false,"levels":["read","write"]}},"logstash-weiboad-2015.06.26":{"4":{"description":"index closed","retryable":false,"levels":["read","write"]}},"logstash-weiboad-2015.07.05":{"4":{"d
{
"order": 1,
"template": "heka",
"settings": {
"index.number_of_shards": 5,
"number_of_replicas": 1,
"index.refresh_interval": "10s"
},
"mappings": {
"loadbalancer": {
@chenryn
chenryn / heka-example.toml
Created October 13, 2014 09:43
heka tcpinput to logoutput
[TcpInput]
address = ":5140"
parser_type = "message.proto"
decoder = "tcpdecoder"
[tcpdecoder]
type = "PayloadRegexDecoder"
match_regex = '^(?P<msg>.+)$'
[tcpdecoder.message_fields]
@chenryn
chenryn / zabbit2pylab.py
Created July 24, 2014 11:43
get zabbix history then plot it
#!/usr/bin/env python
"""
Read item history from zabbix, and plot as histogram
"""
import matplotlib
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
import requests
import json
#!/usr/bin/perl
use 5.010;
use warnings;
use strict;
use Geo::IP;
use Parse::Syslog::Line qw( parse_syslog_line );
use Socket qw( getnameinfo NI_NUMERICHOST NI_NUMERICSERV );
use POSIX qw( strftime );
use AnyEvent;
use AnyEvent::Handle::UDP;
@chenryn
chenryn / skyline-algorithms.pl
Last active August 29, 2015 14:02
port etsy skyline/algorithms.py to Perl5, and use s-w test instead of k-s test
use warnings;
use strict;
use 5.010;
#use Data::Dumper;
use PDL;
use PDL::Fit::Polynomial;
use PDL::Finance::Talib;
use Statistics::Distributions qw/tdistr/;
use Statistics::Normality qw/shapiro_wilk_test/;
use JSON;
@chenryn
chenryn / elasticsearch-skyline.py
Created June 4, 2014 14:14
change etsy skyline to read metrics from elasticsearch directly.
import pandas
import numpy as np
import scipy
import statsmodels.api as sm
import os
import sys
import json
import traceback
import logging
from time import time
@chenryn
chenryn / nagios.cfg
Created May 9, 2014 06:53
omd-1.0-gen-nagios.cfg
#
# This file has been created by OMD out of the following files:
#
# /omd/sites/cdn/etc/nagios/nagios.d/dependency.cfg
# /omd/sites/cdn/etc/nagios/nagios.d/eventhandler.cfg
# /omd/sites/cdn/etc/nagios/nagios.d/flapping.cfg
# /omd/sites/cdn/etc/nagios/nagios.d/freshness.cfg
# /omd/sites/cdn/etc/nagios/nagios.d/logging.cfg
# /omd/sites/cdn/etc/nagios/nagios.d/misc.cfg
# /omd/sites/cdn/etc/nagios/nagios.d/mk-livestatus.cfg
@chenryn
chenryn / gist:9825021
Last active August 29, 2015 13:57
网站运维之监控概述

监控的意义

对公司来说

  • 没钱的公司:求爷爷告奶奶别挂啊
  • 有钱的公司:啥产品不能买来用啊 DevOps产品截图

对个人来说