LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices



Reply
 
Search this Thread
Old 09-08-2006, 03:19 PM   #1
beeblequix
Member
 
Registered: Oct 2005
Location: Tierra Firma, Earth
Distribution: Debian of course...
Posts: 196

Rep: Reputation: 30
cpu, mem, ps output to file script


howdy folks,

I wrote a small script that takes the output from several normal linux commands and writes them to a unique filename.

What do you think?

#!/bin/bash
# simple script to output various stats into unique file log
# Lord Beeblequix 09/08/2006
# yes, the name is inspired by Counterstrike

uniquedate=`date +%m%d%Y%H%M`
statfile="$HOME/stats_${uniquedate}.log"

# *********************************
# snapshot of cpu cycles using top
# *********************************
echo "Running 2x iterations of top"
top -b -n2 -C > $statfile
echo

# *********************************
# snapshot of all running processes
# *********************************
echo "ps in BSD format."
ps -aux >> $statfile
echo

# *********************************
# snapshot of memory usage
# *********************************
echo "Memory stats in MB from free -m"
free -m >> $statfile
echo
echo "Now, go get a bearclaw."

Last edited by beeblequix; 12-02-2009 at 06:32 PM.
 
Old 09-08-2006, 03:44 PM   #2
nilleso
Member
 
Registered: Nov 2004
Location: ON, CANADA
Distribution: ubuntu, RHAS, and other unmentionables
Posts: 372

Rep: Reputation: 31
__________________________________________

Last edited by nilleso; 09-08-2006 at 03:46 PM.
 
Old 09-08-2006, 03:45 PM   #3
nilleso
Member
 
Registered: Nov 2004
Location: ON, CANADA
Distribution: ubuntu, RHAS, and other unmentionables
Posts: 372

Rep: Reputation: 31
I think it's super

Why don`t ya add some disk info like:
Code:
echo "----- Top 5 File Systems by Percentage "
echo
df -k | awk '{print $5,$6 }' | grep -v capacity | \
sort -r -n -t 2 | head -5
echo
echo "----- Top 5 File Systems by Least Kilobytes free"
echo
df -k | awk '{print $4,"kb    ",$6 }' | grep -vi mounted | \
grep -v fd|grep -v mnttab|grep -v proc | sort -n -t 2 | head -5
echo
hostnm=`hostname`
dfbinary="/bin/df -kl"
disksum=`$dfbinary | grep dev | awk '{t += $2; u += $3} \
        END { printf("%d MB, %d MB used",t/1024,u/1024) }'`
echo "Diskspace available and used for $hostnm"
echo $hostnm $disksum
cheers
 
Old 09-08-2006, 04:08 PM   #4
beeblequix
Member
 
Registered: Oct 2005
Location: Tierra Firma, Earth
Distribution: Debian of course...
Posts: 196

Original Poster
Rep: Reputation: 30
good idea. thanks.
 
  


Reply


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
shell script output to file drum2jc Linux - Software 1 05-30-2006 07:54 PM
change of MB,CPU, MEM on Suse 10 Pulp Linux - Hardware 2 10-27-2005 08:32 AM
threadwise measuring of CPU/MEM usage (prstat) raees Linux - Software 1 06-28-2005 09:32 PM
What is cpu/mem monitoring tool seen here? ColKurtz Linux - Software 2 01-18-2005 12:41 PM
bash:output file names from shell script to vi sickboy Linux - Newbie 6 10-14-2004 04:40 AM


All times are GMT -5. The time now is 03:08 AM.

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