mongdb数据库

mongodb使用总结

标签


shell 脚本及linux常用命令

2015年03月06日

我思故我在 – 笛卡尔

文本重复行统计输出

awk 'NR==FNR{a[$1]++}NR>FNR&&a[$1]>1' test test

统计各种TCP连接类型的数量

netstat -atn | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'

awk命令基于行的统计

cat access.log | awk -F["/"] {'print $5,$0'} | awk '{if($11 ~ /^[0-9]+$/) S[$1]=S[$1]+$11;S["TOTAL"]=S["TOTAL"]+$11} END {for(a in S) print a, S[a]}' | sort -k 2,2 -nr 1>result

route 命令

查看当前路由配置

route -n

添加路由

route add -net 192.168.200.0 netmask 255.255.255.0 dev eth0 gw 192.168.200.254

删除路由

route del -net 169.254.0.0 netmask 255.255.0.0 dev eth0 gw 169.254.0.1

线程绑核

taskset -cp 8,9 11441

将PID为11441的线程绑定到8,9核心上。

统计系统所有进程swap的使用信息

#!/bin/bash
# Get current swap usage for all running processes
# writted by xly

function getswap {
    SUM=0
    OVERALL=0
    for DIR in `find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]"` ;
    do
        PID=`echo $DIR | cut -d / -f 3`
        PROGNAME=`ps -p $PID -o comm --no-headers`
        for SWAP in `grep Swap $DIR/smaps 2>/dev/null| awk '{ print $2 }'`
        do
            let SUM=$SUM+$SWAP
        done
        echo "PID=$PID - Swap used: $SUM - ($PROGNAME )"
        let OVERALL=$OVERALL+$SUM
        SUM=0
	
    done
    echo "Overall swap used: $OVERALL"
}

getswap
#getswap|egrep -v "Swap used: 0"

win7 创建并启动一个wifi热点

netsh wlan set hostednetwork mode=allow ssid=livdran2012 key=100100100	
	
netsh wlan start hostednetwork

enjoy the life !!!