Archiving HP-UX old /var/adm/syslog/OLDsyslog.log

It’s hard to troubleshoot constantly rebooting Oracle RAC nodes…

Especially if old system log are constantly overwritten.

To cope with this issue on HP-UX I wrote simple script that at system startup time archives old /var/adm/syslog/OLDsyslog.log file with compression. It makes possible to track back in time when issue appeared first.

To install this solution please create script /tmp/OLDsyslog.log.archiver with next contents and execute it as root:

. /tmp/OLDsyslog.log.archiver install

By default:

  • OLDsyslog.log compressed with gzip
  • archives older than 90 days are deleted

Please, don’t install this script in production before testing!!!

#!/sbin/sh
#
# WARNING: Changing this script in any way may lead to a system that
#          is unbootable.  Do not modify this script.

# (c)Oleksandr Denysenko - odenysenko@gmail.com
# archiving /var/adm/syslog/OLDsyslog.log
#

PATH=/usr/sbin:/usr/bin:/sbin
export PATH

SUBSYSTEM_NAME="basename $0"
DELETE_ARCHIVES_OLDER_THAN_DAYS=90
COMPRESS="/usr/contrib/bin/gzip -c"
TARGET_SCRIPT_NAME="/sbin/init.d/`basename $0`"
RUNLEVEL_LINK="/sbin/rc2.d/S225`basename $0`"

rval=0

case $1 in
'start_msg')
 echo "Starting the $SUBSYSTEM_NAME subsystem"
 ;;

'stop_msg')
 #echo "Stopping the $SUBSYSTEM_NAME subsystem"
 ;;

'install')
 cp $0         $TARGET_SCRIPT_NAME
 chown bin:bin $TARGET_SCRIPT_NAME
 chmod 555     $TARGET_SCRIPT_NAME
 if [ -f $RUNLEVEL_LINK ]
 then
 rm $RUNLEVEL_LINK
 fi
 ln -s         $TARGET_SCRIPT_NAME  $RUNLEVEL_LINK
 ;;

'start')
 if [ -f /var/adm/syslog/OLDsyslog.log ]
 then
 find /var/adm/syslog -name 'OLDsyslog.log.*.gz' -mtime +${DELETE_ARCHIVES_OLDER_THAN_DAYS} -exec rm -f {} \;
 $COMPRESS /var/adm/syslog/OLDsyslog.log > /var/adm/syslog/OLDsyslog.log.`date +%Y%m%d_%H%M`.gz
 fi
 ;;

'stop')
 # nothing to stop
 ;;

*)
 echo "usage: $0 {install|start|stop|start_msg|stop_msg}"
 rval=1
 ;;
esac

exit $rval
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s