JunOS:我可以有一个实时控制台日志吗?


10

在Cisco IOS设备上,该命令logging buffered 51200 notifications会将大多数信息记录到路由器内存中(显然,您可以将其更改为informationaldebugging根据需要进行更改)。

通过telnet或SSH连接到路由器后,我可以执行命令terminal monitorterm mon)使这些事件实时显示在会话中。通过控制台连接时,这会自动发生。

如何在JunOS上实现相同的效果;例如,当我添加IGP / EGB邻居时,我希望看到新的邻接关系,而不是不断查看日志。


4
怎么样start shell,然后tail -f <logfile> | grep <interesting-pattern-here>
迈克彭宁顿

这是否意味着我现在必须与路由器打开两个会话,一个会话监视尾部输出,另一个会话以交互方式配置设备?
jwbensley13年

Answers:


12

“监视启动消息”大致等于“ term mon”。“ messages”是您要监视的日志文件的名称。

如果没有看到期望的输出,则需要更改“设置配置系统syslog文件X ...”中记录到给定文件的内容。


2
另外,在使用“ monitor start <logfile>”时,可以使用ESC-q暂时禁用输出到控制台。再次使用ESC-q重新启用输出。
塞巴斯蒂安·维辛格

3

见下文:

    [edit protocols bgp]
    root@vr-device# show
    traceoptions {
        file bgp-log;
        flag packets detail;
    }
    group test {
        type external;
        peer-as 2;
        local-as 1;
        neighbor 172.16.12.110;
    }

[编辑协议bgp] root @ vr-device#运行监视器启动bgp-log

[bgp编辑协议] root @ vr-device#

    *** bgp-log ***
    Jun 24 10:58:19.384061 bgp_connect_complete: error connecting to 172.16.12.110              
    (External AS 2): Socket is not connected
    Jun 24 10:58:33.408670
    Jun 24 10:58:33.408670 BGP RECV 172.16.12.110+54592 -> 172.16.12.128+179
    Jun 24 10:58:33.408790 BGP RECV message type 1 (Open) length 59
    Jun 24 10:58:33.408792 BGP RECV version 4 as 2 holdtime 90 id 20.0.0.2 parmlen 30
    Jun 24 10:58:33.408794 BGP RECV MP capability AFI=1, SAFI=1
    Jun 24 10:58:33.408809 BGP RECV Refresh capability, code=128
    Jun 24 10:58:33.408811 BGP RECV Refresh capability, code=2
    Jun 24 10:58:33.408920 BGP RECV Restart capability, code=64, time=120, flags=
    Jun 24 10:58:33.408922 BGP RECV 4 Byte AS-Path capability (65), as_num 2
    Jun 24 10:58:33.409054 advertising graceful restart receiving-speaker-only capability to neighbor 172.16.12.110 (External AS 2)
    Jun 24 10:58:33.409056 bgp_send: sending 59 bytes to 172.16.12.110 (External AS 2)
    Jun 24 10:58:33.409058
    Jun 24 10:58:33.409058 BGP SEND 172.16.12.128+179 -> 172.16.12.110+54592
    Jun 24 10:58:33.409060 BGP SEND message type 1 (Open) length 59
    Jun 24 10:58:33.409062 BGP SEND version 4 as 1 holdtime 90 id 192.168.11.3 parmlen 30
    Jun 24 10:58:33.409064 BGP SEND MP capability AFI=1, SAFI=1
    Jun 24 10:58:33.409066 BGP SEND Refresh capability, code=128
    ...

运行监视器停止


1
杜松中的traceoptions类似于cisco中的调试,因此如果停止故障排除,则应将其关闭
Milan Prpic

2
@MilanPrpic ACK,如果您由于RPD的精心设计而导致调度程序延误,并且启用了traceoptions,JTAC将建议您使用RPD延误的原因(因为写入文件I / O可能对RPD调度有问题)
ytti

0

监视带有协议的接口的流量,并将其发送到pwire文件,就像wireshark一样,通常在var / log目录中。

monitor traffic interface ge-0/0/0
monitor interface ge-0/0/0
monitor traffic interface ge-0/2/3 matching "proto 89" write-file ospf.cap - matches proto 89 and writes it in ospf.cap
show security flow session ... options

#set system syslog file messages any info – to save all log messages to file “messages”

显示所有日志消息-

show log messages | match LOGIN | match “Mar 16”
file list detail /var/log = ls –al (to see permitions, etc.)
clear log messages  - to clear the contents of the messages file

monitor start       messages  - live monitoring of messages file
monitor list
monitor stop – to stop all

有关流程级别的更多详细信息,请在流程级别下进行:

#set traceoptions file filenamefil world-readable
#set traceoptions flag all

罗恩的评论是正确的,比我的简短回答更为详尽。很好的例子,我喜欢您使用了某些选项,并且开关使用了启用监视特定协议的语法,并且| 与MAR 16.
泰-史密斯
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.