foldervorti.blogg.se

Linux monitor cpu and memory usage
Linux monitor cpu and memory usage










Tasks: 306 total, 3 running, 303 sleeping, 0 stopped, 0 zombie Output: You will be getting an email alert similar to the one below : CPU Current Usage is: 80.51% Say for example your system reaches the given limit after 8.25 minutes, then you will get an email alert on the second cycle i.e after 10 minutes (at the second 5 minute cycle) Note: Since the script is scheduled to run once every 5 minutes, you will get an email alert at an interval of 5 minutes. */10 * * * * /bin/bash /opt/scripts/cpu-alert.sh SUBJECT="ATTENTION: CPU load is high on $(hostname) at $(date)"Įcho "CPU current usage is: $cpuuse%" > $MESSAGEĮcho "+-+" > $MESSAGEĮcho "Top 20 processes which consuming high CPU" > $MESSAGEĮcho "$(top -bn1 | head -20)" > $MESSAGEĮcho "Top 10 Processes which consuming high CPU using the ps command" > $MESSAGEĮcho "$(ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10)" > $MESSAGEĮcho "Server CPU usage is in under threshold"įinally, add a cronjob to automate this. This is a simple and straightforward one liner script which triggers an email when your system reaches CPU utilization of 80%. If you just want to get the percentage of CPU utilization (via an email alert), instead of the information about the processes, when the system reaches a given threshold, then use the script given below.

linux monitor cpu and memory usage

Method-1 : Linux Shell script to monitor CPU utilization with an email alert

#LINUX MONITOR CPU AND MEMORY USAGE HOW TO#

  • How to Find Out Top Memory Consuming Processes in Linux.
  • linux monitor cpu and memory usage

    How to monitor disk space usage with shell script.

    linux monitor cpu and memory usage

    Refer the following articles to understand monitoring the Memory & Disk usage with the option of an email alert: These scripts will trigger an email to the corresponding email id when the system reaches a given threshold. In this tutorial we have added two shell scripts to monitor the CPU utilization on Linux system, which is very useful when user has only few systems to monitor.

    linux monitor cpu and memory usage

    There are numerous tools available to monitor and display CPU performance in Linux such as top, htop, glances, etc. If your system is under stress, it will slow down your application and becomes a bottleneck in the system. When a Linux system CPU is occupied by multiple processes, it is not available to process other requests, and the remaining pending requests must wait until the CPU is free. CPU performance is one aspect of measuring the performance of a system, which is essential to measure the overall system-performance.










    Linux monitor cpu and memory usage