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 / 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)
#! /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 / jenkins.sh
Created June 30, 2015 02:57
init scripts
#!/bin/bash
# /etc/init.d/jenkins
# debian-compatible jenkins startup script.
# Amelia A Lewis <alewis@ibco.com>
#
### BEGIN INIT INFO
# Provides: jenkins
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
@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 / 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 / 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
"$@"
#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 / autoban.sh
Last active February 5, 2016 03:37
A simple script to protect system from DOS attack
#!/bin/bash
# A simple script to protect system from DOS attack
# create a crontab conf file /etc/cron.d/autoban like this:
# * * * * * root /sbin/autoban.sh ban >/dev/null 2>&1 &
# */10 * * * * root /sbin/autoban.sh unban - 5 >/dev/null 2>&1 &
# 01 * * * * root /sbin/autoban.sh unban 6 20 >/dev/null 2>&1 &
# 01 09 * * * root /sbin/autoban.sh unban 21 - >/dev/null 2>&1 &
#
PATH=/bin:/usr/bin:/usr/sbin:/sbin
export PATH
@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//'
@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