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 閱讀(531) | 評論 (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 閱讀(255) | 評論 (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 閱讀(899) | 評論 (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 閱讀(321) | 評論 (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 閱讀(354) | 評論 (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 閱讀(1027) | 評論 (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 閱讀(483) | 評論 (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 閱讀(516) | 評論 (0)編輯 收藏

          vi

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

          yy命令復制當前整行的內容到vi緩沖區
          粘貼緩沖區中的內容,用p

          posted @ 2008-06-27 23:04 waterye 閱讀(301) | 評論 (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 閱讀(677) | 評論 (0)編輯 收藏

          僅列出標題
          共18頁: 上一頁 1 2 3 4 5 6 7 8 9 下一頁 Last 
          主站蜘蛛池模板: 乃东县| 砚山县| 贵州省| 曲靖市| 彭泽县| 青铜峡市| 新建县| 湛江市| 莲花县| 连江县| 长岛县| 林周县| 剑阁县| 长垣县| 黄梅县| 加查县| 怀集县| 缙云县| 闸北区| 定远县| 河北区| 弥渡县| 南宁市| 博野县| 渑池县| 鄂托克前旗| 天台县| 象州县| 永康市| 新丰县| 正蓝旗| 凭祥市| 沙湾县| 万荣县| 上高县| 怀集县| 富宁县| 错那县| 枣强县| 娱乐| 佛教|