The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Operating Systems > Linux > Gentoo
.
google unix.com



Gentoo Gentoo Linux is a versatile and fast, completely free Linux distribution geared towards developers and network professionals.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help- To learn shell scripting tj23 Shell Programming and Scripting 2 06-20-2008 07:10 AM
newbie: way to learn more about server's resource usage blakekr UNIX for Dummies Questions & Answers 2 05-20-2008 12:43 AM
Hard disk usage is 100% Busy for any command npcrao AIX 3 11-14-2007 06:18 AM
Programming/Scripting Languages To Learn tjinr UNIX for Dummies Questions & Answers 1 07-24-2006 01:32 PM
What is a good place to learn basic shell scripting? Thanks! deutchap6verse5 Shell Programming and Scripting 2 03-08-2005 02:55 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 08-02-2008
broli's Avatar
broli broli is offline
Registered User
  
 

Join Date: Dec 2007
Location: Argentina
Posts: 215
cpu%/mem% usage, scripting, dzen2: howto learn bash the hard way

I am trying to write a small (and rather simple) script to gather some info about the system and piping it to dzen2

first, i want to explain some things.
I know i could have used conky, but my intention was to expand my knowledge of bash, pipes and redirections inside a script, and to have fun (which i am)
some time later, i also decided to try to be more strict on the resource usage. this is a script that will constantly run on a low-end laptop.

also, dzen is not the important part of the script and can be simple ignored, is just a way to show the info. if you are interested in dzen, you can read more info here gotmor - dzen

so, lets talk about the script itself

i use top in batch mode to get the list of most cpu/mem using, but now, i would like to include the total too. (in percentage)

with the memory, i was thinking maybe using free, and doing some math on the used/cached fields. but that would involve a new app to run, when top already gave me the info.
but taking the info from top's output will require a heavy use of pipes and secondary apps like tail and head

with the cpu%, well, im lost .....
where could i find that info?
im thinking, maybe is better to just use the iddle% field of top

this is what i have done so far
general pastebin - broli - post number 1091305

any suggestion on how to improve what i have done will also be welcomed
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:30 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0