Sponsored Content
Operating Systems Linux Gentoo cpu%/mem% usage, scripting, dzen2: howto learn bash the hard way Post 302221485 by broli on Monday 4th of August 2008 02:07:35 PM
Old 08-04-2008
Quote:
Originally Posted by era
Modern versions of awk have a sort command. I'm not sure if it was included even in the original awk.
im on gentoo here, so is the latest stable gawk (sorry, my bad, for not telling you earlier)

Quote:
Originally Posted by era
Certainly, but I'm not really suggesting you move to Perl just for this. There are really two schools of thought on this; skip awk, and only learn Perl; or move to Perl if you run into situations which awk cannot handle comfortably. If you need to process binary data or very large data sets, Perl was designed to overcome the limitations awk have in those areas.
the very reason i started with linux, the very reason im still with linux, is that there is something to learn, teh chalenge, and the satisfaction of personal growth.
"moving to perl" doesn't mean anything "bad"
i will finish this with bash (because i wont let this sucker win). and after that, i will try to make it in perl. just because i can (or rather "just because i still dont know how" )

Quote:
Originally Posted by era
But the requirements you have shown so far should be easy to handle in awk; it's just not clear from reading the code in which direction you want the script to grow, and/or I was too lazy to rewrite it all.
there is only one more thing i want from this script. show the total of memory used, and the total of cpu used, while keeping it light

for the cpu. i had some doubts, but i have decided to show the iddle percentage. this is a personal thing, i will use it, so if i want/know iddle%, thats what im gonna get :P

for the memory, i have been researching.
i was using wmmem, so i went and read the code to and read how it calculated. i came up with the math behind it.
((total - cache - buffer) * 100 ) / total
now my problem is getting those 3 from top

unfortunately, all my work is in my personal laptop (at home), and usually, i dont spent time in this during the week, so i cant give you any particulars on what i have done so far to retrieve that data
i dont ask you to rewrite my script. actually i would hate that.
as i said, i want to solve this, or at least try

thanks for the great help so far !
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Difference in Mem usage ?

Hi All, I have a pair of sun ultra 5_10 with SunOS 5.5.1. Both are almost equally patched and set up with simillar applications. host# uname -a SunOS host 5.5.1 Generic_103640-24 sun4u sparc SUNW,Ultra-5_10 Even though both have same amount of RAM ( 512 Mb ) , ... (1 Reply)
Discussion started by: shibz
1 Replies

2. Linux

High Mem & Cpu Utilisation

Hi All, Kindly help me in optimizing the server as it displays a great amount of CPU & MEM being utilised when the mysql process executes. Below are the stats --- -------------------------------------------------------------------------- # top 15:51:57 up 23:22, 5 users, load average:... (1 Reply)
Discussion started by: gautamatul82
1 Replies

3. Linux

Linux Mem Usage

What is amount of free RAM i have now? total used free shared buffers cached Mem: 1010 963 46 0 215 256 -/+ buffers/cache: 491 518 Swap: 1983 0 1983 Above is the output of... (1 Reply)
Discussion started by: new2ss
1 Replies

4. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

5. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

6. Shell Programming and Scripting

Help with bash script - Need to get CPU usage as a percentage

I'm writing a bash script to log some selections from a sensors output (core temp, mb temp, etc.) and I would also like to have the current cpu usage as a percentage. I have no idea how to go about getting it in a form that a bash script can use. For example, I would simply look in the output of... (3 Replies)
Discussion started by: graysky
3 Replies

7. UNIX for Dummies Questions & Answers

HOWTO - Total memory and CPU usage ... without top?

Hi all, Is it possible to get total memory usage and free memory usage without top? By Googling I found for total memory usage, use vmstat, for CPU, use mpstat, for disk I/O use iostat, is this correct? Will using sar gives the same result as ALL of these three (3) commands? What about if I... (2 Replies)
Discussion started by: newbie_01
2 Replies

8. Shell Programming and Scripting

Should I learn bash scripting or is it going obsolete?

Hi folks, I'm a CS students enrolled in a sysadmin class where we've been covering bash scripting for the past few weeks. I have prior knowledge in java, c++, c#, python,and some scripting languages like asp.net w/c# and php. This bash stuff seems pretty neat and a bit different than what I am... (9 Replies)
Discussion started by: KalEl
9 Replies

9. Shell Programming and Scripting

Command to find total cpu and mem

Hi All, I need to know the command for knowing the total cpu and mem. Thanks (5 Replies)
Discussion started by: aish11
5 Replies

10. UNIX for Dummies Questions & Answers

Learn bash shell scripting

I do not know shell scripting. But at work place, I have got an in and out shell scripting task. I just need to understand a very big script. Is there any tool in which I can place the script and it can tell me the meaning of the whole script? (3 Replies)
Discussion started by: lg123
3 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 06:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy