Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15165293
  • 博文数量: 7460
  • 博客积分: 10434
  • 博客等级: 上将
  • 技术积分: 78178
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-02 22:54
文章分类

全部博文(7460)

文章存档

2011年(1)

2009年(669)

2008年(6790)

分类: 系统运维

2008-05-24 23:37:20

18.1.  启用本地路由器日志

提问 实现路由器 自身保存日志记录,而不仅仅是显示在终端上

回答

Router#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#logging buffered informational

Router(config)#end

Router#

注释 缺省日志记录为debugging级别,例子中为informational忽略掉了debug消息。禁用使用下面命令

Router#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no logging buffered

Router(config)#end

Router#

 

18.2.  设定日志记录大小

提问 改变路由器保存日志记录的大小

回答

Router#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#logging buffered 16000

Router(config)#end

Router#

注释 要注意的是改变了大小后,原有的日志记录会被清除。

18.3.  清除路由器日志记录

提问 清除路由器日志记录

回答

Router#clear logging

Clear logging buffer [confirm]

Router#

注释

18.4.  发送日志到屏幕显示

提问 在终端屏幕实时显示日志记录

回答

启用

Router#terminal monitor

Router#

禁用

Router#terminal no monitor

Router#

注释 缺省情况下日志记录只会在console端显示,要在VTY会话显示就必须使用上述命令

18.5.  使用远端日志服务器

提问 发送日志记录到远端日志服务器

回答

Router#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#logging 172.25.1.1

Router(config)#end

Router#

12.2(15)T后也可以使用下面命令格式

Router2#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router2(config)#logging host 172.25.1.1

Router2(config)#end

Router2#

注释 12.2(15)T后增加了一个特性可以使发送的记录中包含了主机名,下面这是原始的日志记录

Jul 15 20:35:07 172.25.1.100: Jul 15 20:35:07.499 EDT: %SYS-5-CONFIG_I: Configured from console by ijbrown on vty0 (172.25.1.1)

下面这个是使用特性后的记录

Jul 15 20:37:05 172.25.1.100: Router2: Jul 15 20:37:05.173 EDT: %SYS-5-CONFIG_I: Configured from console by ijbrown on vty0 (172.25.1.1)

配置方法Router2#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router2(config)#logging origin-id hostname

Router2(config)#end

Router2#

18.6.  Unix服务器上启用Syslog服务

提问 配置Unix服务器接收syslog记录

回答

一般只需要在/etc/syslog.conf

local7.info                                     /var/log/rtrlog

注释 缺省情况路由器使用local7 logging facility

18.7.  修改缺省Log Facility

提问 修改缺省Log Facility

回答

Router#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#logging host 172.25.1.1

Router(config)#logging facility local6

Router(config)#end

Router#

注释

18.8.  限制特定日志记录发送至服务器

function ImgZoom(Id)//重新设置图片大小 防止撑破表格 { var w = $(Id).width; var m = 550; if(w < m) { return; } else { var h = $(Id).height; $(Id).height = parseInt(h*m/w); $(Id).width = m; } } window.onload = function() { var Imgs = $("content").getElementsByTagName("img"); var i=0; for(;i ILY: 宋体">提问 限制特定等级的日志记录发送至服务器

回答

Router#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#logging host 172.25.1.1

Router(config)#logging trap notifications

Router(config)#end

Router#

注释

18.9.  设定Syslog消息的源地址

提问 路由器Syslog消息的源地址使用特定地址

回答

Router#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#logging host 172.25.1.1

Router(config)#logging source-interface Loopback0

Router(config)#end

Router#

注释 这样如果在日志服务器上设置了地址翻译就可以实现下述的效果

Apr  2 20:27:01 172.25.2.6 94: %SYS-5-CONFIG_I: Configured from on vty0

Apr  2 20:27:48 Boston 95: %SYS-5-CONFIG_I: Configured from on vty0

18.10.  记录路由器日志记录到不同的文件

注释

18.11.  维护服务器上的日志记录

注释 使用脚本实现日志记录的自动存档等功能

18.12.  测试日志服务器的配置

注释 使用脚本来测试日志服务器的配置是否正确

18.13.  避免常见的消息被记录

提问 在日志记录中禁止一些常见的端口状态等消息

回答

Router#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#interface Serial0/0

Router(config-if)#no logging event link-status

Router(config-if)#no logging event dlci-status-change

Router(config-if)#no logging event subif-link-status

Router(config-if)#exit

Router(config)#end

Router#

注释

18.14.  日志记录的流量控制

提问 限制发送到服务器的日志流量

回答

Router#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#logging host 172.25.1.1

Router(config)#logging rate-limit 30 except warnings

Router(config)#end

Router#

对控制台口的日志记录数目控制

Router#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#logging rate-limit console 25 except warnings

Router(config)#end

Router#

注释

18.15.  启用日志统计

提问 统计路由器日志的类型和数目

回答

Router2#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router2(config)#logging count

Router2(config)#end

Router2#

注释

Router2#show logging count

Facility       Message Name                     Sev Occur      Last Time

==================================================================================

NTP            PEERREACH                          6    3 Jul 13 20:31:34.441      

NTP            PEERSYNC                           5    1 Jul 13 20:23:03.571      

NTP            PEERUNREACH                        4    3 Jul 13 20:22:00.435      

NTP            RESTART                            6    1 Jan 31 14:13:33.769      

-------------  -------------------------------  ----------------------------------

NTP TOTAL                                              8

 

18.16.  生成XML格式的日志记录

提问 XML格式来发送日志

回答

Router2# configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router2(config)#logging console xml

Router2(config)#logging monitor xml

Router2(config)#logging buffered xml

Router2(config)#logging host 172.25.1.1 xml

Router2(config)#end

Router2#

注释 12.2(15)T引入此特性,方便后处理

18.17.       修改日志记录

提问 希望修改系统日志记录的一些属性

回答

首先要写特定的TCL脚本(delcounters.tcl 脚本用于过滤掉包含counters的日志)

# delcounters.tcl  This script deletes all log messages that

#                   have the mnemonic "COUNTERS".

if { [string compare -nocase COUNTERS $::mnemonic ] == 0 } {

return ""

} else {

return $::orig_msg

}

然后引用此脚本

Router2#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router2(config)#logging filter tftp://172.25.1.1/delcounters.tcl

Router2(config)#logging host 172.25.1.1 filtered

Router2(config)#end

Router2#

注释 Embedded Syslog Manager (ESM) 引自12.3(2)T,提供一个程序化的接口可以对日志进行过滤,修改等全面控制,主要是使用TCL脚本来进行控制。

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