waterye

#

show full processlist

shell
mysql -192.168.0.136 -3306 --u root -p'abcd' -'show full processlist' | egrep -'Sleep|show full processlist'
jsp
String sql = " show full processlist ";
rs
= stmt.executeQuery(sql);
while (rs.next()) {
String id
= rs.getString("Id");
String user
= rs.getString("User");
String host
= rs.getString("Host");
String db
= rs.getString("db");
String command
= rs.getString("Command");
String info
= rs.getString("Info");
String state
= rs.getString("State");
if (command.equalsIgnoreCase("Sleep")) continue;
if (info.equalsIgnoreCase("show full processlist")) continue;
if (info.length()==0 && state.length()==0) continue;
int time = rs.getInt("Time");
// print
}

posted @ 2008-09-12 00:42 waterye 阅读(505) | 评论 (0)编辑 收藏

nbt

nbtstat.exe -a 192.168.0.171

nbtscan-1.0.35.exe -f 192.168.0.1/24

http://www.unixwiz.net/tools/nbtscan.html

posted @ 2008-09-02 20:04 waterye 阅读(248) | 评论 (0)编辑 收藏

设置Shell的颜色

在/root/.bashrc增加一行
export PS1="\[ \033[0;32;40m\u@\h:\w\$ \033[0m \]"
---------------------------------------------------------------------
首先使用一个例子来说明如何实现Shell彩色:
    PS1="\[ \033[0;32;40m\u@\h:\w\$ \033[0m \]"


   在上面命令中,“\033[0;32;40m”表示定义后面文本的颜色,“\033”表示启动一个转义序列,“[”定义开始颜色定义,“0”定义默认的字体颜色,其它部分稍后定义。
    “32”定义文本的前景色,这里32表示绿色;“40”定义文本的背景色,40表示黑色。
    在字符串的最后定义了“ \033[0m”,它是用来恢复了默认的文本颜色设置,这样就只会得到一个彩色提示符,而不会影响命令和其输出的颜色显示(即黑底白字)。

    我们一共有8种字体颜色可供选择,它们分别是30 (黑色)、31 (红色)、32 (绿色)、33 (黄色)、34 (蓝色)、35 ( 紫红色)、36 (青色)和37 (白色)。
    对于底色也有8种颜色可供选择,只需要将字体颜色的3修改为4即可,例如40、41、42、43、44、45、46、47。 

    文本属性

    我们前面提到,转义序列符后面的“0”表示定义文本的颜色设置。
    除了颜色设置以外,还可以设置文本的其它属性。
    转义序列符后可以跟以下数值:0、1、22、4、24、5、25、7、27,分别定义颜色、黑体、非黑体、下画线、非下画线、闪烁、非闪烁、翻转、非翻转。

出处: http://www.cppblog.com/Bugs/archive/2008/06/24/54442.html

posted @ 2008-08-27 19:45 waterye 阅读(880) | 评论 (0)编辑 收藏

apache access log

CustomLog "|/usr/local/apache2/bin/rotatelogs /usr/local/apache2/logs/access.log.%Y.%m.%d 86400 480" common   # one day per file

posted @ 2008-08-17 01:31 waterye 阅读(306) | 评论 (0)编辑 收藏

convert bmp to jpg

java.awt.image.BufferedImage bufi = javax.imageio.ImageIO.read(bais);
javax.imageio.ImageIO.write(bufi, 
"jpg", baos);

posted @ 2008-08-03 20:55 waterye 阅读(343) | 评论 (0)编辑 收藏

nagios check command

check_mysql!-H 192.168.0.88 -P 3308 -u check -p checkpwd
check_mysql!-H 192.168.0.99 -P 3308 -u check -p checkpwd -S ; check mysql slave server
check_mysql_query!-H 192.168.0.99 -P 3308 -u check -p checkpwd -q "select count(*) from table_name" -w 100 -c 200
check_http!-p 8080
check_http!-u http://192.168.0.188:8080/a.jsp
/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1
/usr/local/nagios/libexec/check_users -w 5 -c 10
/usr/local/nagios/libexec/check_procs -w 150 -c 200
/usr/local/nagios/libexec/check_procs -a 'instance_name=app.task' -c 1:1
/usr/local/nagios/libexec/check_mrtgtraf -F /home/mrtg/logs/192.168.0.188_1.log -a AVG -w 1000000,2000000 -c 5000000,5000000 -e 10

posted @ 2008-07-27 18:14 waterye 阅读(1016) | 评论 (0)编辑 收藏

sort map by value

    Map<String, Integer> m = new TreeMap<String, Integer>();
    m.put(key, value);
    
    
    Set
<Map.Entry<String, Integer>> treeSet = new TreeSet<Map.Entry<String, Integer>>(
        
new Comparator<Map.Entry<String, Integer>>() {
            
public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                Integer d1 
= o1.getValue();
                Integer d2 
= o2.getValue();
                
int r = d2.compareTo(d1);
                
if (r!=0return r;
                
else return o2.getKey().compareTo(o1.getKey());
            }
        });
    treeSet.addAll(m.entrySet());
    
for (Map.Entry me : treeSet) {
        System.out.println(me.getKey() 
+ "," + me.getValue());
    }

posted @ 2008-07-27 17:18 waterye 阅读(463) | 评论 (0)编辑 收藏

awk分析access log

awk '{ if (index($4,"ip")>0) { split($4,a,","); if (substr(a[2],11)>0) print substr(a[2],11) } }' access.log.txt.2008-07-26 > ip.20080726.log
awk '{a[$0]++}END{for(i in a){print a[i] " " i}}' ip.20080726.log | sort -rn | head -n 300
awk '{a[$0]++}END{for(i in a){ j++;} } END { print j }' ip.20080726.log

The GNU Awk User's Guide

posted @ 2008-07-27 01:18 waterye 阅读(495) | 评论 (0)编辑 收藏

vi

:%s/oldstr/newstr/g    替换所有
:$    跳到文件最后一行

yy命令复制当前整行的内容到vi缓冲区
粘贴缓冲区中的内容,用p

posted @ 2008-06-27 23:04 waterye 阅读(288) | 评论 (0)编辑 收藏

使用temporary memory table优化union

sharding听上去很过瘾,但实现成本也挺高的.对于通过按data进行split的表,某些select要用到union,这样可能导致lock的时间变得很长.使用temporary memory table作为中转,可以大大减少lock table的时间,使查询更快.
drop temporary table IF EXISTS table_name_tmp;
create temporary table IF NOT EXISTS table_name_tmp (a int not null,b int not null,primary key (a, b)) ENGINE = MEMORY;

insert ignore into table_name_tmp select * from table_name_1 where ;
insert ignore into table_name_tmp select * from table_name_2 where ;
insert ignore into table_name_tmp select * from table_name_3 where ;
insert ignore into table_name_tmp select * from table_name_4 where ;


select * from table_name_tmp where ;

posted @ 2008-06-22 22:27 waterye 阅读(658) | 评论 (0)编辑 收藏

仅列出标题
共18页: 上一页 1 2 3 4 5 6 7 8 9 下一页 Last