while searching for a way to get the information if there is still someone connected to a Cisco router (without connecting myself) I found How To Get Information About Users Connected To The TTY By Using SNMP .
I added some configuration to the router:
access-list 60 remark protect snmp access-list 60 permit 192.168.1.0 0.0.0.255 ! snmp-server community private RW 60 snmp-server community public RO 60
Beware: The community strings are an example and shouldn’t be used on real equipment or outside a test lab!
While I was connected (from another session) to the console port of the router I tried to look for tsLineActive (that means: actice lines on the router).
crissa@unseen:~$ snmpwalk -v 2c -c public 192.168.1.250 220.127.116.11.18.104.22.168.22.214.171.124 SNMPv2-SMI::enterprises.126.96.36.199.1.1.0 = INTEGER: 1 SNMPv2-SMI::enterprises.188.8.131.52.1.1.1 = INTEGER: 0 SNMPv2-SMI::enterprises.184.108.40.206.1.1.2 = INTEGER: 0 [...]
Double check on the router.
router#who Line User Host(s) Idle Location * 0 con 0 cisco idle 00:00:00 Interface User Mode Idle Peer Address
But I just need the value of the used ports.
crissa@unseen:~$ snmpwalk -v 2c -c public 192.168.1.250 220.127.116.11.18.104.22.168.22.214.171.124 | grep "INTEGER: 1" | wc -l 1
If you know how to ask it is easy to get the information you need! Without SNMP the only way to get this information is to connect to the router and to use the command “who” or “show user”.