Extracting load average from uptime command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extracting load average from uptime command
# 1  
Old 11-07-2009
Extracting load average from uptime command

The output ofthe uptime command gives:
Code:
9:40am  up 9 days, 10:36,  4 users,  load average: 0.02, 0.01, 0.00

How can i extract the portion "load average: 0.02, 0.01, 0.00".
# 2  
Old 11-07-2009
Code:
$ echo "9:40am  up 9 days, 10:36,  4 users,  load average: 0.02, 0.01, 0.00" | grep -o 'load.*'
load average: 0.02, 0.01, 0.00

# 3  
Old 11-07-2009
Thanks,

How to extract the three load average fields separately?
# 4  
Old 11-07-2009
Code:
echo "9:40am  up 9 days, 10:36,  4 users,  load average: 0.02, 0.01, 0.00" | grep -o '[0-9]\+\.[0-9]\+*'
0.02
0.01
0.00



---------- Post updated at 06:54 AM ---------- Previous update was at 06:45 AM ----------

Code:
echo "9:40am  up 9 days, 10:36,  4 users,  load average: 0.02, 0.01, 0.00" | grep -o '[0-9]\+\.[0-9]\+*'|xargs|
{ read var1 var2 var3;  echo "Var 1: $var1, Var 2: $var2, Var 3: $var3" ;}

Var 1: 0.02, Var 2: 0.01, Var 3: 0.00



---------- Post updated at 07:07 AM ---------- Previous update was at 06:54 AM ----------

See here:extracting matched pattern from a line using sed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Load average unit

Hi, On load average graph, unit is 100m, 200m, 300...800m. I don't understand what it means. Thx for helping (3 Replies)
Discussion started by: Michenux
3 Replies

2. UNIX for Dummies Questions & Answers

Help with load average?

how load average is calculated and what exactly is it difference between cpu% and load average (9 Replies)
Discussion started by: robo
9 Replies

3. Shell Programming and Scripting

Extract the uptime from the output of the uptime command

Hi! I want to extract the uptime from the output of the uptime command. The output: 11:53 up 3:02, 2 users, load averages: 0,32 0,34 0,43 I just need the "3:02" part. How can I do this? Dirk (6 Replies)
Discussion started by: Dirk Einecke
6 Replies

4. UNIX for Dummies Questions & Answers

Load Average threshold

What should be the threshold for load average of a quad core processor? What constitutes "good" and "bad" load average values? (2 Replies)
Discussion started by: proactiveaditya
2 Replies

5. HP-UX

why uptime display "load average: inf, inf, inf"

Hi, Does anyone seem this kind of output from uptime and top where "load average: inf, inf, inf" is this possible problem with the processor? Cpu states: CPU LOAD USER NICE SYS IDLE BLOCK SWAIT INTR SSYS 0 0.10 5.4% 0.0% 4.0% 90.6% 0.0% 0.0% 0.0% 0.0%... (1 Reply)
Discussion started by: robertngo
1 Replies

6. UNIX for Dummies Questions & Answers

Please Help me in my load average

Hello AlL,.. I want from experts to help me as my load average is increased and i dont know where is the problem !! this is my top result : root@a4s # top top - 11:30:38 up 40 min, 1 user, load average: 3.06, 2.49, 4.66 Mem: 8168788k total, 2889596k used, 5279192k free, 47792k... (3 Replies)
Discussion started by: black-code
3 Replies

7. UNIX for Dummies Questions & Answers

uptime, load average, and # cpus

I was told that there is a correspondance between the number of cpus, the load averages, and when the cpus reach 100% capacity. I have 4 cpus and said that once the numbers hit 4.00, my CPUs are 100% at capacity. load average: 0.08, 0.09, 0.11 Is that correct? Thank you (7 Replies)
Discussion started by: csross
7 Replies

8. Shell Programming and Scripting

Determening load average.

Hi, I'm new to shell scripting. I need to make a script to add on to my cronjobs. The script must get the value of load average from my server and if its greater than 10 it should stop my apache service. I cant find a way to get the value of load average in integer type to do the check. Any... (4 Replies)
Discussion started by: jibsonline
4 Replies

9. UNIX for Dummies Questions & Answers

Load Average

Hello all, I have a question about load averages. I've read the man pages for the uptime and w command for two or three different flavors of Unix (Red Hat, Tru64, Solaris). All of them agree that in the output of the 2 aforementioned commands, you are given the load average for the box, but... (3 Replies)
Discussion started by: Heathe_Kyle
3 Replies

10. UNIX for Advanced & Expert Users

load average

we have an unix system which has load average normally about 20. but while i am running a particular unix batch which performs heavy operations on filesystem and database average load reduces to 15. how can we explain this situation? while running that batch idle cpu time is about %60-65... (0 Replies)
Discussion started by: gfhgfnhhn
0 Replies
Login or Register to Ask a Question