dstat

介绍

安装

#ubuntu
apt-get install dstat

#centos
yum install dstat

 

使用

其他stat工具(sysstat mpstat cifsiostat sar vmstat iostat netstat nfsstat ifstat)

 

nmon

介绍

nmon 工具可以帮助在一个屏幕上显示所有重要的性能优化信息,并动态地对其进行更新。这个高效的工具可以工作于任何哑屏幕、telnet 会话、甚至拨号线路。另外,它并不会消耗大量的 CPU 周期,通常低于百分之二。在更新的计算机上,其 CPU 使用率将低于百分之一。

 

安装

#Centos6_x86 (包含了多个系统的二进制包,选择匹配自己系统的)

wget http://sourceforge.net/projects/nmon/files/nmon_linux_14i.tar.gz

 mkdir nmon

tar -zxvf nmon_linux_14i.tar.gz -C nmon

cd nmon
./nmon_x86_centos6

 

 

使用

 

tsar

介绍

Tsar是淘宝的采集工具,主要用来收集服务器的系统信息(如cpu,io,mem,tcp等)以及应用数据(如squid haproxy nginx等),tsar支持实时查看和历史查看,方便了解应用和服务器的信息!

https://github.com/alibaba/tsar

安装

wget -O tsar.zip https://github.com/alibaba/tsar/archive/master.zip --no-check-certificate
unzip tsar.zip
cd tsar-master
make
make install

 

 

在盒子中

很多时候,我们都知道自己容易在一个盒子中,老是用盒子的眼光看待问题。无论是在哪方面,爱、生活、工作。

我们知道坏盒子,需要除掉,不要让这个盒子囚禁你。

我们希望,我们探求,我们还没行动。

甚至我们知道了突破的方法,正要准备改变、行动了。

在盒子中,我们知道,这必须要突破。

在盒子外了

我们做出了改变,我们行动了。

我们终于除去了这个坏盒子。

在盒子外了,这样的结果,当然很好,我们成功了,这值得赞赏。

最后还是在盒子中

可是某一天,我们发现,天呀这个坏盒子怎么还是在,在影子当中。

我说真的这可能真有些沮丧,会让你仿佛觉得怎么还是没改变,甚至觉得自己做什么都是无用功。

这好像很不值得。

我们知道,我们真的知道这样的情况。这很糟糕,非常击溃人的毅力。

最牛逼的,最难能可贵的,就是你还会再一次去突破这个坏盒子。我们千万不能放弃,放弃你就真的败了。

要找回自信,要找回勇气。

最后还是在盒子中,是的,也许会是这样的结果。

最后我们还是在盒子中,有些时候也许会是个常态。

感觉这样真的挺怕的!其实这个并不可怕。

可怕的是,破罐子破摔。

真的不要这样,你自己,和你息息相关的人都是不负责的行为。

真正的勇气、牛逼,是带着最糟糕的失败、沮丧,再一次、再一次的继续突破前行。

AutoMySQLBackup是轻量级的mysql备份工具,数据量不大,MyISAM用用很好。
 mkdir AutoMySQLBackup
cd AutoMySQLBackup/
wget -c "http://nchc.dl.sourceforge.net/project/automysqlbackup/AutoMySQLBackup/AutoMySQLBackup%20VER%203.0/automysqlbackup-v3.0_rc6.tar.gz"
tar zxvf automysqlbackup-v3.0_rc6.tar.gz
chmod +x install.sh
sh install.sh
#全部默认配置
cd /etc/automysqlbackup/
vi automysqlbackup.conf #修改里面的配置
crontab -e
#设定每日凌晨3:00执行
0 3 * * * /usr/local/bin/automysqlbackup
btw:这货实际上是使用的mysqldump,如果你是innodb,那么推荐用Xtrabackup,当然还非常推荐,无痛使用Percona mysql。

haproxy_install.sh
#!/bin/bash 
#install haproxy  
#20111207 by dongnan 

#variables 
dir=/usr/local 
ha_dir=${dir}/haproxy 
ha_cfg=${ha_dir}/haproxy.cfg 
kernel=`uname -r | grep '2.6'` 
pcre=$(rpm -qa | grep 'pcre' | wc -l) 
echo "$dir, $ha_dir, $ha_cfg, $kernel, $pcre" 

