How to Monitor Your Server Using Tools Like HTOP and IOTOP

Step 1: Install HTOP and IOTOP

  • To start monitoring your server’s performance, you need to install HTOP and IOTOP. Both tools provide real-time system monitoring for various resources on your server.
    • To install HTOP and IOTOP on a Debian/Ubuntu-based server, run the following command:
      sudo apt-get update
      sudo apt-get install htop iotop
      
    • For CentOS/RHEL-based servers, use:
      sudo yum install htop iotop
      

Step 2: Using HTOP to Monitor System Resources

  • HTOP is a powerful tool that allows you to view and manage system processes and monitor resource usage in real-time.
    • To start HTOP, simply run:
      htop
      
    • HTOP will show a list of processes and system resource usage. Here’s what you’ll see:
      • CPU Usage: Displayed at the top in a bar chart.
      • Memory Usage: Displayed next to the CPU usage.
      • Process List: A list of running processes, including their PID (Process ID), user, CPU usage, memory usage, and more.

Step 3: Navigating in HTOP

  • Use the following commands to interact with HTOP:
    • Arrow Keys: Navigate through the list of processes.
    • F3: Search for a specific process.
    • F9: Kill a process.
    • F10: Exit HTOP.
    • F6: Sort processes by different parameters (e.g., CPU, Memory).

Step 4: Monitor Disk I/O with IOTOP

  • IOTOP is a real-time I/O monitoring tool for Linux, which helps you track disk usage by processes.
    • To run IOTOP, execute the following command:
      sudo iotop
      
    • IOTOP will show disk read/write operations for each process running on the server.

Step 5: Navigating in IOTOP

  • Here are some key actions you can perform in IOTOP:
    • Arrow Keys: Navigate through the list of processes.
    • P: Show only processes that are actively performing disk I/O.
    • Q: Quit IOTOP.
    • R: Refresh the screen.
    • Shift + F: Apply filters to the data.

Step 6: Analyze Disk I/O with IOTOP

  • IOTOP displays information like:
    • PID: Process ID of the application.
    • USER: User running the process.
    • DISK READ: Amount of data read by the process.
    • DISK WRITE: Amount of data written by the process.
    • SWAPIN: The percentage of time the process spent waiting for I/O.
    • IO PRIORITY: The I/O priority of the process.

Step 7: Monitor Specific Resources

  • Monitor CPU Usage: In HTOP, CPU usage is displayed at the top of the screen. If you see high CPU usage from specific processes, you can take action by stopping or optimizing those processes.
  • Monitor Memory Usage: Memory usage is also displayed in HTOP. If a process is consuming too much memory, consider investigating or terminating it.
  • Monitor Disk Usage: IOTOP will help you track which processes are consuming the most disk I/O. Heavy disk activity could indicate a process that needs optimization or adjustment.

Step 8: Set Up Alerts for High Resource Usage (Optional)

  • You can configure system alerts to notify you when resource usage exceeds a set threshold. This can be achieved by using tools like cron or configuring system monitoring services like Nagios, Prometheus, or Zabbix.
    • For example, you can monitor CPU usage and trigger a script to notify you when usage exceeds 90%:
      sudo apt-get install sysstat
      
      Create a script that checks the CPU usage and sends an alert.

Step 9: Use the Data to Optimize Server Performance

  • After monitoring your server’s performance with HTOP and IOTOP, you’ll be able to identify potential issues, such as:
    • Processes that consume excessive CPU or memory.
    • Disk I/O bottlenecks that slow down performance.
  • Once you've identified these issues, you can take action, such as:
    • Killing or optimizing resource-heavy processes.
    • Adding more CPU, RAM, or storage if necessary.
    • Investigating and fixing disk I/O issues with your server setup.

Step 10: Exit the Monitoring Tools

  • Once you’ve completed your monitoring session, you can exit HTOP and IOTOP:
    • For HTOP, press F10 or q.
    • For IOTOP, press q to exit.

By regularly monitoring your server with tools like HTOP and IOTOP, you can ensure that your server is running efficiently and identify any performance issues before they affect your server’s operations.

This guide will help you stay proactive in managing the performance of your server, ensuring a smooth and reliable experience for your hosting needs.

Was this answer helpful? 0 Users Found This Useful (0 Votes)