Rather high CPU usage with memory monitoring bash script

Posted on Nov 21, 2013 3:55 AM, Linux - Stack Overflow | stackoverflow.com

I wrote a little script to monitor memory usage and send an e-mail when free cached memory drops below 1000 MB, but is greater than 800 MB:

#!/bin/bash
while [ true ] ;do
used=`free -m |awk 'NR==3 {print $4}'`

if [ $used -lt 1000 ] && [ $used -gt 800 ]; then
echo 'Free memory is below 1000MB. Possible memory leak!!!' | /bin/mail -s 'HIGH MEMORY ALERT!!!' user@mydomain.com

sleep 5
fi
done

The script works very well but, for some reason, it has a 10% constant CPU usage (and we are talking about a new generation quad-core Xeon processor. I have much bigger scripts that stay well below 1% CPU usage.

Any idea what's causing this and how I can optimize it?

Similar Messages
  1. Help me trace a system process please? fresh Win8, high CPU usage @ idle.
  2. High cpu usage, not responding ,
  3. High CPU usage/no battery life.
  4. High CPU Usage after start
  5. Super high CPU usage
  6. Service Host (11) High CPU Usage
  7. WMV/AVI Choppy play w High CPU Usage (Fedora 20)
  8. High CPU usage while sampling microphone on java?
  9. Android App high cpu-usage
  10. Issue of High CPU and Memory Utilization on High end routers/Switches
  11. Excel 2013 High CPU usage upon opening file
  12. Flash high CPU usage
  13. High CPU usage caused by System Interrupts and System
  14. Store Broker causing very high cpu usage?
  15. High cpu usage (mavericks)
  16. Boxes High CPU Usage on Key Presses with Windows 8.1 Guest
  17. Laravel high cpu load using file based sessions
  18. System Interrupts abnormal high CPU usage
  19. Two-fold problem with nvidia (high cpu usage) & nouveau (blank external monitor).

Help me trace a system process please? fresh Win8, high CPU usage @ idle.

Posted on Nov 14, 2013 2:22 AM,

So I have a fresh install of Win8.1 LEGAL copy (it's about 2 weeks old) I noticed yesterday abnormally high CPU usage. ~40% in task manager when the computer is doing nothing. After some investigation, most google searches are telling me it's a driver issue, run a trace this or that. ...

High cpu usage, not responding ,

Posted on Nov 15, 2013 3:37 AM,

I have the slowest computer. It never used to be this way.It takes for ever to boot and when it finally does when you click on anything it gets the not responding thing. i constantly get the high cpu usage message. the norton program seems to supposedly fix problems but it still isnt working. this...

High CPU usage/no battery life.

Posted on Nov 16, 2013 5:42 AM,

I need a way to debug my phone and figure out what is causing such high CPU usage and poor battery life. After startup, my phone sticks at 100% until it freezes and restarts but sometimes I get lucky and it goes down a few percentages but freezes again when I start multi tasking a bit. I don't know what ...

High CPU Usage after start

Posted on Mar 07, 2014 7:27 AM,

I have a desktop PC with Windows 8.1 on it. It has been running really well so far. But about two weeks ago I started experiencing this High CPU usage just after turning on the computer. It goes like this for about 10 minutes or so and then goes back to normal. I took a screenshot of my...

Super high CPU usage

Posted on Apr 27, 2014 2:18 AM,

I'm getting ridiculously high CPU usage for what seems to be no real reason.. At first I assumed it was some sort of virus, or malware but after scanning and restarting multiple times the issues have persisted. I don't know what's going on but I'm getting 100% usage and I've never actually seen...

Service Host (11) High CPU Usage

Posted on May 14, 2014 8:55 AM,

Recently I have noticed an unusually High CPU usage from 'Service Host: Local System (Network Restricted)(11)' Attachment 43239 (http://www.eightforums.com/attachments/performance-maintenance/43239-service-host-11-high-cpu-usage-capture.png) Any ideas how to fix? I have tried the fix from this (http:...

WMV/AVI Choppy play w High CPU Usage (Fedora 20)

Posted on May 30, 2014 3:44 AM,

Hi, I"mve managed to get my WMV/AVI files to play. However they play in a choppy manner with high CPU usage. I don't see this choppy playback when viewing youtube videos. I get the folling errors from VLC: [0x7f1cec000958] main video output warning: picture is too late...

High CPU usage while sampling microphone on java?

Posted on Jul 15, 2014 4:32 AM,

I am playing with the microphone to sample eg my voice. For that I use the javax.sound.sampled pacakge. However, when only sampling the microphone, I have a very high CPU usage. The code is available here : http://91.121.120.36:8081/root/gui-freq/blob/6b470aaf03038562578e4386c6774f...

Android App high cpu-usage

Posted on Mar 11, 2012 3:18 AM,

I am programming a app that has to do a operation with high cpu usage on a longer time the operation is startet like a service but the android system kills the app because of the high cpu usage so what can I do to reduce the cpu usage ? and make the system not to stop my service ? s...

Issue of High CPU and Memory Utilization on High end routers/Switches

Posted on Oct 25, 2014 3:44 AM,

Hi experts....hope u doing good !! I thing w.r.t high cpu and memory utilization on high end routers and switches ...we have ZTE devices ZXR10-6804,M6000 8S routers and ZXR10-8900/5900 switches in our network ....need to know best ways to troubleshoot and solve the issue OF HIGH CPU AND...

Excel 2013 High CPU usage upon opening file

Posted on Nov 06, 2014 11:21 AM,

Hello, I am heavily reliant on excel to analyze data recorded from past experiments. I occasionally run into the problem of high CPU usage (>96%) that will cause Excel to crash. Recently, I can no longer open ANY excel spreadsheet file without the excel program crashing. A can open...

Flash high CPU usage

Posted on Dec 30, 2013 3:43 AM,

Hi Guys hoping someone can help. So I have a late 2011 11" Core i7 Macbook Air, Whenever I load a flash based website in any browser I get high CPU / GPU usage, Fans spin up and the battery life tanks, the battery life goes down to just over a hour on full load (TBH I cant get much ...

High CPU usage caused by System Interrupts and System

Posted on Apr 25, 2014 5:08 AM,

Hello, I have read couple of threads about this System Interrupts thing and none of them really helped me. I think you can check the specs somewhere, I am not sure since I am new to the forum. Basically when I start my laptop everything is good for a while when suddenly the CPU usage goes high...

Store Broker causing very high cpu usage?

Posted on Apr 29, 2014 8:03 AM,

So I booted up my pc this afternoon, and could not help but notice with my monitoring software, my cpu activity was going nuts. I opened task manager, and sorted by cpu usage, and " Store Broker" was using app 35% of my cpu just sitting at desktop. I ended it in task manager - what the heck is this and why ...

High cpu usage (mavericks)

Posted on Jun 09, 2014 1:40 AM,

Hey,  On Mavericks, I've been noticing that I'm getting a high (unacceptable) CPU% usage in Photoshop. When not even using the program and having it ran in the background, about 8-10% is taken up. This seems normal. When I do some simple strokes my CPU will bounce up to 50-80%....

Boxes High CPU Usage on Key Presses with Windows 8.1 Guest

Posted on Jul 16, 2014 5:53 AM,

Hi all, I have a strange issue with Gnome Boxes. If I start typing fast on the keyboard in the guest OS (which is Windows 8.1), CPU usage goes high in the host (above 150%) and the guest slows down to the point even network communication halts. It lasts until few seconds after I stop typing....

Laravel high cpu load using file based sessions

Posted on Sep 10, 2014 1:52 AM,

Leading up to the question: Recently a website I have in production was experiencing very high CPU loads. After monitoring the processes using top -d 1 we could easily see that several times a second a apache process would spike to 90% to 100% cpu usage. We im...

System Interrupts abnormal high CPU usage

Posted on Oct 20, 2014 11:43 AM,

Hi, usually my laptop had in fully idle state about 1-2% CPU usage. Currently I get approximately 8-10% CPU usage in idle state. From task manager, the most demanding process is System Interrputs consuming between 5-6% CPU. I suppose this is abnormal high. Can I somehow lower this usage? Because with 10% ...

Two-fold problem with nvidia (high cpu usage) & nouveau (blank external monitor).

Posted on Nov 04, 2014 7:01 AM,

Guys & Gals, I am facing two different problems with the nvidia & nouveau drivers. With the nvidia driver, all seem to work just fine.... except one thing: cpu usage gets pretty high, especially when scrolling on any browser (e.g. facebook, youtube scrolling---->cpu goes up to 90+%, ...

 
 
Email:

Username:

Password:


Register

Username:

Password:

Login