#check 
if [ ! "$kernel" -o "$pcre" -lt "2" ];then 
    echo -e "the script need linux 2.6 kernel and pcre pcre-devel \nyou can usage 'yum install pcre pcre-devel' or 'rpm -ivh pcre-devel-6.6-2.el5_1.7.x86_64.rpm'" 
    exit 1 
fi 

#function 

install_ha_cfg (){ 
#configure haproxy.cfg 
#default configure file for test,but need your change the frontend server and backend server ip address, 
#good luck! 

echo ' 
global 
    log 127.0.0.1   local0 
    maxconn 4096              #最大连接数 
    chroot /usr/local/haproxy #安装目录 
    uid 99                    #用户haproxy 
    gid 99                    #组haproxy 
    daemon                    #守护进程运行 
    nbproc 1                  #进程数量 
    pidfile /usr/local/haproxy/logs/haproxy.pid #haproxy pid 

defaults 
   log     global 
   mode    http               #7层 http;4层tcp  
   option  httplog            #http 日志格式 
   option  httpclose          #主动关闭http通道 
   option  redispatch         #serverId对应的服务器挂掉后,强制定向到其他健康的服务器 

   option  dontlognull 
   maxconn 2000               #最大连接数 
   contimeout      5000       #连接超时(毫秒) 
   clitimeout      50000      #客户端超时(毫秒) 
   srvtimeout      50000      #服务器超时(毫秒) 

frontend haproxy_test         #定义前端服务器(haproxy) 
        bind 10.0.1.251:80    #监听地址 
        default_backend server_pool  #指定后端服务器群 
        #errorfile 502 /usr/local/haproxy/html/maintain.html 
        #errorfile 503 /usr/local/haproxy/html/maintain.html 
        #errorfile 504 /usr/local/haproxy/html/maintain.html 

backend server_pool           #定义后端服务器群(web server/apache/nginx/iis..) 
        mode http 
        option  forwardfor    #后端服务器(apache/nginx/iis/*),从Http Header中获得客户端IP 
        #balance roundrobin    #负载均衡的方式,轮询方式 
        balance leastconn     #负载均衡的方式,最小连接 
        cookie SERVERID       #插入serverid到cookie中,serverid后面可以定义 
        option  httpchk HEAD /check.html #用来做健康检查html文档 
        server server1 10.0.1.252:80 cookie server1 check inter 2000 rise 3 fall 3 weight 3 
        server server2 10.0.1.253:80 cookie server2 check inter 2000 rise 3 fall 3 maxconn 120 weight 3 
        server server3 10.0.1.254:80 cookie server3 check maxconn 90 rise 2 fall 3 weight 3 
#服务器定义: 
#cookie server1表示serverid为server1; 
#check inter 2000 是检测心跳频率(check 默认 ); 
#rise 3 表示 3次正确认为服务器可用; 
#fall 3 表示 3次失败认为服务器不可用; 
#weight 表示权重。 

listen admin_stat                   #status 
    bind *:8080                     #监听端口 
    mode http                       #http的7层模式 
    stats refresh 30s               #统计页面自动刷新时间 
    stats uri /haproxy-stats        #统计页面URL 
    stats realm Haproxy\ Statistics #统计页面密码框上提示文本 
    stats auth admin:admin          #统计页面用户名和密码设置 
    stats hide-version              #隐藏统计页面上HAProxy的版本信息 
    stats admin if TRUE             #手工启用/禁用,后端服务器 
' > "$ha_cfg" && sed -i '1 d' "$ha_cfg" 
} 

#install 
if [ ! -e "$ha_dir" ];then 
   tar zxf haproxy*.tar.gz 
   cd haproxy*/ 
   make TARGET=linux26 USE_STATIC_PCRE=1 PREFIX=/usr/local/haproxy && make install PREFIX=/usr/local/haproxy && mkdir /usr/local/haproxy/{html,logs} 
   cd ../ 
