osedebt.blogg.se

Shell script to monitor cpu and memory usage in linux
Shell script to monitor cpu and memory usage in linux













  • Multiple plugins and add-ons are running in the background.
  • Several tabs are opened at the same time.
  • BrowserĮven the browser can cause high CPU usage if: These are often invisible and heavily utilize the CPU.

    shell script to monitor cpu and memory usage in linux

    If a system becomes extremely slow with a CPU usage of nearly 100%-but with no clear cause-the problem may be a virus or malware.

    shell script to monitor cpu and memory usage in linux

    Too many background processes running simultaneously on a computer consume CPU resources and unnecessarily cause high CPU usage. Autostart programs and background processesĪutostart programs are applications that are launched automatically when booting the operating system and they continue to run in the background.

    shell script to monitor cpu and memory usage in linux

    If the idle process is taking up to 99% of the CPU's power, it means only 1% is being used to run actual tasks.Ģ. This process appears to show high CPU usage, but it actually indicates the percentage of CPU capacity not being used. If a system is idle, the OS creates a process called the System Idle Process to prevent the system from shutting off. Higher than average CPU usage can often be attributed to one of the following causes: 1. To get the top 5 processes (sorted by cpu usage), you can use the following command (source: ): ps aux | sort -nrk 3,3 | head -n 5Īnd now you can combine the monitoring plugin and the process output: /usr/lib/nagios/plugins/check_cpu_stats.Since high CPU utilization indicates poor system performance, it should be avoided. I also need to get the start commands and process names of the top 5 process Example: /usr/lib/nagios/plugins/check_cpu_stats.sh -w 70,70,70 -c 80,80,80 > /dev/null if ] then echo "alert" | mailx -s "cpu alert" else echo "no alert" fi But you can also use the plugin standalone and send an alert.

    shell script to monitor cpu and memory usage in linux

    You can of course also adapt the thresholds to your environment.Ĭoncerning the alerting part: The best scenario is of course, if you already have this host/machine in an existing monitoring. Critical thresholds are set to 80% CPU usage on user, system and iowait. Warning thresholds are set to 70% CPU usage on user, system and iowait. There are a couple of different versions of this plugin out there, one example can be found here: The plugin check_cpu_stats supports thresholds on CPU usage (not load). I suggest you use an already existing monitoring plugin for this purpose. I need to send an email whenever the CPU utilization goes beyond 70%?















    Shell script to monitor cpu and memory usage in linux