zoukankan      html  css  js  c++  java
  • linux 命令笔记

    查看当前进程打开的进程数:

    lsof -n -p 【process id】|wc -l

     

    查看当前进程的限制

    cat /proc/【process id】/limits
    Limit                     Soft Limit           Hard Limit           Units     
    Max cpu time              unlimited            unlimited            ms        
    Max file size             unlimited            unlimited            bytes     
    Max data size             unlimited            unlimited            bytes     
    Max stack size            8388608              unlimited            bytes     
    Max core file size        0                    unlimited            bytes     
    Max resident set          unlimited            unlimited            bytes     
    Max processes             2048                 2048                 processes 
    Max open files            1024                 1024                 files     
    Max locked memory         32768                32768                bytes     
    Max address space         unlimited            unlimited            bytes     
    Max file locks            unlimited            unlimited            locks     
    Max pending signals       2048                 2048                 signals   
    Max msgqueue size         819200               819200               bytes     
    Max nice priority         0                    0                    
    Max realtime priority     0                    0


    ------------------------------------------ 检查网络连接信息 ------------------------------------------
    检查网络连接信息:
    netstat -tano | awk '{print $6}' | sort | uniq -c
    ss -s
    netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'

    ------------------------------------------ 检查进程所关联的进程信息 ------------------------------------------
    检查进程所关联的进程信息:
    lsof -n -p PROCESS_ID | wc -l
    cat /proc/PROCESS_ID/limits

    kmemsize is one of the (many) memory parameters in a virtuozzo vps. Please post the output of this command:
    cat /proc/user_beancounters

    1、查看apache当前并发访问数:
      netstat -an | grep ESTABLISHED | wc -l

    2、查看有多少个进程数:
      ps aux | grep httpd | wc -l

    3、可以使用如下参数查看数据
    ps -ef | grep httpd | wc -l

    ------------------------------------------ mrtg ------------------------------------------
    /usr/local/mrtg/cfgmaker public@localhost > /etc/mrtg/mrtg.cfg
    indexmaker /etc/mrtg/mrtg.cfg --output=/app/web/_ipub_/diag/mrtg/index.htm --title="MRTG monitor"
    env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

    ------------------------------------------ 使用文件创建swap分区 ------------------------------------------
    二、使用文件创建swap分区
    bs blocksize ,每个块大小为1k.count=2048000。则总大小为2G的文件。
    dd if=/dev/zero of=/swapfile bs=1k count=2048000
    mkswap /swapfile
    swapon /swapfile
    修改/etc/fstab使其启动时自动mount:
    在/etc/fstab中增加如下语句:
    /swapfile swap swap defaults 0 0

    ------------------------------------------ 查询 Httpd 的主进程 id 号 ------------------------------------------
    方法一: ps -ef | grep httpd | grep apache | head -n 1 | awk '{print $3}'
    方法二: cat /var/run/httpd.pid
    lsof -n -p PROCESS_ID

    ------------------------------------------ 查询 Httpd 的消耗的内存多少 ------------------------------------------
    ps -C httpd -O rss | gawk '{ count ++; sum += $2 }; END {count --; print "Number of processes =",count; print "Memory usage per process =",sum/1024/count, "MB"; print "Total memory usage =", sum/1024, "MB" ;};'

  • 相关阅读:
    Java实现 LeetCode 416 分割等和子集
    Java实现 LeetCode 416 分割等和子集
    在Linux运行期间升级Linux系统(Uboot+kernel+Rootfs)
    【详解】嵌入式开发中固件的烧录方式
    嵌入式系统烧写uboot/bootloader/kernel的一般方法
    Linux下USB烧写uImage kernel
    Xmanager连接CentOS的远程桌面
    命令行利器Tmux
    u-boot中分区和内核MTD分区关系
    uboot环境变量与内核MTD分区关系
  • 原文地址:https://www.cnblogs.com/AloneSword/p/2921292.html
Copyright © 2011-2022 走看看