how to find the cpu utilisation ratio in linux and unix
how to find the cpu utilisation ratio in linux
Collapse
X
-
Tags: None
-
Check out the /proc directory.This directory mostly consists of these system related info.There is one file called /proc/cpuinfo which gives physical parameters CPU info ,but thats not what you are looking for.
I am trying to find the answer to your question.
Originally posted by narasimha435how to find the cpu utilisation ratio in linux and unix -
The command "w" (/bin/w in Solaris, /usr/bin/w in Linux -- at least Fedora) will give you that information.
The first line of the output should look like:
08:58:53 up 75 days, 18:04, 3 users, load average: 0.03, 0.07, 0.02
or
8:55am up 38 day(s), 1 user, load average: 1.28, 1.37, 1.29
Depending on what you plan to do with it, you may need to parse out specific information. For example, I run the following script every half hour on one of the Solaris boxes I am responsible for:
[code=perl]#! /bin/perl
use strict;
open IN, "/bin/w |" or die "could not run w to get load average: $!\n";
my $line = <IN>;
close IN;
chomp $line;
my ($junk,$avgs) = split /load average: /,$line;
my ($min,$fivemin, $fifteenmin) = split /, /, $avgs;
print scalar localtime(), "\t$min\t$fivem in\t$fifteenmin \n";[/code](My crontab includes a redirection to append the data to a file.)
HTH,
PaulComment
Comment