svcadm enable sar fails to enable sar

本文详细解析了使用 svc-adm 命令在 OpenSolaris 中启用 sar 性能收集工具时遇到的问题。主要问题是 crontab 文件未正确启用,导致性能数据无法被收集。文中还提供了具体的步骤来复现此问题,并给出了解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6302763

Category
utility
Sub-Category
misc
Description
"svcadm enable sar" does not enable sar. The crontab for sar remains commented out. The problem is with both the /lib/svc/method/svc-sar script, and file permissions in /var/spool/cron/crontabs. The script. assumes that we begin without a sys crontab (which is not the case), and also that we can rm an existing sys crontab (which fails as it runs as the sys user).
The following is the execsnoop DTrace program running while we disable sar,
# execsnoop
UID PID PPID ARGS
0 820 680 svcadm disable sar
3 821 7 /sbin/sh -c exec /lib/svc/method/svc-sar stop
3 821 7 /sbin/sh /lib/svc/method/svc-sar stop
3 822 821 /usr/bin/who -r
3 823 821 rm /var/spool/cron/crontabs/sys
On the last line, we can see the "rm" command runs as UID 3. The permissions on the crontabs directory are,
# ls -ld /var/spool/cron/crontabs
drwxr-xr-x 2 root sys 512 Apr 11 15:23 /var/spool/cron/crontabs
which is why the sys user fails to rm it's crontab file.
Frequency
Always
Regression
Solaris 10
Steps to Reproduce
# svcadm enable sar
# crontab -l sys
Expected Result
#
# sys crontab
#
# The sys crontab should be used to do performance collection.
# Please note that if the system/sar service is disabled this file
# will be deleted. Please keep a backup copy if you change the
# defaults.
#
0 * * * 0-6 /usr/lib/sa/sa1
20,40 8-17 * * 1-5 /usr/lib/sa/sa1
5 18 * * 1-5 /usr/lib/sa/sa2 -s 8:00 -e 18:01 -i 1200 -A
Actual Result
#ident "@(#)sys 1.5 92/07/14 SMI" /* SVr4.0 1.2 */
#
# The sys crontab should be used to do performance collection. See cron
# and performance manual pages for details on startup.
#
# 0 * * * 0-6 /usr/lib/sa/sa1
# 20,40 8-17 * * 1-5 /usr/lib/sa/sa1
# 5 18 * * 1-5 /usr/lib/sa/sa2 -s 8:00 -e 18:01 -i 1200 -A
Error Message(s)
none
Test Case

Workaround
# svcadm enable sar
# chmod 775 /var/spool/cron/crontabs
# svcadm disable sar
# svcadm enable sar


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/228190/viewspace-670817/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/228190/viewspace-670817/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值