Chinaunix首页 | 论坛 | 博客
  • 博客访问: 41442
  • 博文数量: 11
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 130
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-24 12:37
文章分类
文章存档

2006年(11)

我的朋友
最近访客

分类:

2006-01-24 12:40:05

一、常用命令
date    //显示日期
prtconf -v    //显示系统内存的大小并报告有关外围设备的信息
psrinfo -v    //显示有关处理器的信息
showrev –p   //报告已安装了哪些修补程序
scinstall -pv    //显示Sun Cluster 软件发行版本和软件包版本信息
scstat     //提供群集状况的快照
scconf –p     //列出群集配置信息
scrgadm -p      //显示有关安装的资源、资源组和资源类型的信息
/usr/platform/sun4u/sbin/prtdiag -v   //显示配置信息(CUP,内存,I/O设备)、系统诊断信息、环境状态
uptime   //显示运行时间与CPU的平均负载
mpstat –p 5 120 >;mpstat     //统计10分钟CPU的负载状态
kstat >;outputlog   //输出硬件细节
swap –s    //显示swap使用情况
df –h    //显示磁盘使用情况
prtvtoc /dev/rdsk/c0t0d0s2    //显示磁盘的分区情况
iostat 5 120 >;iostatlog    //统计10分钟内的磁盘利用信息
iostat –xtc 5 120 >;iostatElog   //统计10分钟内的扩展磁盘信息
vmstat 5 120 >;vmstatlog    //显示10分钟内的虚拟内存使用情况、CPU负荷、paging、系统调用等等
vmstat –s     //显示系统环境信息
vmstat –c 5 120 >;vmstatClog   //显示缓存信息
vmstat –i   //显示给设备的中断信号量
sar –a 5 120 >;saralog   //统计10分钟内显示文件访问操作统计表
sar –b 5 120 >;sarblog //统计10分钟内显示缓冲区行为统计表
sar –c 5 120 >;sarclog   //统计10分钟内显示系统通话统计表
sar –d 5 120 >;sardlog  //统计10分钟内显示磁盘行为统计表
sar –g 5 120 >;sarglog //统计10分钟内显示Page-Out和内存的解除行为(freeing activities)
sar –p 5 120 >;sarplog  //统计10分钟内显示Page-In行为,包括保护和转化错误
sar –k 5 120 >;sarklog  //统计10分钟内显示核心存储器分配(KMA)行为
sar –m 5 120 >;sarmlog  //统计10分钟内显示进程之间通信行为
sar –q 5 120 >;sarqlog //统计10分钟内显示队列占用时平均队列长度和时间百分比
sar –r 5 120 >;sarrlog   //统计10分钟内显示当前未用的内存分页数量和swap文件磁盘块
sar –u 5 120 >;sarulog  //统计10分钟内显示CPU利用率
sar –v 5 120 >;sarvlog  //统计10分钟内显示系统表状态,包括进程表,inode表,文件表和共享内存记录表
sar –w 5 120 >;sarwlog //统计10分钟内显示swap行为,包括交换和开关行为
sar –y 5 120 >;sarylog  //统计10分钟内监视终端设备行为
sar –A 5 120 >;sarAlog  //统计10分钟内显示全部系统性能
netstat –i 30 20 >;netstatlog    //显示10分钟内的网络流量
netstat –s    //.显示UDP,TCP,ICMP,IP协议的状态
last >;lastlog    //输出最近登陆的信息
lastcomm >;lastcommlog   //输出最近操作过的命令

二、日志文件内容

/var/adm/loginlog    //系统错误的登陆信息

/var/adm/sulog      //su命令操作记录

/var/log/syslog      //系统日志

/var/adm/messages,    //记载来自系统核心的各种运行日志,需要每天备份

 

三、每天例行巡查的记录(目测),包括服务器显示灯,风扇是否正常转

 

 

 

备注:

1messages记载来自系统核心的各种运行日志,包括各种精灵,如认证,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,入侵者也许会删掉messagesyslog等日志,但他并不知道实际上他所有的操作都被记录在案,管理员事后只要把commandlog这个文件拷贝到/var/adm下,改为pacct ,同时执行读取命令lastcomm,就一切尽在掌握啦。

 

2. dmesg命令
从错误的日志里面收集诊断信息

3.showrev 命令 [-a]

显示机器和软件的修订信息

 

 

4Iostat参数:

 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    1       c0t0d0

0.3   0.3   9.0   7.3  0.0  0.0    0.0   37.2     0    1       c0t0d0s0

0.0   0.0   0.1   0.5  0.0  0.0    0.0   34.0     0    0       c0t0d0s1

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

 

 

5Vmstat参数

 

vmstat命令用于统计并显示核心线程、虚拟内存、硬盘、中断及CPU的使用情况。
运行命令

 

# vmstat 2 10
输出图略

: pipo为连续非零值时,系统运行速度将会降低。
pi
每秒钟从页空间(Paging Space)调入内存的页面数(4KB/page);
po
每秒钟从内存调入页空间(Paging Space)的页面数;

当进程请求的内存页面数大于内存中可用页面数时, 一些内存页会被换出内存, 存放于系统页空间(Paging Space), 以后使用时再调入内存。由于访问页空间中页面的速度远小于对内存页面的访问速度,所以频繁的换页会降低系统运行速度。


: frsr的数值增大时,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).

 

 

6netstat -i

命令结果显示了在每一个接口发送和接收数据包的情况,其中的3项:ierrsoerrs and collis与网络性能问题有关: 
        ierrs
,是指主机从网络接收数据包中包含有多少不正确的数据包,如果ierrs很大,通常表明硬件接口存在问题或硬件驱动器接受数据包较慢,此时应该在不同时间多次采集数据进行比较来决定采取什么措施。正常情况下,
ierrs/opkts< 
        0.025%. 

        oerrs,
是指主机从网络送出的数据包中包含有多少不正确的数据包。正常情况下
oerrs/ipkts< 0.025%. 

        collis,
碰撞是在局域网中有两面三刀个或以上系统同时发送数据时产生的,如果碰撞率(collis/opkts)大于5%,说明网络负荷过大。此时应该调整网络结构,减少网络流量。

 

7sar命令的使用

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 8 a.m. to 5

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 8 a.m. to 5 p.m., Monday through

Friday, and every hour on the hour otherwise. You can change these defaults to

meet your needs.

阅读(1142) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~