Show elapsed time for startup tasks

When HP-UX boots up, more than two dozen startup scripts are run to initialize and start services and daemons. Most complete immediately, but some take a long time to complete. There is no timestamp recorded in /etc/rc.log
(where the startup scripts record their activity) so other than manually writing down the script names when there are long pauses, you can add an elapsed time to each script.

Now, for long elapsed time startup scripts, you can examine the tasks in the script and determine:

Is the service or process needed?
If not, edit the corresponding config script in /etc/rc.config.d.
If there is no config script (non-standard) then either remove the link in /sbin/rc*.d, or (recommended method) rename the link without a leading “S” or “K“, like this:
mv /sbin/rc2.d/S522ppp /sbin/rc2.d/__S522ppp

Is the script taking too long?
If yes, look at the actual commands being run. For special networking and fibre attached SAN disks, misconfigurations may take dozens of seconds to complete.

Edit the file:
/sbin/rc.utils

(about line 615, insert SECONDS=0)

echo >> $LOGFILE
echo ${FUNCT_DESC[$I]} >> $LOGFILE
echo “Output from “${FUNCT_NAME[$I]}”:” >> $LOGFILE

SECONDS=0
echo “—————————-” >> $LOGFILE

a few lines down:


eval “${FUNCT_NAME[$I]}” >> $LOGFILE 2>&1 < /dev/null

result=$?

add this echo line:

echo “${FUNCT_NAME[$I]} — Elapsed time = $SECONDS sec” >> $LOGFILE

and in same file around line 760, insert SECONDS=0:

echo ${FUNCT_DESC[$INDEX]} >> $LOGFILE
echo “Output from “${FUNCT_NAME[$INDEX]}”:” >> $LOGFILE

SECONDS=0
echo “—————————” >> $LOGFILE

edit this line:
echo “${FUNCT_NAME[$INDEX]} ” >> $LOGFILE


modified line:
echo “${FUNCT_NAME[$INDEX]} — Elapsed time = $SECONDS sec” >> $LOGFILE

The two modified lines with $SECONDS inserted are almost identical except the first one is FUNCT_NAME[$I] and the other is FUNCT_NAME[$INDEX].

Now at the next reboot, the rc.log files (/etc/rc.log and /etc/rc.log.old) will have the elapsed seconds for each script.

To sort by the process start times:

grep Elapsed /etc/rc.log | sort -nk7

To sort by the process start and stop times, sort the rc.log.old file:

grep Elapsed /etc/rc.log.old | sort -nk7

– See more at: http://serviceitdirect.com/blog/show-elapsed-time-startup-tasks#sthash.uZRd8UBm.dpuf


Tags: