LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-15-2007, 02:20 PM   #1
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Rep: Reputation: 30
monitoring Linux


Dear all,

we are running oracle on Linux RHEL ES 4.0...

I use to monitor OS using the following commands :

df -h
free -m
sar 1 5
top

what else can you suggest to check inorder to avoid any disaster



Thanks
Yusuf
 
Old 12-15-2007, 03:18 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
Become familiar with the system logs (the files in /var/log) and read them. If you have a lot of systems to monitor you can use something like Nagios to monitor them from one central console.
 
Old 12-15-2007, 06:01 PM   #3
snowman81
Member
 
Registered: Aug 2006
Location: Michigan
Distribution: Ubuntu
Posts: 282

Rep: Reputation: 30
I would also recommend a search for different monitoring commands. Often times there are small innocuous programs that you don't know about that are extremely useful.
 
Old 12-15-2007, 07:59 PM   #4
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
Here are some other basic monitoring commands

who or w


To monitor currently logged in users

ps -aux

Check for running processes

last

list previous logins

crontab -l


Check if you or anyone is running any schedule jobs

netstat -tap


Check for active tcp connections to and from your computer and what ports your computer is listening to. The p option tells which program is being used.

There are many more commands in linux, but it depends what kind of monitoring you looking for. For example IDS intrusion detection system.

Last edited by dv502; 12-15-2007 at 08:33 PM.
 
Old 12-15-2007, 10:01 PM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
htop is a good alternative to top. It's a little more feature-rich, and is in colour!
 
Old 12-16-2007, 12:17 AM   #6
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by matthewg42 View Post
htop is a good alternative to top. It's a little more feature-rich, and is in colour!
Thankyou miller,snowman,DV502 and mathew for your excellent answers, that really helped me..

Is there anyway,I can have the monitorin commands in a script and run it periodically.give me a example.. I will develop the remaining..


Thanks in advance
Yusuf
 
Old 12-16-2007, 05:51 AM   #7
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Yes, it is possible. You just have to make sure the commands will not run indefinitely. htop and top, when invoked normally use a curses interface, which cannot usefully be re-directed to a file, but top has a batch mode for just this sort of thing.

You could write a simple script like this:
Code:
#!/bin/bash

LOGFILE=/path/to/your/logfile.log

echo "Logging system stuff at $(date)" >> "$LOGFILE"
# log vmstat.  3 * 5 second interval.  Probably better than 1 second as it 
# gives more time to average out the load analysis.
vmstat 5 3 >> "$LOGFILE"

# make a blank line between commands to help readability.
echo "" >> "$LOGFILE"

top -b -n 1 >> "$LOGFILE"
echo "" >> "$LOGFILE"
w >> "$LOGFILE"
netstat -tap >> "$LOGFILE"
echo "" >> "$LOGFILE"
echo "" >> "$LOGFILE"
...and so on - just add anything you like there. The important thing is that the program will not wait for input from the user (like top in interactive mode).

You can then call this script from cron every 5 minutes or something like that. Use the command "crontab -e" and then enter a line:
Code:
*/5 * * * * /path/to/your/script.sh

Last edited by matthewg42; 12-16-2007 at 05:52 AM.
 
Old 12-16-2007, 06:11 AM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 20,945

Rep: Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070
You mentioned "sar" - that is from the sysstat package.
Properly implemented that will have all the history (and more) that you could need.
No need for extra scripts.
 
Old 12-29-2007, 04:30 AM   #9
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by matthewg42 View Post
Yes, it is possible. You just have to make sure the commands will not run indefinitely. htop and top, when invoked normally use a curses interface, which cannot usefully be re-directed to a file, but top has a batch mode for just this sort of thing.

You could write a simple script like this:
Code:
#!/bin/bash

LOGFILE=/path/to/your/logfile.log

echo "Logging system stuff at $(date)" >> "$LOGFILE"
# log vmstat.  3 * 5 second interval.  Probably better than 1 second as it 
# gives more time to average out the load analysis.
vmstat 5 3 >> "$LOGFILE"

# make a blank line between commands to help readability.
echo "" >> "$LOGFILE"

