Guest

IP Application Services

How To Get Information About Users Connected To The TTY By Using SNMP

Document ID: 45281

Updated: Oct 26, 2005

   Print

Introduction

This document describes how you can retrieve information about users connected to the TTY lines on a Cisco device with the help of Simple Network Management Protocol (SNMP). This document also explains all possible object identifiers (OIDs) and how to clear a specific TTY line with SNMP.

Prerequisites

Requirements

Before you use the information in this document, make sure that you meet these requirements:

  • Understand how to view TTY information on Cisco devices .

  • General use of SNMP walk, get, and set commands.

  • Understand how to configure SNMP on a Cisco device.

Components Used

This document applies to Cisco routers and switches running a regular Catalyst operating system (OS) or Catalyst IOS that supports the OLD-CISCO-TS-MIB.

Note: The OLD-CISCO-TS-MIB is not loaded by default in NET-SNMP. If the Management Information Base (MIB) is not loaded on your system, you must use the OID instead of the object name.

The information in this document is based on the software and hardware versions listed here:

The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, make sure that you understand the potential impact of any command.

Conventions

For more information on document conventions, refer to the Cisco Technical Tips Conventions.

Background

Details of the MIB Variables (Includes OIDs)

1.3.6.1.4.1.9.2.9.1 (OLD-CISCO-TS-MIB)
tsLines OBJECT-TYPE
                   SYNTAX  INTEGER
                   ACCESS  read-only
                   STATUS  mandatory
                   DESCRIPTION "Number of terminal lines on this device. Includes virtual lines."
                   ::= { lts 1 }


1.3.6.1.4.1.9.2.9.2.1.1 (OLD-CISCO-TS-MIB)
tsLineActive OBJECT-TYPE
                   SYNTAX  INTEGER
                   ACCESS  read-only
                   STATUS  mandatory
                   DESCRIPTION "Boolean whether this line is active or not."
                   ::= { ltsLineEntry 1 }


1.3.6.1.4.1.9.2.9.2.1.2 (OLD-CISCO-TS-MIB)
tsLineType OBJECT-TYPE
                   SYNTAX  INTEGER {
                        unknown(1),
                        console(2),
                        terminal(3),
                        line-printer(4),
                        virtual-terminal(5),
                        auxiliary(6)
                   }
                   ACCESS  read-only
                   STATUS  mandatory
                   DESCRIPTION "Type of line."
                   ::= { ltsLineEntry 2 }



1.3.6.1.4.1.9.2.9.2.1.21 (OLD-CISCO-TS-MIB)
tsLineTimeActive OBJECT-TYPE
                   SYNTAX  INTEGER
                   ACCESS  read-only
                   STATUS  mandatory
                   DESCRIPTION "The time in seconds since line was activated."
                   ::= { ltsLineEntry 21 }


1.3.6.1.4.1.9.2.9.2.1.18 (OLD-CISCO-TS-MIB)
tsLineUser OBJECT-TYPE
                   SYNTAX  DisplayString
                   ACCESS  read-only
                   STATUS  mandatory
                   DESCRIPTION "TACACS user name,if TACACS is enabled, of user on this line."
                   ::= { ltsLineEntry 18 }


1.3.6.1.4.1.9.2.9.4 (OLD-CISCO-TS-MIB)
tsMsgTtyLine OBJECT-TYPE
                   SYNTAX  INTEGER
                   ACCESS  read-write
                   STATUS  mandatory
                   DESCRIPTION "tty line to send the message to. -1 sends the messages to all tty lines."
                   ::= { lts 4 }


1.3.6.1.4.1.9.2.9.10 (OLD-CISCO-TS-MIB)
tsClrTtyLine OBJECT-TYPE
                   SYNTAX  INTEGER
                   ACCESS  read-write
                   STATUS  mandatory
                   DESCRIPTION "tty line to clear. Read returns the last line cleared.
																		 A value of -1 indicates no lines have been cleared."
                   ::= { lts 10 }

Obtain TTY Information with SNMP

Step-by-Step Instructions

