Cover V08, I07
Article
Listing 1
Listing 2
Listing 3
Listing 4
Listing 5
Listing 6

jul99.tar


Listing 5: Various cron driven logging scripts

#!/bin/ksh
# disk_io.sh (cron) script to collect disk I/O load
LOG=/stats/disk/io/d`date +%m`.log
date +%m%d%H%M >> ${LOG}
#/opt/RICHPse/examples/iost.se 30 10 >> ${LOG}
/usr/bin/iostat -xn 30 3 >> ${LOG}
#_END_

#!/bin/ksh
# cpu_mem.sh (cron) script to collect system load, memory, and cpu stats
CLOG=/stats/cpu_mem/c`date +%m`.log
ULOG=/stats/cpu_mem/u`date +%m`.log
date +%m%d%H%M >> ${CLOG}
vmstat 20 4 > /tmp/$$.vm; sed -n '4,6p' /tmp/$$.vm >> ${CLOG}
date +%m%d >> ${ULOG}
uptime >> ${ULOG}
#_END_

#!/bin/ksh
# net_io.sh (cron) script to collect collect % collissions on the network
LOG=/stats/net/io/n`date +%m`.log
date +%m%d%H%M >> ${LOG}
/usr/bin/netstat -i | grep hme0 | awk '{print $1 " "$9 * 100 / $7"% \
collision rate"}' >> \ ${LOG} #_END_ #!/bin/ksh # compress_files.sh (cron) script to compress the system activity logs # place in cron as follows: # 0 23 15 * * /usr/local/bin/compress_files.sh CPU=/stats/cpu_mem IO=/stats/net/io SAR=/stats/sar DISK=/stats/disk/io THIS_MONTH=`date '+%b'` for dir in $CPU $IO $SAR $DISK do cd $dir for file in `ls -lrt |/usr/bin/grep -v $THIS_MONTH|grep -v ".Z"| awk \
'{print $9}'` do /usr/bin/compress $file done done #_END_