Script to display load average on HPUX 11 Itanium 4 CPU system

Posted on 2005-05-13
Last Modified: 2013-12-26
I know in Linux you can use a perl script to display the load average for different CPU's.  What I'd like to do is write a simple script without perl to do a constant running average of each CPU's load and an overall average of the load.  Is there a quick / simple script I can use to do this?
Question by:16582
    LVL 20

    Expert Comment

    Um - what's wrong with "top" or "sar" ?

    Author Comment

    to displays all running / sleeping processes... I just want the CPU load(s). top is fine for info but I don't need all of the other info..  I'm currently running an automatic archiver daemon and it tends to spike CPU load when it kicks on.  I just want to monitor the CPU(s).
    LVL 12

    Expert Comment

    Did you try "uptime"?
    LVL 51

    Expert Comment

    sh -c "while [ 1 ]; do w; sleep 3;done"

    Author Comment

    The Current listing for top shows CPUs 0-3 and the average load/user/nice/sys/idle.  To be more specific; the overall average is nice to know but I'd like to see the individual CPU(s)  load/user/sys/ and idle.  Everything else is secondary and I can use top for that but, I just need to display the individual CPUs and their respective loads for the above output. Example Below:

    CPU  LOAD   USER   SYS      IDLE
    0      2.09    24.1%  34.6%   41.3%
    1      2.06    27.5%  36.0%   36.6%
    2      1.67    56.5%  20.2%   29.7%
    3      1.92    62.6%  19.6%   17.8%
    avg   1.93    42.8%  27.5%   29.7%

    Not required bu nice would be the current memory load and free..

    Now, I know that the top command displays this but, I am in an environment that requires some of our system users to run/monitor system settings.  I would just like to output these variables real time for the users that need the information.  They get a bit confused seeing 8 to 9 pages of information for top.  

    To make it simpler, can the top command be modified to just display this info?  I've looked in the man pages and can see how to modify the out put per CPU but not all at once.


    LVL 7

    Accepted Solution

    top handles SMP just fine, so I suspect a 4-way will also give indivdual lines.

    Create .toprc:

    $ cat .toprc
    RCfile for "top with windows"           # shameless braggin'
    Id:a, Mode_altscr=1, Mode_irixps=1, Delay_time=3.000, Curwin=1
    Def     fieldscur=AEHIOQTWKNMbcdfgjplrsuvyzX
            winflags=9520, sortindx=10, maxtasks=0
            summclr=1, msgsclr=1, headclr=3, taskclr=1
    Job     fieldscur=ABcefgjlrstuvyzMKNHIWOPQDX
            winflags=9524, sortindx=0, maxtasks=0
            summclr=6, msgsclr=6, headclr=7, taskclr=6
    Mem     fieldscur=ANOPQRSTUVbcdefgjlmyzWHIKX
            winflags=62768, sortindx=13, maxtasks=0
            summclr=5, msgsclr=5, headclr=4, taskclr=5
    Usr     fieldscur=ABDECGfhijlopqrstuvyzMKNWX
            winflags=62768, sortindx=4, maxtasks=0
            summclr=3, msgsclr=3, headclr=2, taskclr=3

    And run:

    $ top -n 1 -b
    Tasks:  63 total,   3 running,  60 sleeping,   0 stopped,   0 zombie
     Cpu0 :  1.9% us,  1.2% sy, 93.8% ni,  3.0% id,  0.0% wa,  0.1% hi,  0.1% si
     Cpu1 :  1.0% us,  1.0% sy, 93.6% ni,  4.4% id,  0.0% wa,  0.0% hi,  0.0% si


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
    Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now