Skip to content

Instantly share code, notes, and snippets.

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

itxx00 itxx00

✈️
keep working
View GitHub Profile
#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 / gist:b09b8eb9a5528c0d7aff
Created April 16, 2015 07:40
nginx fcgiwrap git-http-backend setup on CentOS6
/etc/nginx/conf.d/git.conf
server {
listen 443;
server_name git.test.net;
root /data/web;
charset utf-8;
index index.html;
access_log /var/log/nginx/git_access.log;
@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
@itxx00
itxx00 / jenkins.sh
Created June 30, 2015 02:57
init scripts
#!/bin/bash
# /etc/init.d/jenkins
# debian-compatible jenkins startup script.
# Amelia A Lewis <[email protected]>
#
### BEGIN INIT INFO
# Provides: jenkins
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
#! /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
@itxx00
itxx00 / qcloud_api.sh
Last active June 22, 2016 06:54
qcloud_api.sh
# Before you can use the tool,
# you need to install following software.
# curl openssl gawk
if [ "$mode_qcloud_api" ];then
return
fi
export mode_qcloud_api=1
function urlencode(){
@itxx00
itxx00 / gist:de5178e2566e270c4567daff62094582
Created June 24, 2016 03:14
network interface interrupts customize
# https://www.qcloud.com/doc/product/215/2238
3. 配置优化
公网网关主机会默认配置iptables的nat规则,以及打开kernel的ip_forward,基本的公网网关功能已经完全具备。建议经过下述配置,以达到更好的性能。
1) 通过以下命令将net.ipv4.ip_forward配置写到/etc/sysctl.conf文件中
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
2) 通过以下命令将nf_conntrack配置参数调大