xref: /titanic_51/usr/src/cmd/sa/svc-sar (revision 37714ae43602c675f9dc59b070bfdf9fa702872c)
1#!/sbin/sh
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License, Version 1.0 only
7# (the "License").  You may not use this file except in compliance
8# with the License.
9#
10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11# or http://www.opensolaris.org/os/licensing.
12# See the License for the specific language governing permissions
13# and limitations under the License.
14#
15# When distributing Covered Code, include this CDDL HEADER in each
16# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17# If applicable, add the following below this CDDL HEADER, with the
18# fields enclosed by brackets "[]" replaced with your own identifying
19# information: Portions Copyright [yyyy] [name of copyright owner]
20#
21# CDDL HEADER END
22#
23#
24# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27#	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
28#	  All Rights Reserved
29#
30#ident	"%Z%%M%	%I%	%E% SMI"
31#
32# Start method script for the system activity reporting service.
33#
34# To enable periodic collection of data, you may need to uncomment
35# the entries in /var/spool/cron/crontabs/sys
36
37arg=$1
38
39set -- `/usr/bin/who -r`
40_INIT_RUN_NPREV="$8"
41# utmpx's runlevel entries are only set on reaching single-user,
42# so there might not be a who -r entry yet.
43[ -z "$_INIT_RUN_NPREV" ] && _INIT_RUN_NPREV=0
44
45case "$arg" in
46'start')
47	if [ $_INIT_RUN_NPREV -eq 0 ]; then
48
49		/usr/lib/sa/sadc /var/adm/sa/sa`date +%d`
50
51		if [ ! -f /var/spool/cron/crontabs/sys ]; then
52			cat << EOF > /var/spool/cron/crontabs/sys
53#
54# sys crontab
55#
56# The sys crontab should be used to do performance collection.
57# Please note that if the system/sar service is disabled this file
58# will be deleted. Please keep a backup copy if you change the
59# defaults.
60#
610 * * * 0-6 /usr/lib/sa/sa1
6220,40 8-17 * * 1-5 /usr/lib/sa/sa1
635 18 * * 1-5 /usr/lib/sa/sa2 -s 8:00 -e 18:01 -i 1200 -A
64EOF
65		fi
66	fi
67	;;
68'stop')
69	rm /var/spool/cron/crontabs/sys
70	;;
71*)
72	echo "Usage: $0 { start | stop }"
73	exit 1
74	;;
75esac
76
77exit 0
78