Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-12-2004, 05:31 AM   #1
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Rep: Reputation: 30
Monitoring Script (using mpstat) tip

Hi folks,

I'm in the process of writing a generic script which will monitor CPU usage (in terms of idle time) on a Solaris 8 box (However this would work on any UNIX system). I'm using the 'mpstat' command in the following way:

bash-2.03$ mpstat 1 3 | awk -F" " {'print $16'} > cpu_usage

bash-2.03$ cat cpu_usage

The 'mpstat 1 3' part will display 3 values of CPU statistics per CPU, sampled on a 1 second basis,. The awk part will only grab the "idl" value since mpstat generates much more statistics.

As you can see in the example above, I have 2 CPUs.

My ultimate goal is to provide an average of the 'idl' value for each CPU. I am finding problems extracting the 84,93 and 100 numbers for one CPU and the 85,88, and 99 numbers for the other CPU.... Remember that I have to keep in consideration the fact that the number of CPUs can vary and I want to keep the script as generic as possible.

Thanks for any tips.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Port Monitoring bash script twantrd Programming 15 01-29-2009 12:59 AM
Monitoring Script required nimish Linux - Software 0 11-05-2004 03:25 AM
bash script, monitoring running PID? thebover Programming 4 08-26-2004 02:42 PM
Please advise on monitoring script pembo13 Linux - Software 1 07-22-2004 02:04 AM
Monitoring with perl script tidom Linux - Enterprise 4 05-02-2004 02:01 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:21 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration