Batch script like system monitor for Centos

Posted on 2011-04-25
Last Modified: 2012-08-13
Hello experts,

I need a script for utilization log of my server, those are: CPU usage, Memory, PID, Time on Centos.
You can see system monitor on Centos or Task Manager on Windows.
But I need this log every 5 minute created.

Thanks advanced.
Question by:softbless
    LVL 31

    Expert Comment

    SAR is a utility that may be very useful for you.
    LVL 38

    Expert Comment

    For system monitoring, you can use Nagios

    It can log CPU usage , load, memory, process via NRPE.
    And you can configure the threshold to alert sys admin.

    Or you just want a script to login the system utilization, then here is the simpe one
    --------- /home/user/ ----

    log_file=/tmp/utilization.log.`date +%Y%m%d_%H%M`

    /usr/bin/top -b -n1 > $log_file

    $ chmod +x /home/user/

    and create cron job
    $ crontab -e
    */5 * * * * /home/user/ > /dev/null 2>&1
    LVL 76

    Expert Comment

    by:arnold is a tool that collects information and presents in a graphical way.

    Author Comment

    Hi wesly_chen,

    How to see only 10 process? So in log, there are 10 process every 5 minutes.
    Btw, I don'y know about this PR  NI  VIRT  RES  SHR S. Can you explain me?

    Thank you very much.
    LVL 38

    Accepted Solution

    man top
    it has more details for those information. i.e.
    PR  --  Priority
    NI  --  Nice value
    VIRT  --  Virtual Image (kb)
    SHR  --  Shared Mem size (kb)
    S  --  Process Status

    man page of top has more details (I can not copy and paste the manpage here)

    > How to see only 10 process?

    log_file=/tmp/utilization.log.`date +%Y%m%d_%H%M`

    /usr/bin/top -b -n1 | head -17 > $log_file
    LVL 38

    Expert Comment


    Author Closing Comment


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
    Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    733 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

    25 Experts available now in Live!

    Get 1:1 Help Now