[j-nsp] why is "show log messages | last 10" so slow?
Phil Shafer
phil at juniper.net
Tue Oct 30 10:23:15 EDT 2018
Saku Ytti writes:
>The 'last 50' is purely CLI construct. The
>designers could have chosen that 'last N' is passed to RPC always as
>an argument, and never implemented in CLI, and each RPC call has to
>implement it. It is debatable which is the right call.
That's fairly accurate. Most of the UI pipes are implemented in
the CLI, allowing them to be used interactively, like the "m"
keystroke at the automore prompt being equivalent to the "match"
pipe, "e" == "except", etc:
---(Help for CLI automore)---
Clear all match and except strings: c or C
Display all line matching a regexp: m or M <string>
Display all lines except those matching a regexp: e or E <string>
Display this help text: h
Don't hold in automore at bottom of output: N
Hold in automore at bottom of output: H
Move down half display: TAB, d, or ^D
Move down one line: Enter, j, ^N, ^X, ^Z, or Down-Arrow
Move down one page: Space, f, ^F, or Right-Arrow
Move to bottom of output: G, ^E, or End
Move to top of output: g, ^A, or Home
Move up half display: u or ^U
Move up one line: k, Delete, Backspace, ^P, or Up-Arrow
Move up one page: b, ^B, or Left-Arrow
Quit automore: q, Q, ^K
Redraw display: ^L or ^R
Repeat a keystroke command 1 to 9 times: Meta-1..9
Repeat last search: n
Save output to a file: s or S <filename/url>
Search backwards thru the output: ?<string>
Search forwards thru the output: /<string>
---(End of Help)---
FWIW, I use this extensively to match/except my way to the source of
a problem, then clear to see the complete log.
For "last", this isn't really vital, but it's worth notice that the
display is really showing the <n> lines of the display, but the
complete display is buffered and available in automore, so you can
page backward ("b") through it. This means it's more like the G
in more/less, that "tail".
It also means the CLI goes thru the cost of recording the complete
input data set. If you want to avoid this cost, use the "no-more"
pipe:
user at cli> show log messages | last 5 | no-more
Oct 30 09:52:55 mgd[38686]: UI_DBASE_LOGIN_EVENT: User 'phil' entering configuration mode
Oct 30 09:52:59 mgd[38686]: UI_DBASE_LOGOUT_EVENT: User 'phil' exiting configuration mode
Oct 30 10:00:36 hassisd[4105]: CHASSISD_SNMP_TRAP6: SNMP trap generated: Power Supply failed (jnxContentsContainerIndex 2, jnxContentsL1Index 1, jnxContentsL2Index 0, jnxContentsL3Index 0, jnxContentsDescr PEM 0, jnxOperatingState/Temp 6)
Note that this tosses you back to the CLI prompt instead of keeping
you at the automore prompt.
Thanks,
Phil
More information about the juniper-nsp
mailing list