分类:
2006-01-24 12:40:05
二、日志文件内容
/var/adm/loginlog //系统错误的登陆信息
/var/adm/sulog //su命令操作记录
/var/log/syslog //系统日志
/var/adm/messages, //记载来自系统核心的各种运行日志,需要每天备份
三、每天例行巡查的记录(目测),包括服务器显示灯,风扇是否正常转
备注:
1、messages记载来自系统核心的各种运行日志,包括各种精灵,如认证,inetd等进程的消息及系统特殊状态,如温度超高等的系统消息,可以说它是系统最重要的日志之一。 messages可以记载的内容是由/etc/syslog.conf决定的。就安全的角度来讲,目前互联网上入侵者采用的手段大多数是利用系统的漏洞,而当入侵者试图利用漏洞对你的服务器进行攻击时,在服务器的messages文件中一般会留下一些异常的内容,如本文最开始描述的部分,就是目前互联网上入侵者使用rpc.ttdbserver漏洞攻击所留下的痕迹,它是solaris最为臭名昭著的一个系统漏洞,入侵者利用这个漏洞可以轻松的从远端得到超级用户权限,但这种攻击不是干净的入侵攻击,它会在messages下留下记录,同时会在根目录下生成core文件,管理员经常检查系统日志,是不难发现有入侵者或入侵企图的
Solaris操作系统可以通过设置日志文件可以对每个用户的每一条命令进行纪录,这一功能默认是不开放的,为了打开它,需要执行/usr/lib/acct目录下的accton文件,格式如下/usr/lib/acct/accton /var/adm/pacct,在sun的手册上,只有这一种用法,但这样做的缺点是明显的,大多数有经验的入侵者一定不会放过/var/adm和 /var/log这两个目录的,如果它们看到有pacct这个东西,不删才怪。针对这种情况其实有个很好的解决办法,执行/usr/lib/acct/accton 后面跟一个别的目录和文件即可,如/usr/lib/acct/accton /yiming/log/commandlog,这样入侵者不会在/var/adm/下看到pacct,入侵者也许会删掉message,syslog等日志,但他并不知道实际上他所有的操作都被记录在案,管理员事后只要把commandlog这个文件拷贝到/var/adm下,改为pacct ,同时执行读取命令lastcomm,就一切尽在掌握啦。
2. dmesg命令
从错误的日志里面收集诊断信息
3.showrev 命令 [-a]
显示机器和软件的修订信息
4、Iostat参数:
iostat命令汇报磁盘I/O状态、进程流通量、队列长度、服务时间等
Usage: iostat [-cCdDeEImMnpPrstxz] [-l n] [T d|u] [disk ...] [interval [count]]
-c: report percentage of time system has spent
in user/system/wait/idle mode
-C: report disk statistics by controller
-d: display disk Kb/sec, transfers/sec, avg.
service time in milliseconds
-D: display disk reads/sec, writes/sec,
percentage disk utilization
-e: report device error summary statistics
-E: report extended device error statistics
-I: report the counts in each interval,
instead of rates, where applicable
-l n: Limit the number of disks to n
-m: Display mount points (most useful with -p)
-M: Display data throughput in MB/sec instead of Kb/sec
-n: convert device names to cXdYtZ format
-p: report per-partition disk statistics
-P: report per-partition disk statistics only,
no per-device disk statistics
-r: Display data in comma separated format
-s: Suppress state change messages
-T d|u Display a timestamp in date (d) or unix time_t (u)
-t: display chars read/written to terminals
-x: display extended disk statistics
-z: Suppress entries with all zero values
disk Explicitly specify the disks to be reported; in addi-
tion to any explicit disks, any active disks up to the
disk limit (see -l above) will also be reported.
count Only print count reports.
interval
Report once each interval seconds.
EXAMPLES
Example 1: Using the iostat command
example% iostat -xtc 5 2
extended device statistics tty cpu
device r/s w/s kr/s kw/s wait actv svc_t %w %b tin tout us sy wt id
sd0 0.4 0.3 10.4 8.0 0.0 0.0 36.9 0 1 0 10 0 0 1 99
sd1 0.0 0.0 0.3 0.4 0.0 0.0 35.0 0 0
sd6 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
nfs1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
nfs2 0.0 0.0 0.0 0.1 0.0 0.0 35.6 0 0
extended device statistics tty cpu
device r/s w/s kr/s kw/s wait actv svc_t %w %b tin tout us sy wt id
sd0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 155 0 0 0 100
sd1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
sd6 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
nfs1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
nfs2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
device
name of the disk
r/s reads per second
w/s writes per second
Kr/s kilobytes read per second
Kw/s kilobytes written per second
wait average number of transactions waiting for service
(queue length)
actv average number of transactions actively being serviced
(removed from the queue but not yet completed)
svc_t average service time, in milliseconds
%w percent of time there are transactions waiting for
service (queue non-empty)
%b percent of time the disk is busy (transactions in pro-
gress)
Example 2: Using the iostat command
example% iostat -xnp
extended device statistics
r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device
0.4 0.3 10.4 7.9 0.0 0.0 0.0 36.9 0
0.3 0.3 9.0 7.3 0.0 0.0 0.0 37.2 0
0.0 0.0 0.1 0.5 0.0 0.0 0.0 34.0 0
0.0 0.0 0.0 0.1 0.0 0.0 0.6 35.0 0 0 expositor:/export/home3/user3
The fields have the same meanings as in the previous example, with the following additions:
wsvc_t
average service time in wait queue, in milliseconds
asvc_t
average service time active transactions, in mil-
liseconds
5、Vmstat参数
vmstat命令用于统计并显示核心线程、虚拟内存、硬盘、中断及CPU的使用情况。
运行命令
# vmstat 2 10
输出图略
注: 当pi和po为连续非零值时,系统运行速度将会降低。
pi 每秒钟从页空间(Paging Space)调入内存的页面数(4KB/page);
po 每秒钟从内存调入页空间(Paging Space)的页面数;
当进程请求的内存页面数大于内存中可用页面数时, 一些内存页会被换出内存, 存放于系统页空间(Paging Space)中, 以后使用时再调入内存。由于访问页空间中页面的速度远小于对内存页面的访问速度,所以频繁的换页会降低系统运行速度。
注: 当fr和sr的数值增大时,sample明内存负载增大。
fr 为填充内存空闲sample或分配给某进程所需要释放的内存页面;
sr 为得到fr数量的空闲页面所需要检查的页面数;
fr/sr比例为1:4sample明每释放一个内存页面需要检查四个页面。
当po*SYS>fr(SYS为一系统参数,可用命令schedtune查看)时,系统自身认为已到崩溃边缘。SYS在有128MB或更多内存的系统上默认值为0, sample示禁止内存加载控制,否则默认值为6。系统崩溃sample明此时系统使用大量时间用于内存换入/换出,而没有足够时间处理应用或正常工作。这时一些进程将被临时挂起,系统运行明显减慢。
OPTIONS
The following options are supported:
-c Report cache flushing statistics. By default, report
the total number of each kind of cache flushed since
boot time. The types are: user, context, region, seg-
ment, page, and partial-page.
-i Report the number of interrupts per device. count and
interval does not apply to the -i option.
-p Report paging activity in details. This option will
display the following, respectively:
epi Executable page-ins.
epo Executable page-outs.
epf Executable page-frees.
api Anonymous page-ins.
apo Anonymous page-outs.
apf Anonymous page-frees.
fpi File system page-ins.
fpo File system page-outs.
fpf File system page-frees.
-s Display the total number of various system events
since boot. count and interval does not apply to the
-s option.
-S Report on swapping rather than paging activity. This
option will change two fields in vmstat's ``paging''
display: rather than the ``re'' and ``mf'' fields,
vmstat will report ``si'' (swap-ins) and ``so''
(swap-outs).
6、netstat -i
命令结果显示了在每一个接口发送和接收数据包的情况,其中的3项:ierrs、oerrs and collis与网络性能问题有关:
ierrs,是指主机从网络接收数据包中包含有多少不正确的数据包,如果ierrs很大,通常表明硬件接口存在问题或硬件驱动器接受数据包较慢,此时应该在不同时间多次采集数据进行比较来决定采取什么措施。正常情况下,ierrs/opkts<
0.025%.
oerrs,是指主机从网络送出的数据包中包含有多少不正确的数据包。正常情况下oerrs/ipkts< 0.025%.
collis,碰撞是在局域网中有两面三刀个或以上系统同时发送数据时产生的,如果碰撞率(collis/opkts)大于5%,说明网络负荷过大。此时应该调整网络结构,减少网络流量。
7、sar命令的使用
1. 成为超级用户
2. 编辑/etc/init.d/perf 件并且不注释所有行
3. 编辑/var/spool/cron/crontabs/sys 文件(the system crontab file) 并且不注释以下行:
# 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
The first entry writes a record to /var/adm/sa/sadd on the hour, every hour,
seven days a week.
The second entry writes a record to /var/adm/sa/sadd twice each hour during
peak working hours: at 20 minutes and 40 minutes past the hour, from
p.m., Monday through Friday.
Thus, these two crontab entries cause a record to be written to
/var/adm/sa/sadd every 20 minutes from
Friday, and every hour on the hour otherwise. You can change these defaults to
meet your needs.