purpose: gather daily messages - Sys Admin scripts
#!/bin/ksh
# john meister
# purpose: gather daily messages
# -----------------------------------------------------
LOG="~/public_html/logs/`/usr/bin/date +%d%b%y`.messages.txt" ; export LOG
##################################
# systems with ssh setup
##################################
HOSTS="host1 host2 host3 host4"
export HOSTS
DATE=`date | cut -c 5-11` ; export DATE
for x in $HOSTS
do
echo "\n### $x (`ssh $x uname -r` on `ssh $x uname -i | awk -F, '{print $2}'`) ###" | tee -a $LOG
ssh $x uptime | awk '{ print "system up " $3 " " $4 " at " $1 " load avg=" $10$11$12$13 }' | tee -a $LOG
ssh $x sar | grep Average | awk '{print "sar average is usr_"$2" sys_"$3" wio_"$4" idle_"$5"%"}' | tee -a $LOG
echo "messages ($DATE):" | tee -a $LOG
ssh $x cat /var/adm/messages | grep "`date | cut -c 5-11`" | tee -a $LOG
done
##################################
# systems without ssh use rsh
# NOT recommended
##################################
HOSTS8="host5 host6 host7 host8" ; export HOSTS8
for x in $HOSTS8
do
echo "\n### $x (`rsh $x uname -r` on `rsh $x uname -i | awk -F, '{print $2}'`) ###" | tee -a $LOG
rsh $x uptime | awk '{ print "system up " $3 " " $4 " at " $1 " load avg=" $10$11$12$13 }' | tee -a $LOG
rsh $x sar | grep Average | awk '{print "sar average is usr_"$2" sys_"$3" wio_"$4" idle_"$5"%"}' | tee -a $LOG
echo "messages ($DATE):" | tee -a $LOG
rsh $x cat /var/adm/messages | grep "`date | cut -c 5-11`" | tee -a $LOG
done
echo " ------------- " | tee -a $LOG
echo "webpage: http://server.com/logs/`/usr/bin/date +%d%b%y`.messages.txt" | tee -a $LOG
echo " ------------- " | tee -a $LOG
mailx -s "logs for (date | awk '{print $1}')(`date +%d%b%y`)" sysadmin@server.com < $LOG
##################################
|
The Art of Linux System Administration published by O'Reilly Media Study Guide for the LPIC-2 Certification Exams |
![]() Wagoneers FULL SIZE JEEPS JeepMeister "Jeep is America's -Enzo Ferrari MeisterTech Diesels + |
One Page Overview of Linux Commands click for an image of the 5 essential Linux commands An Intro to Linux |
at Midway Auto on SR9 in Snohomish, or at Northland Diesel in Bellingham, WA |