zoukankan      html  css  js  c++  java
  • Linux负载查询定位工具

    1 uptime命令,负载查询命令

    02:34:03 // 当前时间
    up 2 days, 20:14 // 系统运行时间
    1 user // 正在登录用户数

    而最后三个数字呢,依次则是过去 1 分钟、5 分钟、15 分...

    2 模拟工具stress

    模拟cpu负载

     stress --cpu 1 --timeout 600

    模拟io负载

    stress -i 1 --timeout 600

    模拟多核负载

     stress -c 8 --timeout 600

    3 查询负载 

     watch -d uptime //监控变化的部分

    4 查询io和cpu性能指标

     mpstat -P ALL 5 

    # -P ALL 表示监控所有 CPU,后面数字 5 表示间隔 5 秒后输出一组数据
    $ mpstat -P ALL 5
    Linux 4.15.0 (ubuntu) 09/22/18 _x86_64_ (2 CPU)
    13:30:06 CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
    13:30:11 all 50.05 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 49.95
    13:30:11 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
    13:30:11 1 100.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

    5 定位io和cpu指标最高的进程id

    # 间隔 5 秒后输出一组数据
    $ pidstat -u 5 1
    13:37:07 UID PID %usr %system %guest %wait %CPU CPU Command
    13:37:12 0 2962 100.00 0.00 0.00 0.00 100.00 1 stress

    # 间隔 5 秒后输出一组数据,-u 表示 CPU 指标
    $ pidstat -u 5 1
    Linux 4.15.0 (ubuntu) 09/22/18 _x86_64_ (2 CPU)
    13:42:08 UID PID %usr %system %guest %wait %CPU CPU Command
    13:42:13 0 104 0.00 3.39 0.00 0.00 3.39 1 kworker/1:1H
    13:42:13 0 109 0.00 0.40 0.00 0.00 0.40 0 kworker/0:1H
    13:42:13 0 2997 2.00 35.53 0.00 3.99 37.52 1 stress
    13:42:13 0 3057 0.00 0.40 0.00 0.00 0.40 0 pidstat

    可以发现stress的指标最高,生产中可以用pidstat来抓出指标异常的进程

    centos7安装yum istall sysstat 这个就是pidstat

  • 相关阅读:
    Centos操作系统配置VIP以及网络
    heartbeat+nginx搭建高可用HA集群
    sudo -s/sodo -i/su root
    mysql数据库使用sql查询数据库大小及表大小
    Caffe机器学习框架
    TensorFlow实战:Chapter-4(CNN-2-经典卷积神经网络(AlexNet、VGGNet))
    深度工作:充分使用每一份脑力
    Laravel 的中大型专案架构
    python数据分析之numpy
    lumen-Permission 权限管理使用心得
  • 原文地址:https://www.cnblogs.com/QuestionsZhang/p/10601110.html
Copyright © 2011-2022 走看看