Skip to content

Instantly share code, notes, and snippets.

View itxx00's full-sized avatar
✈️
keep working

itxx00 itxx00

✈️
keep working
View GitHub Profile
@itxx00
itxx00 / hosts_m.sh
Created January 9, 2015 03:57
manage /etc/hosts file
#!/bin/bash
# manage /etc/hosts
isIp() {
# test variable is an ip address or not
# true: return 0
# false: return 1
local ip=$1
local stat=1
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
OIFS=$IFS
@itxx00
itxx00 / idig.sh
Created January 15, 2015 05:14
a wrapper for dig command
#!/bin/sh
[ -z $1 ] || dig +nocmd +noall +answer +stats $@ | grep 'IN\|Query time' | sed 's/;; Query time://' | sed ';N;s/\n//'
#include <assert.h>
#include <errno.h>
#include <fstab.h>
#include <inttypes.h>
#include <malloc.h>
#include <mntent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/quota.h>
@itxx00
itxx00 / dnsrec.sh
Last active August 29, 2015 14:19
script to add/delete dns records using nsupdate, based on: https://blog.gnuers.org/?p=890
#!/bin/bash
usage(){
echo "usage: $0 <addrec> <view> <zone> <domain> <type> <value> <mxpr> <ttl>"
echo "usage: $0 <delrec> <view> <zone> <domain> [type] [value] [mxpr] [ttl]"
exit 1
}
DEBUG() {
if [[ $DEBUG = true ]]; then
"$@"
@itxx00
itxx00 / build-dir-pool.sh
Created May 29, 2015 08:31
how to build a storage pool with virsh
virsh pool-define-as default dir - - - - /var/lib/libvirt/images
virsh pool-build default
virsh pool-start default
virsh pool-autostart default
virsh pool-list
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import time, os, socket
import json
metric = ['usr', 'nice', 'sys', 'idle', 'iowait', 'irq', 'soft', 'steal', 'guest']
host = socket.gethostname()
def get_cpu_core_stat(num):
@itxx00
itxx00 / falcon-agent.spec
Created July 13, 2015 10:28
falcon-agent spec
Name: falcon-agent
Version: 0.4
Release: 1%{?dist}
Summary: falcon-agent
Group: system/daemon
License: GPL
URL: http://open-falcon.com/
Source0: http://open-falcon.com/download/%{name}-%{version}.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
#!/bin/bash
# send named metrics to falcon-agent
RNDC_BIN=/usr/sbin/rndc
STATS='/var/named/data/named_stats.txt'
rm -f $STATS
if ! $RNDC_BIN stats; then
exit 1
set nocompatible "关闭vi兼容
set enc=utf-8
"set number "显示行号
filetype plugin on "文件类型
set history=500 "历史命令
syntax on "语法高亮
"set autoindent "ai 自动缩进
"set smartindent "智能缩进
set showmatch "括号匹配
set ruler "右下角显示光标状态行
@itxx00
itxx00 / core-emu
Last active December 25, 2015 02:19
http://stackoverflow.com/questions/12671587/isolated-test-network-on-a-linux-server-running-a-web-server-lightttpd-and-cu
https://code.google.com/p/coreemu/
http://stuff.onse.fi/man?program=ip-netns&section=8
http://blog.kghost.info/2013/03/01/linux-network-emulator/
http://blog.kghost.info/2013/03/27/linux-network-tun/
http://seravo.fi/2012/virtualized-bridged-networking-with-macvtap
http://blog.csdn.net/kl222/article/details/8513593