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 |
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.
|
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.
|
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. |
htop is a good alternative to top. It's a little more feature-rich, and is in colour!
|
Quote:
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 |
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 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 |
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. |
Quote:
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 |
Quote:
Code:
cat $LOGFILE | mail -s "Contents of my LOGFILE" user@company.com |
Quote:
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 #From:DBA #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 #From:DBA #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 |
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 |
Quote:
Thanks Yusuf |
All times are GMT -5. The time now is 09:02 PM. |