Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help w/ my little script

Status
Not open for further replies.

ponetguy2

MIS
Aug 28, 2002
442
US

I would like to have one instance of Memory output. I tried |grep 'CPU states' 'Memory' and the script did'nt like it. There should be a way where I can grep twice per command. Is there?

#!/bin/sh
while true
do
top -d 2 | col -b | grep 'CPU states'
top -d 2 | col -b | grep 'Memory'
uptime
sleep 300
done

Here is my output:


webdev# ./uptime.sh
CPU states: 99.6% idle, 0.0% user, 0.4% kernel, 0.0% iowait, 0.0% swap
Memory: 128M real, 73M free, 16M swap in use, 567M swap free
Memory: 128M real, 72M free, 16M swap in use, 567M swap free
10:59am up 14 day(s), 19:55, 3 users, load average: 0.05, 0.02, 0.02
CPU states: 99.4% idle, 0.4% user, 0.2% kernel, 0.0% iowait, 0.0% swap
Memory: 128M real, 73M free, 16M swap in use, 567M swap free
Memory: 128M real, 73M free, 16M swap in use, 567M swap free

 
like this?

top -d 2 | col -b | egrep 'CPU states'|'Memory'
 
What do you want for your output? What exactly are you looking for? There may be other methods than what you are trying to do.
 

i was able to get my desired output. however, i just wanted to know if there is a better way of producing it through my stupid little script. we are currently running top on all our servers and i don't like it. i wanted a script to replace top.

Here is my desired output:
CPU states: 99.6% idle, 0.0% user, 0.4% kernel, 0.0% iowait, 0.0% swap
Memory: 128M real, 73M free, 16M swap in use, 567M swap free



#!/bin/sh
while true
do
top -d 2 | col -b | grep 'CPU states'
top -d 1 | col -b | grep 'Memory'
uptime
sleep 300
done
 
For your setup maybe top is the best option, given you only have 128MB of memory. I have never in my IT career, worked on a server that doesn't have memory in GBs. So, I have access to other tools to capture and output that info.
 
Maybe look into Big Sister performance monitor. It is free, Big Brother is the commercial version.
 
oh, the output i've pasted on this thread is from an ultra 5. i test my little scripts on this box, before i run it on the servers. this is why you guys see 128mb of ram.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top