DevOps
- 监控
"信息采集,日志处理,报警"
- Zabbix "http://www.zabbix.com/product.php"
- heka #go "https://github.com/mozilla-services/heka"
- 日志处理
- sentry #python 异常采集和聚合
- What do Etcd, Consul, and Zookeeper do? | |
- Service Registration: | |
- Host, port number, and sometimes authentication credentials, protocols, versions | |
numbers, and/or environment details. | |
- Service Discovery: | |
- Ability for client application to query the central registry to learn of service location. | |
- Consistent and durable general-purpose K/V store across distributed system. | |
- Some solutions support this better than others. | |
- Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state. | |
- Centralized locking can be based on this K/V store. |
#!/usr/bin/env python | |
# a simple multi-threaded TCP Black Hole server | |
import sys | |
from socket import * | |
import threading | |
import thread | |
import time | |
def handler(clientsock,addr): | |
try: |
set nocompatible | |
syntax enable | |
set encoding=utf-8 | |
set showcmd " display incomplete commands | |
filetype plugin indent on " load file type plugins + indentation | |
"" Whitespace | |
set nowrap " don't wrap lines | |
set tabstop=4 shiftwidth=4 " a tab is 4 spaces | |
set expandtab " use spaces, not tabs |
import os | |
import struct | |
import socket | |
state_table = ( | |
"EMPTY SLOT", | |
"ESTABLISHED", | |
"SENT", | |
"RECV", | |
"WAIT1", |
import inspect | |
import logging | |
import re | |
# from https://github.com/baniuyao/Python-CLog/blob/master/CLog.py | |
class LogRecordWithStack(logging.LogRecord): | |
def __init__(self, *args, **kargs): | |
super(LogRecordWithStack, self).__init__(*args, **kargs) | |
self.chain = self.get_meta_data() |
# http://snipperize.todayclose.com/snippet/py/64-%E5%92%8C-10%E8%BF%9B%E5%88%B6--93237/ | |
def encode_b64(n): | |
table = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_' | |
result = [] | |
temp = n | |
if 0 == temp: | |
¦ result.append('0') | |
else: |
DevOps
package main | |
import "fmt" | |
// fibonacci 函数会返回一个返回 int 的函数。 | |
func fibonacci() func() int { | |
sum1 := -1 | |
sum2 := 1 | |
return func() int { | |
sum := sum1 + sum2 |
set -eu | |
getent passwd | grep "^${1}:" | head -1 >> /etc/passwd | |
cp -r /etc/skel /home/$1 | |
chown -R $1 /home/$1 | |
usermod -d /home/$1 $1 |
#!/usr/bin/env python | |
"""A fake smtp server, use system sendmail to send the mail. (need Python > 2.4)""" | |
import smtpd | |
import asyncore | |
from subprocess import Popen, PIPE | |
class FakeSMTPServer(smtpd.SMTPServer): | |
"""A Fake smtp server""" |