Skip to content

Instantly share code, notes, and snippets.

@holys
holys / lamp.sh
Created August 19, 2013 11:19
learn shell script
#!/bin/bash -
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#===============================================================================
# SYSTEM REQUIRED: CentOS-5 (32bit/64bit)¡¢CentOS-6 (32bit/64bit)
# DESCRIPTION: Install LAMP in CentOS
# AUTHOR: Zhu Maohai.
# REVISION: 0.4
# website: http://www.centos.bz/lamp/
#===============================================================================
@holys
holys / log
Created September 3, 2013 03:59
==> Downloading http://gource.googlecode.com/files/gource-0.40.tar.gz
Already downloaded: /Library/Caches/Homebrew/gource-0.40.tar.gz
tar xf /Library/Caches/Homebrew/gource-0.40.tar.gz
==> ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/gource/0.40 --disable-sdltest --without-x --disable-freetypetest
./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/gource/0.40 --disable-sdltest --without-x --disable-freetypetest
configure: WARNING: unrecognized options: --disable-sdltest, --disable-freetypetest
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
#!/usr/bin/env python2
# vim: set fileencoding=utf8
import re, sys, os, random, datetime, time, json, urllib2, logging
from mutagen.id3 import ID3,TRCK,TIT2,TALB,TPE1,APIC
from HTMLParser import HTMLParser
parser = HTMLParser()
s = u'\x1b[1;%dm%s\x1b[0m' # terminual color template
# coding: utf-8
class MyIterator(object):
def __init__(self, step):
self.step = step
def next(self):
if self.step == 0:
raise StopIteration
input {
file {
type => "nginx"
path => "/var/log/nginx/localhost.access.log"
format => 'plain'
}
}
# We need to tell the filters (grok, date) that we want to act on the nginx
# type otherwise it won't do anything
filter {
# strip the syslog PRI part and create facility and severity fields.
# the original syslog message is saved in field %{syslog_raw_message}.
# the extracted PRI is available in the %{syslog_pri} field.
#
# You get %{syslog_facility_code} and %{syslog_severity_code} fields.
# You also get %{syslog_facility} and %{syslog_severity} fields if the
# use_labels option is set True (the default) on syslog_pri filter.
grok {
type => "syslog-relay"
@holys
holys / access.log
Last active January 4, 2016 02:09
python regular pattern for nginx access.log
14.145.146.20 - - [02/Dec/2013:00:01:01 +0800] "GET /api/groups HTTP/1.1" 200 28 "https://qing.wps.cn/" "qing-8.1.17.1 AppleWebKit(2.2.3)" "14.145.146.20" 0.002 -
----
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" $request_time $upstream_response_time';
#coding: utf-8
"""Pylogstat
Usage:
pylogstat.py parse FILE [--db DB] [--host HOST] [--port PORT] [--maxline MAXLINE]
pylogstat.py aggregate (--db DB) [--host HOST] [--port PORT] [--start
START] [--end END] [--delta DELTA]
pylogstat.py index (-c | -d) (--db DB) [--host HOST] [--port PORT]
Options:
#!/usr/bin/env bash
# Install BuildRequires from .spec file
function install_buildrequires()
{
requires=$(grep "BuildRequires" $1 | awk '{print $2}')
for require in $requires
do
echo "Installing $require"
yum install -y $require