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. Flash high CPU usage
  10. High CPU usage caused by System Interrupts and System
  11. Store Broker causing very high cpu usage?
  12. High cpu usage (mavericks)
  13. Boxes High CPU Usage on Key Presses with Windows 8.1 Guest
  14. Kernel_task high cpu usage
  15. High cpu usage by mysql query
  16. Extremely High CPU Usage
  17. High CPU usage 98 - 100%
  18. Broswers causing 100% CPU usage
  19. High CPU Usage when charging Macbook Pro 2011 13"

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. ...

Read RepliesRead Related

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...

Read RepliesRead Related

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 ...

Read RepliesRead Related

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...

Read RepliesRead Related

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...

Read RepliesRead Related

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:...

Read RepliesRead Related

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...

Read RepliesRead Related

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...

Read RepliesRead Related

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 ...

Read RepliesRead Related

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...

Read RepliesRead Related

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 ...

Read RepliesRead Related

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%....

Read RepliesRead Related

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....

Read RepliesRead Related

Kernel_task high cpu usage

Posted on Nov 08, 2013 5:28 AM,

Noticed that when the app i'm developing is running, my kernel_task starts running overtime, its cpu usage can go up to 300% or more, while my app runs at around 10%, it's def my app causing the trouble, and it interferes with other running apps too so it's not acceptable. How would i go...

Read RepliesRead Related

High cpu usage by mysql query

Posted on Nov 29, 2013 10:03 AM,

I'm having some truobles in with this query, everytime when i use it the cpu usage goes from a 5% to 67%-100%. I'm running the mysql server in ubuntu by a java service but even if i execute the query via any mysql ide the results are the same. I have made some search in the web about it so ...

Read RepliesRead Related

Extremely High CPU Usage

Posted on Dec 18, 2013 2:54 AM,

Hello, I am having a problem with my computer. It has of late been running at 90+ % CPU usage, and sometimes 100. When i hit Ctrl ALT DEL and open the task manager, the services.exe under the processes tab is using almost all of the CPU. Why is this? I have Norton installed and can find...

Read RepliesRead Related

High CPU usage 98 - 100%

Posted on Jan 05, 2014 1:51 AM,

100% CPU usage . Need help ! I had my computer healthy for over a year , tough in day 26 i think, I started my PC but it was really slow and the CPU usage was at 100. It said that the process that was using more the CPU was the taskmg. So i have re.instaled my w7 and the problemas continues...

Read RepliesRead Related

Broswers causing 100% CPU usage

Posted on Jan 29, 2014 1:11 AM,

Hey, Ive been having a problem with my laptop for the last few days. IE, Firefox and Chrome are all causing high CPU usage spikes, up to 100% when opening a new tab, but when try to go to a page with video content such as youtube, this spikes to 100% and stays there. Laptop is clean and ...

Read RepliesRead Related

High CPU Usage when charging Macbook Pro 2011 13"

Posted on Mar 15, 2013 11:17 AM,

Hey, Over the last week or so I noticed that when my Macbook Pro (Late 2011 13") was switched on and charging the CPU usage shoots up to ~90% with the fan operating at roughly 6.2k RPM. I have had the laptop a year come the end of the month and mainly use it for word processing, cod...

Read RepliesRead Related
 
 
Email:

Username:

Password:


Register

Username:

Password:

Login