Skip to content

Instantly share code, notes, and snippets.

View luohao-brian's full-sized avatar

Hao Luo luohao-brian

  • Huawei
  • Beijing, CHN
View GitHub Profile
@luohao-brian
luohao-brian / nginx_access_log_to_mysql.py
Created November 3, 2018 02:49
nginx_access_log_to_mysql.py
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
import time
import sys
import os
import MySQLdb
@luohao-brian
luohao-brian / ns-ovs.sh
Created October 8, 2018 07:46
Linux Networking Scripts
# 创建2个ns, 分别用veth连接在ns1和ns2, 接在ovs网桥br1上
# ns1 & ns2
ip netns add ns1
ip netns add ns2
# tap1 & tap2
ip link add tap1 type veth peer name ovs-tap1
ip link add tap2 type veth peer name ovs-tap2
@luohao-brian
luohao-brian / apt-dpkg
Created September 24, 2018 16:58
debian/ubuntu apt & dpkg examples
apt-cache search # ------(package 搜索包)
apt-cache show #------(package 获取包的相关信息,如说明、大小、版本等)
apt-get install # ------(package 安装包)
apt-get install # -----(package --reinstall 重新安装包)
apt-get -f install # -----(强制安装, "-f = --fix-missing"当是修复安装吧...)
apt-get remove #-----(package 删除包)
apt-get remove --purge # ------(package 删除包,包括删除配置文件等)
apt-get autoremove --purge # ----(package 删除包及其依赖的软件包+配置文件等(只对6.10有效,强烈推荐))
apt-get update #------更新源
apt-get upgrade #------更新已安装的包
@luohao-brian
luohao-brian / thin-lvm.sh
Created September 24, 2018 16:55
LVM examples
# create a pv
pvcreate /dev/sdb
# create a data vg
vgcreate data /dev/sdb
# create a thin pool
lvcreate -L 200G --type thin-pool data/thinpool
# extend thin pool to 300G
@luohao-brian
luohao-brian / libvirt-vm.xml
Last active September 30, 2018 08:43
libvirt virtual machine example
<domain type='kvm' id='1'>
<name>ubuntu-1804-hluo</name>
<memory unit='KiB'>4194304</memory>
<currentMemory unit='KiB'>4194304</currentMemory>
<vcpu>2</vcpu>
<cpu mode='host-passthrough'/>
<os>
<type arch='x86_64'>hvm</type>
<boot dev='hd'/>
</os>
@luohao-brian
luohao-brian / qemu-kvm-ovs-tuntap.sh
Last active September 28, 2018 09:27
qemu-kvm usages
#!/bin/bash
# 创建虚拟交换机:
ovs-vsctl add-br br-int
# 创建TAP设备:
ip tuntap add tap0 mode tap
ip tuntap add tap1 mode tap
# 将设备连接到虚拟交换机:
@luohao-brian
luohao-brian / pypam_example.py
Last active December 13, 2015 19:48
PyPAM authendicate example
# (c) 2007 Chris AtLee <chris@atlee.ca>
# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license.php
"""
PAM module for python
Provides an authenticate function that will allow the caller to authenticate
a user against the Pluggable Authentication Modules (PAM) on the system.
Implemented using ctypes, so no compilation is necessary.