zoukankan      html  css  js  c++  java
  • 【原创】Linux常用脚本

    #1、启用停用VIP

    sudo /etc/ha.d/resource.d/IPaddr 10.10.10.10 start
    sudo /etc/ha.d/resource.d/IPaddr 10.10.10.10 stop

     #2、查看MySQL QPS

    mysqladmin --login-path=local -r -i 1 -c 10000 ext |
    awk -F"|" 
    "BEGIN{ count=0; }"
    '{ if($2 ~ /Variable_name/ && ((++count)%20 == 1)){
        print "----------|---------|--- MySQL Command Status --|----- Innodb row operation ----|-- Buffer Pool Read --|-- slowqueries --";
        print "---Time---|---QPS---|select insert update delete|  read inserted updated deleted|   logical    physical|   slowqueries";
    }
    else if ($2 ~ /Queries/){queries=$3;}
    else if ($2 ~ /Com_select /){com_select=$3;}
    else if ($2 ~ /Com_insert /){com_insert=$3;}
    else if ($2 ~ /Com_update /){com_update=$3;}
    else if ($2 ~ /Com_delete /){com_delete=$3;}
    else if ($2 ~ /Innodb_rows_read/){innodb_rows_read=$3;}
    else if ($2 ~ /Innodb_rows_deleted/){innodb_rows_deleted=$3;}
    else if ($2 ~ /Innodb_rows_inserted/){innodb_rows_inserted=$3;}
    else if ($2 ~ /Innodb_rows_updated/){innodb_rows_updated=$3;}
    else if ($2 ~ /Innodb_buffer_pool_read_requests/){innodb_lor=$3;}
    else if ($2 ~ /Innodb_buffer_pool_reads/){innodb_phr=$3;}
    else if($2~/Slow_queries/){slow_queries=$3;}
    else if ($2 ~ /Uptime / && count >= 2){
      printf(" %s |%9d",strftime("%H:%M:%S"),queries);
      printf("|%6d %6d %6d %6d",com_select,com_insert,com_update,com_delete);
      printf("|%6d %8d %7d %7d",innodb_rows_read,innodb_rows_inserted,innodb_rows_updated,innodb_rows_deleted);
      printf("|%10d %11d",innodb_lor,innodb_phr);
      printf("|%11d
    ",slow_queries);
    }}'

    #3、进程号占用的swap

    awk '/^Swap:/ {SWAP+=$2}END{print SWAP" KB"}' /proc/$(pid)/smaps
    

    #4、查看swap使用的进程和内存

    for i in $( cd /proc;ls |grep "^[0-9]"|awk ' $0 >100') ;do awk '/Swap:/{a=a+$2}END{print '"$i"',a/1024"M"}' /proc/$i/smaps 2>/dev/null ; done | sort -k2nr | head -10
    

     


     

  • 相关阅读:
    Java 第十一届 蓝桥杯 省模拟赛 洁净数
    Java 第十一届 蓝桥杯 省模拟赛 第十层的二叉树
    Java 第十一届 蓝桥杯 省模拟赛 第十层的二叉树
    Java 第十一届 蓝桥杯 省模拟赛 第十层的二叉树
    Java 第十一届 蓝桥杯 省模拟赛 70044与113148的最大公约数
    Java 第十一届 蓝桥杯 省模拟赛 70044与113148的最大公约数
    20. Valid Parentheses
    290. Word Pattern
    205. Isomorphic Strings
    71. Simplify Path
  • 原文地址:https://www.cnblogs.com/wangdong/p/9235450.html
Copyright © 2011-2022 走看看