LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   SUSE / openSUSE (https://www.linuxquestions.org/questions/suse-opensuse-60/)
-   -   script to monitor memory and cpu usage (https://www.linuxquestions.org/questions/suse-opensuse-60/script-to-monitor-memory-and-cpu-usage-742013/)

s_linux 07-22-2009 01:16 PM

script to monitor memory and cpu usage
 
Im just trying to write some script to caputre memory and cpu usage on SLES servers, I just wanna use "top |grep Mem" and "top |grep Cpu". when I ran the above command, it just keep going. i just want to get one line each for memory and cpu. Any one have an idea. Thanks

ramram29 07-22-2009 02:30 PM

Better yet you can graph the result using a combination of SNMP and rddtools

David1357 07-22-2009 03:10 PM

Quote:

Originally Posted by s_linux (Post 3616720)
Any one have an idea.

Code:

[user@machine:~] top -b -n 1 | grep Mem
[user@machine:~] top -b -n 1 | grep Cpu

From the man page:
Code:

      -b : Batch mode operation
            Starts  top  in  'Batch  mode', which could be useful for
            sending output from top to other programs or to a file.
            In this mode, top will not accept input and runs until the
            iterations limit you've set with the '-n' command-line
            option or until killed.


s_linux 07-23-2009 02:03 PM

Thanks it works!!


All times are GMT -5. The time now is 07:56 AM.