16 Linux server monitoring commands you should know

  

In different Linux distributions, there are different GUI programs that can display various system information. For example, in the SUSE Linux distribution, there is a very good graphical The configuration and management tool YaST, the KDE System Guard in the KDE desktop environment is also very good.

However, for a Linux system administrator, such a GUI program will not run on a Linux server unless it is forced, mainly because the GUI consumes a lot of system resources. So, using GUI tools is generally a simple troubleshooting, if you really want to know what really happens in the system, then please turn off your GUI, hurry into the world of Linux command line.

If you want to pursue the best performance, then the Linux server should run at runlevel 3, which supports network and multi-user functions, but does not support GUI functions. If you really need a GUI, you can type startx into the GUI at the command line.

If your Linux system is entering the GUI by default, you can adjust the configuration and let him enter runlevel 3 by default. The specific method is:

  • 1 Open a terminal, su 2 with your favorite editor (vi /emacs /...) to the root account
  • Open the /etc /inittab file
  • 3 initdefault keyword to find the & ldquo; id: 5: initdefault: & rdquo; modified to & ldquo; id: 3: initdefault: & rdquo;

    If the system is simply not The /etc/inittab file does not matter, create this file directly and add a new line "ld:3". In this case, if you restart the server, you will enter the command line state by default. Of course, if you only want to enter the command line state temporarily, then simply enter "ld";init 3” in the terminal.

    At this point, our command line is ready, and you can start to see through powerful commands "What's going on in the server"::

     
    1. [ ,null,null,3],01 - iostat ]
    2. [02/03 - meminfo/free ]
    3. [04 - mpstat ]
    4. [05 - netstat ]
    5. [06 - Nmon ]
    6. [07 - pmap ]
    7. [08/09 - ps/pstree ]
    8. [10 - sar ]
    9. [11 - strace ]
    10. [12 - tcpdump ]
    11. [13 - top ]
    12. [14 - uptime ]
    13. [15 - vmstat ]
    14. [16 - wireshark]

      [01 - iostat]

      iostat command displays the details of the state of your storage system. You can usually use this command to check if your storage device is working properly.

      It is completely possible to find system IO problems through this command before the user complains that the server is slow.

      As you can see, iostat can display both CPU usage and IO status of each disk.

       
      1. # iostat 1
      2. Linux 2.6.32-220.4.1.el6.i686 (roclinux) December 22, 2012 _i686_ (4 CPU)

      3. avg-cpu: %user %nice %system %iowait %steal %idle
      4. 0.55 0.00 0.03 0.02 0.00 99.40

      5. Device: tps Blk_read /s Blk_wrtn /s Blk_read Blk_wrtn
      6. sdb 0.41 2.61 5.76 2558664 5653872
      7. sda 0.24 0.80 4.12 784650 4038344

        [02/03 - meminfo /free]

        meminfo provides very detailed memory usage. Can directly view with the cat command:

         
        1. cat /proc /meminfo

          Of course meminfo contains too many details, you can directly use the free command to view A review of memory.

           
          1. # free -m
          2. total used free shared buffers cached
          3. Mem: 1513 1429 83 0 343 836
          4. -/+ buffers /cache: 249 1263
          5. Swap: 0 0 0

            [04 - mpstat]

            mpstat used on multiprocessor servers, for Displays the status of each CPU.

            In addition, mpstat will also display the average status of all processors.

            You can set the CPU statistics for each server, or the CPU statistics for each process.

             
            1. # mpstat -P ALL

            2. Linux 2.6.32-220.4.1.el6.i686 (roclinux) 2012 December May 22 _i686_ (4 CPU)



            3. 17 35 when 46 is of 5 seconds CPU% usr% nice% sys% iowait% irq % soft% steal% guest% idle

            4. 17 46 is of 5 35 seconds when all 0.55 0.00 0.03 0.02 0.00 0.00 0.00 0.00 99.40

            5. 17 when 46 minutes 35 seconds 0 0.84 0.00 0.04 0.03 0.00 0.01 0.00 0.00 99.08

            6. 17 minutes 35 seconds when 46 1 0.51 0.00 0.03 0.02 0.00 0.00 0.00 0.00 99.44

            7. when

              17 46 minutes 35 seconds 2 0.45 0.00 0.02 0.01 0.00 0.00 0.00 0.00 99.51

            8. 17 minutes 35 seconds when 46 is 3 0.40 0.00 0.02 0.01 0.00 0.00 0.00 0.00 99.56



            9. # mpstat -P 0

            10. Linux 2.6.32-220.4.1.el6. i686 (roclinux) 22 December 2012 _i686_ (4 CPU)



            11. 17 39 when 46 is of 5 seconds CPU% usr% Nice %sys %iowait %irq %soft %steal % guest% idle

            12. 17 46 minutes 39 seconds when Meaning 0 0.84 0.00 0.04 0.03 0.00 0.01 0.00 0.00 99.08


              wherein each domain Description as follows:

            13. 1 CPU: processor number, If all, then this line represents the statistical mean of all processors
            14. 2% usr: CPU user mode using Rate
            15. 3 %nice: User State CPU Utilization with Scheduling Priority
            16. 4 %sys: Kernel State CPU Utilization (This value does not include the time to respond to hardware interrupts and software interrupts)
            17. 5 %iowait: Percentage of time that the IO request is causing the CPU to be in the IDLE state
            18. 6 %irq: Time ratio of the CPU responding to hardware interrupts
            19. 7 %soft:CPU response Time ratio of software interrupts
            20. 8 %steal: Passive latency ratio of virtual CPUs when the virtual machine monitor is serving other virtual processors
            21. 9 %guest: Run a virtual process CPU time consumed by the ratio

              [05 - netstat]

              netstat command, a Linux system administrator almost used every day life (It has been gradually replaced by ss in command), he can display a lot of information about the network aspects, such as socket usage, routing cases, card cases, the protocol, the network traffic statistics and so on.

              Some common netstat options include:

            22. -a: shows all socke information
            23. -r: Displays routing information
            24. -i: NIC excuse statistics show
            25. -s: displays the network protocol statistics

              [06 - nmon]

              nmon is Nigel & rsquo; s Monitor the abbreviation, it is a very A well-known tool for monitoring the performance of Linux systems.

              nmon can view processor utilization, memory usage, run queue information, disk IO statistics, network IO statistics, page break statistics, and more.

              You can view this information through a curses-based GUI interface.


  • Copyright © Windows knowledge All Rights Reserved