The values in the example are as follows:

  • Device hostname = ponch

  • Read community = public

  • Write community = private

  1. Replace the community strings and the hostname in the these commands.

    • To find the available number of TTY lines (that includes the virtual ones), query the object tsLines:

      snmpwalk -c public ponch tsLines
      cisco.local.lts.tsLines.0 : INTEGER: 135
      
    • To list active TTY lines query the tsLineActive object. The active TTY lines return 1:

      snmpwalk -c public ponch tsLineActive
      cisco.local.lts.ltsLineTable.ltsLineEntry.tsLineActive.0 : INTEGER: 1
      cisco.local.lts.ltsLineTable.ltsLineEntry.tsLineActive.129 : INTEGER: 0
      cisco.local.lts.ltsLineTable.ltsLineEntry.tsLineActive.130 : INTEGER: 1
      …
      
  2. Verify this with the show users command on the command-line interface (CLI) of the router:

    ponch#sh users
        Line       User       Host(s)              Idle       Location
       0 con 0                idle                 15:32:49
    *130 vty 0                idle                 00:00:00 10.61.64.9
    
      Interface      User        Mode                     Idle     Peer Address
    
    • To obtain the type of line, query the tsLineType object. This shows how the user is connected:

      • unknown(1)

      • console(2)

      • terminal(3)

      • line-printer(4)

      • auxiliary(6)

      snmpwalk -c public ponch tsLineType
      cisco.local.lts.ltsLineTable.ltsLineEntry.tsLineType.0 : INTEGER: console
      cisco.local.lts.ltsLineTable.ltsLineEntry.tsLineType.129 : INTEGER: auxiliary
      cisco.local.lts.ltsLineTable.ltsLineEntry.tsLineType.130 : INTEGER: virtual-terminal
      …
      
    • To determine whether the time line is been active,query the tsLineTimeActive object. This is the time in seconds since the line was activated:

      snmpwalk -c public ponch tsLineTimeActive
      cisco.local.lts.ltsLineTable.ltsLineEntry.tsLineTimeActive.0 : INTEGER: 172351
      cisco.local.lts.ltsLineTable.ltsLineEntry.tsLineTimeActive.129 : INTEGER: 0
      cisco.local.lts.ltsLineTable.ltsLineEntry.tsLineTimeActive.130 : INTEGER: 9069
      …
      
    • To see who is connected to a TTY, you must be connected to the device through TACACS. Query the tsLineUser object to find the user name:

      Note:  If you are NOT connected through TACACS, then tsLineUser is empty!

      snmpwalk -c public ponch tsLineUser
      cisco.local.lts.ltsLineTable.ltsLineEntry.tsLineUser.0 : DISPLAY STRING- (ascii):
      cisco.local.lts.ltsLineTable.ltsLineEntry.tsLineUser.129 : DISPLAY STRING- (ascii):
      cisco.local.lts.ltsLineTable.ltsLineEntry.tsLineUser.131 : DISPLAY STRING- (ascii): cisco
      …
  3. Compare this sample output to your CLI command show users output:

    ponch#sh users
        Line       User       Host(s)              Idle       Location
       0 con 0                idle                 15:32:49
    *131 vty 0     cisco      idle                 00:00:00 10.61.64.11
    
    
      Interface      User        Mode                     Idle     Peer Address
    
    

Clear a VTY Session with SNMP

Step-by-Step Instructions

You can clear a telnet (VTY) session with SNMP. The SNMP command is the equivalent of the clear line vty <number> command. The object used to clear a line is tsClrTtyLine.

  1. Use SNMP to clear VTY line 132 with these commands:

    snmpset -c private ponch tsClrTtyLine.0 integer 132
    cisco.local.lts.tcClrTtyLine.0 : INTEGER: 132

    or

    snmpset -c private ponch .1.3.6.1.4.1.9.2.9.10.0 integer 132
    enterprises.9.2.9.10.0 = 132
  2. To check this on the router before the line 132 is cleared, issue this command on the CLI:

    ponch#show users
        Line       User       Host(s)              Idle       Location
       0 con 0                idle                 05:23:17
     130 vty 0                idle                    1d03h 144.254.7.118
     131 vty 1                idle                    1d01h 144.254.7.118
     132 vty 2                idle                 00:04:36 144.254.8.54
    *133 vty 3                idle                 00:00:00 144.254.7.53
    
      Interface      User        Mode                     Idle     Peer Address
    
  3. Check the router after you issue this command, to make sure line 132 is cleared:

    ponch#show users
        Line       User       Host(s)              Idle       Location
       0 con 0                idle                 05:26:42
     130 vty 0                idle                    1d03h 144.254.7.118
     131 vty 1                idle                    1d01h 144.254.7.118
    *133 vty 3                idle                 00:00:00 144.254.7.53
    
      Interface      User        Mode                     Idle     Peer Address
    
  4. Line 132 is now cleared.

    Note:  Issue this command carefully because it can disconnect a user from the device without warning!

Related Information

Updated: Oct 26, 2005
Document ID: 45281