LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-10-2006, 05:00 PM   #1
bebeslb
LQ Newbie
 
Registered: Jan 2006
Posts: 6

Rep: Reputation: 0
Trying to generate resource information and email the output.


Hey folks

I am trying to write a script for the first time and i think i have been successful. I would like your input to make it "better". I get the output that i need. Can someone please take a look at the script at your convenience?

Thank you in advance.

Bebeslb

#!/bin/bash
# Remove file for the directory /var/log/os-res.log and creating a new new
rm /var/log/os-res.log
# Create new os-res.log everytime script is used.
output=/var/log/os-res.log #Log file path
prt1=389 #Port Number to monitor the number of connections
prt2=636 #Port Number to monitor the number of connections
interval=1800 #Interval in seconds

i=0
while [ $i -le 1000000 ]
do
date >> $output

echo "netstat-$prt1:" >> $output
netstat -na|grep $prt1 | grep -i established | wc -l >> $output
echo "-------------------------------------------------------------" >> $output

echo "netstat-$prt2:" >> $output
netstat -na|grep $prt2 | grep -i established | wc -l >> $output
echo "-------------------------------------------------------------" >> $output

echo "vmstat:" >> $output
vmstat -S M >> $output
echo "-------------------------------------------------------------" >> $output

echo "cpustat:" >> $output
sar -U 2 20 >> $output
echo "-------------------------------------------------------------" >> $output

echo "memory" >> $output
sar -r >> $output
echo "-------------------------------------------------------------" >> $output

echo "iostat:" >> $output
iostat >> $output
echo "=============================================================" >> $output

sleep $interval
i=`expr $i + 1`

if [ -s /var/log/os-res.log ]; then
mail -s "Diana OS Resource Results $(date +%F)" blah@blah.com < /var/log/os-res.log
fi

done
#end
 
Old 10-11-2006, 09:51 AM   #2
RaelOM
Member
 
Registered: Dec 2004
Posts: 110

Rep: Reputation: 16
Why wouldn't you use a RT perf monitor tool? MRTG, Cacti, HP Openview, et al?

This seems awfully inefficient
 
  


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
Hiding machine information and root information geletine Linux - Security 6 07-14-2006 07:57 AM
how to generate .so abd_bela Programming 1 01-31-2006 04:12 AM
Slackware 10.1 + Information Resource Manager (IRM) caps_phisto Linux - General 1 05-11-2005 11:02 AM
Generate a system event to send email ? debian_dummy Debian 2 05-02-2004 04:37 AM
the sound gives output when using mic but no output when run a music file medo Debian 0 04-19-2004 07:17 PM


All times are GMT -5. The time now is 07:53 PM.

Main Menu
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