• 【原创】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
    

     


     

  • 相关阅读:
    POJ 2506 Tiling
    POJ 2586 Y2K Accounting Bug
    POJ 2965 The Pilots Brothers' refrigerator (DFS)
    POJ 2499 Binary Tree
    POJ 3006 Dirichlet's Theorem on Arithmetic Progressions (素数)
    beautifulsoup 基本语法 含class属性查找小技巧class_
    xlrd库的使用
    pytest框架 里 fixture 参数化的方法
    ddt数据驱动
    mac电脑 pip安装包后 撞到了系统python里面的解决方法
  • 原文地址:https://www.cnblogs.com/wangdong/p/9235450.html
Copyright © 2020-2023  润新知