LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-18-2014, 02:41 PM   #1
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
Scripting a better way for a Linux Server Baseline?


I'm trying to get a baseline on a number of physical Linux servers before we convert them to virtual machines, that way we know what to allocate.

I fooled around with a few of the command line stuff, mpstat -P ALL, iostat -d -m -h -t, and sar before I decided on a basic script such as the following

Code:
[user@server scripts]$ cat cpu_memory_resources

#!/bin/bash
# 11/18/2014
# Gathering memory, cpu and i/o for this serveri every 15 minutes

echo

printf "%s\n" "##############################################################"
printf "%s `hostname` `date`\n"
printf "%s\n" "##############################################################"

echo

printf "%s\n" "MEMORY STATS IN GIGABYTES"
echo
free -g
echo

printf "%s\n" "ALL CPU STATS"
echo
mpstat -P ALL
echo

printf "%s\n" "IO STATS FOR ALL DISKS IN MEGABYTES"
echo
iostat -d -m -h
echo
The formatting wasn't what we wanted it to be, along with it would be awesome if we could get an average for say on the hour for a 24 hour period. I was thinking maybe use AWK, however I not that familiar with it.

I settled on using the following:

Code:
vmstat -a -S m 8640 3660 > outputfile
Can anyone recommend a better way to caputre this information and clean it up?

thanks
 
Old 11-19-2014, 08:39 PM   #2
codeguy
Member
 
Registered: Jan 2004
Distribution: Slackware
Posts: 187

Rep: Reputation: 46
I don't know if its better, but here is what I use.

In /etc/cron.d/sar:
PHP Code:
*/10 * * * *  /usr/local/bin/vcsstat.sh 
vcsstat.sh:

PHP Code:
#!/bin/sh
f=`date +%M`
fn="/tmp/sa-vcs-$f"
rm -f $fn

if [[ -/usr/lib64/sa/sadc ]]
then
    app
=/usr/lib64/sa/sadc
else
    
app=/usr/lib/sa/sadc
fi

$app 
-S DISK 600 2 $fn
/usr/bin/sadf -- -bBdqrwW -P ALL  -n DEV,EDEV $fn | /usr/bin/perl /usr/local/bin/addsar.pl
rm 
-f $fn 


It runs sadc for 10 minutes every 10 minutes (it collects a 10 minute average I guess I should say).
sadf reads the binary format and dumps a text format, which addsar.pl loads into a database.

You can see a quick sample by doing:
/usr/lib/sa/sadc -S DISK 10 2 > /tmp/sa
/usr/bin/sadf -- -bBdqrwW -P ALL -n DEV,EDEV /tmp/sa
 
Old 11-20-2014, 12:22 PM   #3
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420

Original Poster
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
I'm not familiar with PHP and in the past I've problems trying to get things to compile, at all.

Was hoping I could do something in Bash.
 
  


Reply

Tags
awk, iostat, mpstat, sar, vmstat



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
Need baseline info rjohnsto Linux - Networking 3 09-26-2012 07:25 PM
Performing a baseline on Apache keysorsoze Linux - Server 2 01-15-2007 09:13 PM
Baseline instllation Ghent SUSE / openSUSE 1 08-23-2005 01:17 PM
Baseline Install jmdlcar Slackware 3 07-28-2005 07:21 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:10 PM.

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
Open Source Consulting | Domain Registration