Sunday, March 14, 2010

IOS: “Terminal Monitor” on, Off — Logging to Your Terminal

September 17, 2009 by Greg Ferro · 1 Comment 

This Post is Part of a Series — click for list on Console Mastery»

I don’t get asked about this quite so much since the Cisco CCNA added this to the cur­riculum but there are some people who may not have been pay­ing atten­tion (or learned by short­cut) and this is for them. In fact, there is more detail here about the ter­minal mon­it­or­ing than you really wanted to know.

Logging to your Terminal

By default, Cisco IOS does not send log mes­sages to a ter­minal ses­sion over IP, that is, tel­net or SSH con­nec­tions don’t get log mes­sages. Console con­nec­tions on a serial cable do have log­ging enabled by default.

Syntax

If you don’t under­stand the dif­fer­ence between Console, Terminal and Monitor then you should read
this art­icle which dis­cusses it in detail.

Check your cur­rent logging

You can see the cur­rent log­ging status by using the ‘show log­ging’ com­mand on this switch I have handy:

s1#sh logging
Syslog logging: enabled (0 messages dropped, 0 messages rate-limited, 0 flushes, 0 overruns, xml disabled, filtering disabled)

No Active Message Discriminator.
No Inactive Message Discriminator.
Console logging: level debugging, 1002228 messages logged, xml disabled,
filtering disabled
Monitor logging: level debugging, 1 messages logged, xml disabled,
filtering disabled
Buffer logging: level debugging, 1002228 messages logged, xml disabled,
filtering disabled
Exception Logging: size (4096 bytes)
Count and timestamp logging messages: disabled
File logging: disabled
Persistent logging: disabled

No act­ive fil­ter modules.

Trap log­ging: level inform­a­tional, 1002230 mes­sage lines logged

Log Buffer (4096 bytes)
——Snip——

Yeah, well, I lied about about be able to see it. IOS doesn’t actu­ally tell you that the default con­di­tion is doing any­thing. This is how Cisco IOS does everything, the default doesn’t show up((This rule applies every­where, except where it doesn’t.)). Get over it.

By default the con­sole always gets log mes­sages, so noth­ing shows in the log­ging out­put above. By default the ter­minal doesn’t show log mes­sages and so noth­ing shows int the log­ging out­put above.

Using “ter­minal monitor”

If you want log­ging mes­sages from IOS to appear on the your ter­minal then you need to use the ‘ter­minal mon­itor’ com­mand. You can type it long hand if you like, but every­one shortens this to ‘term mon’ and in con­ver­sa­tion it’s said ‘term mon’ (as in, “go term mon now will you?”).

s1#
s1#term mon

That’s it. Logging to your ter­minal will now occur. Of course, a mes­sage or log has to be hap­pen­ing for a mes­sage to appear. So lets use IOS to tell us that we have con­figured it.

Turning Terminal Logging Off

In a clas­sic moment of IOS mad­ness, if you want to stop log­ging to your terminal:

s1#terminal no monitor

If is was con­sist­ent with everything in IOS, you might expect to use:

s1#no terminal monitor  But you would be wrong. This syntax is very old and predates the more standardised IOS conventions.

Confirming that log­ging is enabled to your terminal

s1#sh logg
Syslog logging: enabled (0 messages dropped, 0 messages rate-limited, 0 flushes, 0 overruns, xml disabled, filtering disabled)

No Active Message Discriminator.

No Inactive Message Discriminator.

Console log­ging: level debug­ging, 1002247 mes­sages logged, xml dis­abled,
fil­ter­ing dis­abled
Monitor log­ging: level debug­ging, 1 mes­sages logged, xml dis­abled,
fil­ter­ing dis­abled
Logging to: vty1(0)
Buffer log­ging: level debug­ging, 1002247 mes­sages logged, xml dis­abled,
fil­ter­ing dis­abled
Exception Logging: size (4096 bytes)
Count and timestamp log­ging mes­sages: dis­abled
File log­ging: dis­abled
Persistent log­ging: dis­abled
No act­ive fil­ter mod­ules.
Trap log­ging: level inform­a­tional, 1002249 mes­sage lines logged
Log Buffer (4096 bytes):

Which leads to the ques­tion — Which ter­minal am I on ?

Use show ter­minal to find out which line your on, and this is teh same num­ber as the vty:

s1#sh terminal
Line 2, Location: "", Type: "LINUX"
Length: 62 lines, Width: 161 columns
Baud rate (TX/RX) is 9600/9600
Status: PSI Enabled, Ready, Active, No Exit Banner, Ctrl-c Enabled
Automore On
Capabilities: none

In this case, you would be on vty2.

Please rate this post:

  Why Rate Posts?
1 Star - It\\\'s Crud2 Stars - It\\\'s Tosh3 Stars - Something\\\'s missing4 Stars - Needs works5 Stars - Good Enough6 Stars - Good7 Stars - Excellent8 Stars - Brilliant9 Stars - Astonishing10 Stars - Awesomely Godlike? (No Ratings Yet)
Loading ... Loading ...

Comments

One Response to “IOS: “Terminal Monitor” on, Off — Logging to Your Terminal”
  1. DaveC says:

    Hi Greg,

    Another nice intro art­icle, how­ever a couple i would like to add a couple of quick points your read­ers may be inter­ested in…

    1) Since writ­ing to the con­sole must occur at it’s con­figured speed (default 9600 bps) this can cause increased in CPU usage(if it sud­denly has to write 000s of mes­sages* at that speed and in each case wait until it has fin­ished wit­ting the last this can cause prob­lems. It is a while since I have seen this on live equip­ment and am unsure if this is due to bet­ter schedul­ing within IOS. However I would still con­sider it good prac­tice to dis­able con­sole log­ging except for a spe­cific purposes.

    2) While not “bet­ter” than the meth­ods above I thought I would men­tion the way I usu­ally check if the (telnet/​shh) ses­sion logged in has log­ging enabled, as an altern­at­ive:
    LabR1SW3#sh term | inc Cap
    Capabilities: Receives Logging Output

    For new Cisco users it prob­ably worth point­ing out the other use­ful items in the sh term out­put as part of your Console Mastery series.

    *e.g. if debug­ging is enabled

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!