top -b -n 1 >> "$LOGFILE"
echo "" >> "$LOGFILE"
w >> "$LOGFILE"
netstat -tap >> "$LOGFILE"
echo "" >> "$LOGFILE"
echo "" >> "$LOGFILE"
...and so on - just add anything you like there. The important thing is that the program will not wait for input from the user (like top in interactive mode).

You can then call this script from cron every 5 minutes or something like that. Use the command "crontab -e" and then enter a line:
Code:
*/5 * * * * /path/to/your/script.sh



Thank you mathew always, I've solved many of real time issues with your help.. and now this time, if you can also tell me.. how to get the output of this script to a mail.. in otherwords, from the above it is storing it in a logfile, where as what can I do to recieve the output in mail using send mail.

Please help


Thanks
Yusuf
 
Old 12-29-2007, 05:09 AM   #10
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Quote:
and now this time, if you can also tell me.. how to get the output of this script to a mail
Here it is
Code:
cat $LOGFILE | mail -s "Contents of my LOGFILE" user@company.com
-twantrd
 
Old 12-29-2007, 05:23 AM   #11
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by twantrd View Post
Here it is
Code:
cat $LOGFILE | mail -s "Contents of my LOGFILE" user@company.com
-twantrd

Thanks a lot Twantrd..



am using the following script :
***********************************************************************
[root@oracle ~]# sh /root/test/tests/test/sysos.sh

LOGFILE=/home/oracrp/test/sysos.log
+ LOGFILE=/home/oracrp/test/sysos.log

echo "Logging system log at $(date)" >> "$LOGFILE"
date
++ date
+ echo 'Logging system log at Sat Dec 29 14:10:27 AST 2007'
# log vmstat. 3 * 5 second interval. Probably better than 1 second as it
# gives more time to average out the load analysis.

sar 1 5 >> $LOGFILE
+ sar 1 5


#/usr/sbin/sendmail erp_webmail@ali.com.kw << EOM
#FromBA
#To:Yusuf
#Subject:$(date +%d-%b-%Y) Alert Log Error

#EOM

# make a blank line between commands to help readability.
echo "" >> "$LOGFILE"
+ echo ''

top -b -n 1 >> "$LOGFILE"
+ top -b -n 1
echo "" >> "$LOGFILE"
+ echo ''

w >> "$LOGFILE"
+ w

#netstat -tap >> "$LOGFILE"
echo "" >> "$LOGFILE"
+ echo ''
echo "" >> "$LOGFILE"
+ echo ''


#/usr/sbin/sendmail erp_webmail@ali.com.kw << EOM
#FromBA
#To:Yusuf
#Subject:$(date +%d-%b-%Y) SYSOS

#EOM

cat $LOGFILE | mail -s "Contents of my LOGFILE" erp_webmail@ali.com.kw
+ cat /home/oracrp/test/sysos.log
+ mail -s 'Contents of my LOGFILE' user@company.com

***********************************************************************


am goin to have the above script in CRON which runs every 1 hour and sends a mail to the user. but since, the logfile is getting accumulated every time the script runs, so it sends the complete logfile contents to the user.. is there anyway,I can overcome this such that it should send only the last time executed commands output to the mail ?

Please help


Thanks
Yusuf
 
Old 12-29-2007, 04:26 PM   #12
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
That's because you are using '>>' which APPENDS the output to the logfile. To do what you want, change only the first instance of writing the logfile to '>'.

-twantrd
 
Old 12-30-2007, 04:48 AM   #13
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by twantrd View Post
That's because you are using '>>' which APPENDS the output to the logfile. To do what you want, change only the first instance of writing the logfile to '>'.

-twantrd
Excellent twanrd, it works fine


Thanks
Yusuf
 
  


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
Monitoring Applicaitons for my Linux dragunu Linux - Newbie 4 11-13-2006 11:05 AM
Monitoring Linux Servers bebeslb Linux - Enterprise 1 06-08-2006 06:55 PM
Linux monitoring tools chrs0302 Linux - Software 3 03-14-2006 01:06 PM
Linux - Monitoring hlozo Linux - Networking 2 09-07-2004 05:42 PM
Harddisk monitoring of Linux manya Linux - Security 2 06-09-2004 07:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:53 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
Open Source Consulting | Domain Registration