# 
   if [ ! -e "$ha_dir" ];then 
       echo "error! can't install haproxy  please check ! Will now out of the script !" 
       exit 1 
   else 
       ! grep 'haproxy' /etc/syslog.conf && echo 'local1.*            /var/log/haproxy.log' >> /etc/syslog.conf 
       sed -ir 's/SYSLOGD_OPTIONS="-m 0"/SYSLOGD_OPTIONS="-r -m 0"/g' /etc/sysconfig/syslog && /etc/init.d/syslog restart 
       install_ha_cfg 
       rm -rf haproxy*/ 
   fi 
else 
   echo "haproxy is already exists!" 
fi 

haproxy.sh

# cat /usr/local/sbin/haproxy.sh  
#!/bin/bash 
#haproxy command  
#ver:0.1bate 
#20111129 by dongnan 

#/usr/local/haproxy/sbin/haproxy  
#HA-Proxy version 1.4.18 2011/09/16 
#Copyright 2000-2011 Willy Tarreau <w@1wt.eu> 
# 
#Usage : haproxy [-f <cfgfile>]* [ -vdVD ] [ -n <maxconn> ] [ -N <maxpconn> ] 
#        [ -p <pidfile> ] [ -m <max megs> ] 
#        -v displays version ; -vv shows known build options. 
#        -d enters debug mode ; -db only disables background mode. 
#        -V enters verbose mode (disables quiet mode) 
#        -D goes daemon 
#        -q quiet mode : don't display messages 
#        -c check mode : only check config files and exit 
#        -n sets the maximum total # of connections (2000) 
#        -m limits the usable amount of memory (in MB) 
#        -N sets the default, per-proxy maximum # of connections (2000) 
#        -p writes pids of all children to this file 
#        -de disables epoll() usage even when available 
#        -ds disables speculative epoll() usage even when available 
#        -dp disables poll() usage even when available 
#        -sf/-st [pid ]* finishes/terminates old pids. Must be last arguments. 

#variables 
haproxy_dir=/usr/local/haproxy/ 
haproxy_conf=${haproxy_dir}haproxy.cfg 
haproxy_pid=${haproxy_dir}logs/haproxy.pid 
haproxy_cmd=${haproxy_dir}sbin/haproxy 
#test variables 
#file $haproxy_dir; file $haproxy_conf; file $haproxy_cmd; file $haproxy_pid 

if [ "$#" -eq "0" ];then 
    echo "usage: $0 {start|stop|restart}" 
    exit 1 
fi 

if [ "$1" = "start" ];then 
#echo $1 
    $haproxy_cmd -f $haproxy_conf 
elif [ "$1" = "stop" ];then 
#echo $1 
    kill `cat $haproxy_pid` 
elif [ "$1" = "restart" ];then 
#echo $1 
    $haproxy_cmd -f $haproxy_conf -st `cat $haproxy_pid` 

else 
   echo "usage: $0 arguments only start and stop or restart !" 
fi

关键字: css代码网页变灰 css代码网页变黑白 nginx网页变灰代码变黑白代码 css滤镜实现页面灰色黑白色效果

1 css代码,支持ie firefox chrome等webkit核心 Opera

html{
filter: grayscale(100%);
-webkit-filter: grayscale(100%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */
-webkit-filter: grayscale(1);
filter: gray; /* For IE 6 - 9 */
filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); 
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
-moz-filter: grayscale(100%); /*待定*/
-ms-filter: grayscale(100%); /*待定*/
-o-filter: grayscale(100%); /*欧朋有什么解决办法?*/
}

2 利用ningx http_sub_module模块把html代码注入http中,不改动web文件实现

来源:https://gist.github.com/hydra35/5426536

# 1. Make sure you have nginx sub module compiled in
# nginx -V  2>&1 | grep --color=always '\-\-with\-http_sub_module'

# 2. add two directives below at HTTP level

# nginx.conf
http {
        # ......

        sub_filter  '</head>' '<style type="text/css">html{ filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); -webkit-filter: grayscale(100%); filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
} img { _filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=0); -webkit-filter: grayscale(100%); filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
} </style>';
        sub_filter_once on;

        # ......
}

# 3. nginx -t && /etc/init.d/nginx reload