Skip to content

Instantly share code, notes, and snippets.

View thomasgogo's full-sized avatar

thomas thomasgogo

  • 18:40 (UTC +08:00)
View GitHub Profile
FIELDS = ['cmd', 'command', 'start', 'end', 'delta', 'msg', 'stdout', 'stderr']
def human_log(res):
if type(res) == type(dict()):
for field in FIELDS:
if field in res.keys():
# use default encoding, check out sys.setdefaultencoding
print u'\n{0}:\n{1}'.format(field, res[field])
# or use specific encoding, e.g. utf-8
@pcn
pcn / logback.conf
Created May 24, 2012 17:31
trying for a logstash conf file that works with java's logback logger
input {
# file {
# path => ["/var/log/knewton/*/*.log"]
# type => "knewton_logback"
# }
stdin {
type => "knewton_logback"
}
}
@chmouel
chmouel / noclientdebug.py
Created September 2, 2011 02:54
debugging novaclient
import novaclient
from novaclient.v1_1 import client
import logging
ch = logging.StreamHandler()
novaclient.client._logger.setLevel(logging.DEBUG)
novaclient.client._logger.addHandler(ch)
@wangwen1220
wangwen1220 / js-trim.js
Created January 26, 2014 07:03
JS: 去掉 String 中的多余空格 | trim
// 去掉 String 中的多余空格
if (!String.prototype.trim) {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
};
}
// 用法
var str = " some string ";
str.trim();
@tomheng
tomheng / gist:6149779
Last active May 21, 2019 08:21
用Memcache实现分布式的锁服务
<?php
/**
* 锁服务(用Memcache模拟锁)
*/
class Lock{
private $mc = null;
private $key_prefix = "memcache_lock_service_key_";
@wutingjia
wutingjia / 集中式日志分析方案.md
Last active July 28, 2021 01:38
集中式日志分析方案

使用技术:Filebeat + kafka + logstash + elasticsearch + kibana
(日志采集) (传输) (数据收集整理) (数据存储搜索分析) (数据分析可视化)

Logger

这里使用slf4j+logback的组合,首先需要注意是否与某些依赖继承的log4j冲突,需要把它exculusion,如果存在,slf4j会报找到多个binding的实现,然后会自己选取一种。
slf4J 是 简单日志门面(simple logger facade),并没有具体的日志实现,只提供一组接口,这样用户就无需,因为不同的底层实现而编写不同的代码。
首先需要依赖logback-classic和slf4j-api。如果使用的是log4j还需要slf4j-log4j12 作为连接。
对于logback其配置文件为resource下的logback.xml。
配置例如:

<logger name="ELKLogger" level="DEBUG" additivity="true">
@jessone
jessone / hosts
Last active June 29, 2022 13:40
hosts BlockAD update:2022/06/29
#Copyright (c) 2011-2018 huaqing.org
#Update 2020-02-11
127.0.0.1 localhost
0.0.0.0 license.sublimehq.com
#Video
0.0.0.0 atm.youku.com
0.0.0.0 p-log.ykimg.com
0.0.0.0 Fvid.atm.youku.com
0.0.0.0 html.atm.youku.com
0.0.0.0 vhtml.atm.youku.com
# This gist is compatible with Ansible 1.x .
# For Ansible 2.x , please check out:
# - https://gist.github.com/dmsimard/cd706de198c85a8255f6
# - https://github.com/n0ts/ansible-human_log
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@deviantony
deviantony / vsphere_info.py
Last active March 5, 2023 14:51
VMWare Vsphere info in Python using pyvmomi
#!/usr/bin/env python
import pyVmomi
import argparse
import atexit
import itertools
from pyVmomi import vim, vmodl
from pyVim.connect import SmartConnect, Disconnect
import humanize
@ScriptingSquirrel
ScriptingSquirrel / export-node-stats.md
Last active April 4, 2023 02:18
Setup prometheus-node-exporter and push stats to Pushgateway with cron job

(Assuming a Debian 8-like system)

  • Install prometheus-node-exporter

    $ sudo apt update && sudo apt install prometheus-node-exporter
  • Configure prometheus-node-exporter to expose metrics only to localhost, not on to all networks. Modify file /etc/default/prometheus-node-exporter:

    # Set the command-line arguments to pass to the server.