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

网络工程 瞻博网络
2021-07-14 18:45:56

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

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

我怎样才能在 JunOS 上达到同样的效果;例如,当我添加 IGP/EGB 邻居时,我希望看到新的邻接出现,而不是不断查看日志。

3个回答

'monitor start messages' 大致相当于'term mon。'messages' 是您要监控的日志文件的名称。

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

见下文:

    [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# run monitor start 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
    ...

运行监控停止

使用协议监控接口的流量,将其发送到类似于wireshark的pcap文件,通常在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