07-09-2019 08:21 AM
It took me a long time to figure out how to login to the embedded access point on my IR829 router using the command 'service-module wlan-ap 0'. Once I figured that out I thought I was ok. I didn't realize initially that it only works under certain favorable conditions. I have since found out that when there are no existing sessions and the last state of the connection was user level prior to disconnecting everything works. But if the last session used is disconnected (CTL+SHIFT+6, X) is still in privileged user mode I need to check for that (hence the two different pattern matches for prompt and checking for whether or not I need to enter the enable password). I also need to check for an existing connection and disconnect it. However, it would appear that because the EEM script operates over a VTY line that the EEM script does not "see" the same state that the console does? When I check for an existing session via the EEM script it tells me there is no session to the AP open and tries to connect, only to get refused. When the script exits I am able to verify that there is in fact a session still open. Below is my script config and debug output.
no event manager applet OSPFNeighborDOWN event manager applet OSPFNeighborDOWN event syslog pattern ".*OSPF-5-ADJCHG.*FULL to DOWN.*" maxrun 60 action 001 wait 5 action 010 cli command "enable" action 011 cli command "disconnect" action 012 regexp "confirm" $_cli_result action 013 if $_regexp_result eq 1 action 014 cli command "y" action 015 end action 020 cli command "service-module wlan-ap 0 session\012" pattern "(>|#)" action 030 cli command "enable" action 031 regexp "Password:" $_cli_result action 032 if $_regexp_result eq 1 action 040 cli command "Cisco" pattern "#" action 041 end action 042 cli command "terminal length 0" pattern "#" action 050 cli command "show interface Dot11Radio1" pattern "#" action 060 regexp "Dot11Radio1 is down, line protocol is down" $_cli_result action 070 if $_regexp_result eq 1 action 071 syslog msg "5 GHz radio is down. Enabling guest WiFi." action 080 cli command "config t" pattern "#" action 090 cli command "interface dot110" pattern "#" action 100 cli command "no shut" pattern "#" action 110 cli command "end" pattern "#" action 111 cli command "terminal length 24" pattern "#" action 120 cli command "wr" pattern "#" action 130 end no event manager applet OSPFNeighborUP event manager applet OSPFNeighborUP event syslog pattern ".*OSPF-5-ADJCHG.*LOADING to FULL.*" maxrun 60 action 001 wait 5 action 010 cli command "enable" action 011 cli command "disconnect" action 012 regexp "confirm" $_cli_result action 013 if $_regexp_result eq 1 action 014 cli command "y" action 015 end action 020 cli command "service-module wlan-ap 0 session\012" pattern "(>|#)" action 030 cli command "enable" action 031 regexp "Password:" $_cli_result action 032 if $_regexp_result eq 1 action 040 cli command "Cisco" pattern "#" action 041 end action 042 cli command "terminal length 0" pattern "#" action 050 cli command "show interface Dot11Radio1" pattern "#" action 060 regexp "Dot11Radio1 is up, line protocol is up" $_cli_result action 070 if $_regexp_result eq 1 action 071 syslog msg "5 GHz radio is up. Disabling guest WiFi." action 080 cli command "config t" pattern "#" action 090 cli command "interface dot110" pattern "#" action 100 cli command "shut" pattern "#" action 110 cli command "end" pattern "#" action 111 cli command "terminal length 24" pattern "#" action 120 cli command "wr" pattern "#" action 130 end end
The script is triggered by OSPF up/down events
*Jul 9 14:25:10.676: %OSPF-5-ADJCHG: Process 10, Nbr 10.1.121.1 on Vlan1 from LOADING to FULL, Loading Done LAB# *Jul 9 14:25:15.708: %HA_EM-6-LOG: OSPFNeighborUP : DEBUG(cli_lib) : : CTL : cli_open called. *Jul 9 14:25:15.708: %HA_EM-6-LOG: OSPFNeighborUP : DEBUG(cli_lib) : : OUT : LAB> *Jul 9 14:25:15.708: %HA_EM-6-LOG: OSPFNeighborUP : DEBUG(cli_lib) : : IN : LAB>enable *Jul 9 14:25:15.718: %HA_EM-6-LOG: OSPFNeighborUP : DEBUG(cli_lib) : : OUT : LAB#
The EEM script doesn't see that there is an existing connection indicated by the '% No current connection' response
*Jul 9 14:25:15.718: %HA_EM-6-LOG: OSPFNeighborUP : DEBUG(cli_lib) : : IN : LAB#disconnect *Jul 9 14:25:15.828: %HA_EM-6-LOG: OSPFNeighborUP : DEBUG(cli_lib) : : OUT : % No current connection
The script tries to login to the AP, only to get refused due to the current session
*Jul 9 14:25:15.828: %HA_EM-6-LOG: OSPFNeighborUP : DEBUG(cli_lib) : : IN : LAB#service-module wlan-ap 0 session *Jul 9 14:25:15.828: %HA_EM-6-LOG: OSPFNeighborUP : DEBUG(cli_lib) : : IN : *Jul 9 14:25:15.938: %HA_EM-6-LOG: OSPFNeighborUP : DEBUG(cli_lib) : : OUT : Trying 192.168.254.1, 2004 ... *Jul 9 14:25:15.938: %HA_EM-6-LOG: OSPFNeighborUP : DEBUG(cli_lib) : : OUT : % Connection refused by remote host ...snip... *Jul 9 14:25:16.168: %HA_EM-6-LOG: OSPFNeighborUP : DEBUG(cli_lib) : : CTL : cli_close called. *Jul 9 14:25:16.168: *Jul 9 14:25:16.168: tty is now going through its death sequence
Once the script has died you can see that there was in fact a session still open
LAB#show session Conn Host Address Byte Idle Conn Name * 1 192.168.254.1 192.168.254.1 64 1 192.168.254.1 LAB#disconnect Closing connection to 192.168.254.1 [confirm] LAB#
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide