Sponsored Content
Operating Systems Linux Gentoo cpu%/mem% usage, scripting, dzen2: howto learn bash the hard way Post 302221230 by era on Monday 4th of August 2008 01:52:20 AM
Old 08-04-2008
Obiously, awk is a fairly complete programming language, so you can rewrite simple text-processing utilities in awk, many of them easily.

Code:
awk 'NR==10 { exit 0 }1'  # head -10
awk '{ print $2 }'   # cut -f2 (splitting on runs of whitespace though)

tail is harder to emulate generically because the array type is rather crude. Maybe switch to sed (or Perl!) for that.

See also http://www.pement.org/awk/awk1line.txt

The first few lines of top output indicate the CPU usage. Read the manual page to learn what the fields mean.

Code:
Cpu(s): 16.8%us,  1.7%sy,  0.0%ni, 80.5%id,  0.8%wa,  0.1%hi,  0.1%si,  0.0%st

 

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
I3BAR(1)																  I3BAR(1)

NAME
i3bar - xcb-based status- and workspace-bar SYNOPSIS
i3bar [-s sock_path] [-b bar_id] [-v] [-h] WARNING
i3bar will automatically be invoked by i3 for every bar configuration block. Starting it manually is usually not what you want to do. You have been warned! OPTIONS
-s, --socket sock_path Overwrites the path to the i3 IPC socket. -b, --bar_id bar_id Specifies the bar ID for which to get the configuration from i3. -v, --version Display version number and exit. -h, --help Display a short help-message and exit DESCRIPTION
i3bar displays a bar at the bottom (or top) of your monitor(s) containing workspace switching buttons and a statusline generated by i3status(1) or similar. It is automatically invoked (and configured through) i3. i3bar does not support any color or other markups, so stdin should be plain utf8, one line at a time. If you use i3status(1), you therefore should specify output_format = none in the general section of its config file. ENVIRONMENT
I3SOCK Used as a fallback for the i3 IPC socket path if neither the commandline contains an argument nor the I3_SOCKET_PATH property is set on the X11 root window. EXAMPLES
Nothing to see here, move along. As stated above, you should not run i3bar manually. Instead, see the i3 documentation, especially the User's Guide. SEE ALSO
i3status(1) or conky(1) for programs generating a statusline. dzen2(1) or xmobar(1) for similar programs to i3bar. AUTHORS
Axel Wagner and contributors AUTHOR
Axel Wagner <mail+i3bar@merovius.de> Author. 4.1 October 2011 I3BAR(1)
All times are GMT -4. The time now is 07:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy