cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

EEM TCL Script to Provide LTE status, GPS and Ping results via SMS Text Message (sms_lte_sgp.tcl)

7280
Views
5
Helpful
2
Comments

This tcl script applies to Cisco ISRs running IOS 15.3(3)M1 or later, and 15.4(1)T or later that have an embedded LTE interface - C819(H)G-4G or LTE eHWIC).  For GPS output, a GPS antenna is required.  The following document can assist with ISR GPS deployment: 

http://www.cisco.com/en/US/docs/routers/access/interfaces/software/deployment/guide/guide_120913.pdf

The tcl script leverages IOS EEM to allow for receiving status information via SMS text messages.  Included in this script is the ability to provide information about LTE radio signal and connection, GPS coordinates, and reachability via ping.  This is done by sending a text message to the phone number (e.g. MDN or MS-ISDN) associated with the 4G SIM in the ISR.

To install the script:

- Download the tcl file

- Copy the tcl file onto the ISR flash (via USB, TFTP, FTP)

- Insert the following IOS commands into the ISR running configuration

  - event manager directory user policy "flash:/"

  - event manager policy sms_lte_sgp.tcl type user

To test the script:

- determine the phone number of the SIM in the ISR via the following IOS command

  - for C819G-4G:  show cell 0 hard | i ISDN

  - for LTE eHWIC: show cell 0/x/0 | i ISDN   (where x is the slot number, found by from "show ip int brief | i Cell"

- send a text message to the phone number with only one of the following per text:

  - status

  - gps

  - ping <ip address or host@domain> (e.g. 192.168.1.1 or device@yourdomain.com)

_____________________________________________________________________________________________________________

Below is sample output from an 819 ISR configured with the sms_lte_sgp.tcl script:

C819H2#dir flash: | i tcl

  241  -rw-        2811  Nov 18 2013 09:54:44 -05:00  gps_time.tcl

  249  -rw-         648  Oct 10 2013 14:35:54 -04:00  GPS_TRACK_BASIC.tcl

  257  -rw-        4937  Dec 10 2013 11:49:22 -05:00  findmyrouter.tcl

  259  -rw-        5937   Jan 9 2014 11:01:42 -05:00  sms_lte_sgp.tcl

C819H2#

C819H2#sh run | s event man

event manager directory user policy "flash:/"

event manager policy findmyrouter.tcl type user

event manager policy sms_lte_sgp.tcl type user

C819H2#

C819H2#sh event man pol reg

No.  Class     Type    Event Type          Trap  Time Registered           Name

1    script    user    timer cron          Off   Tue Dec 24 09:34:08 2013  findmyrouter.tcl

name {findmyrouter.tcl} cron entry {0 * * * *}

nice 0 queue-priority normal maxrun 55.000 scheduler rp_primary Secu none

2    script    user    syslog              Off   Thu Jan 9 11:02:23 2014   sms_lte_sgp.tcl

pattern { New SMS received on index .*}

nice 0 queue-priority normal maxrun 120.000 scheduler rp_primary Secu none

C819H2#

C819H2#sh cell 0 hard | i ISDN

IDentity Number (MSISDN) = 1xxx694yyyy

C819H2#

_____________________________________________________________________________________________________________

Below is sample output from each (the texting source is a 1921 with LTE eHWIC, the ISR running the tcl script is an 891G-4G-V-K9):

C1921_pod4#cell 0/0/0 lte sms send xxx694yyyy status

C1921_pod4#

*Jan  9 22:01:12.970: %CELLWAN-2-SMS_ARCH_PATH_UNCONFIGURED: Cellular0/0/0 failed to archive SMS because 'gsm|cdma|lte sms archive path' under cellular controller is not configured.

*Jan  9 22:01:12.970: %CELLWAN-5-OUTGOING_SMS_SENT: Cellular0/0/0 has just sent an outgoing SMS successfully.

*Jan  9 22:01:16.010: Cellular0/0/0: New SMS received on index 5. Please issue a view command to see it

C1921_pod4#cell 0/0/0 lte sms view 5

SMS ID: 5

TIME: 14/01/09 17:00:40

FROM: xxx694yyyy

SIZE: 160

IP address = 10.162.247.16 Current Roaming Status = Home Current Band = LTE Current RSSI = -73 dBm Current RSRP = -102  dBm Current RSRQ = -13  dB Current SNR =

C1921_pod4#

C1921_pod4#cell 0/0/0 lte sms send xxx694yyyy gps

C1921_pod4#

*Jan  9 22:01:59.130: %CELLWAN-2-SMS_ARCH_PATH_UNCONFIGURED: Cellular0/0/0 failed to archive SMS because 'gsm|cdma|lte sms archive path' under cellular controller is not configured.

*Jan  9 22:01:59.130: %CELLWAN-5-OUTGOING_SMS_SENT: Cellular0/0/0 has just sent an outgoing SMS successfully.

*Jan  9 22:02:00.754: Cellular0/0/0: New SMS received on index 6. Please issue a view command to see it

C1921_pod4#

C1921_pod4#cell 0/0/0 lte sms view 6

SMS ID: 6

TIME: 14/01/09 17:01:25

FROM: xxx694yyyy

SIZE: 143

GPS State: GPS enabled Latitude: 40 Deg 6 Min 8 Sec North Longitude: 75 Deg 7 Min 20 Sec West Timestamp (GMT): Thu Jan  9 17:01:22 2014 C819H2#

C1921_pod4#

C1921_pod4#cell 0/0/0 lte sms send xxx694yyyy ping 10.239.249.1

C1921_pod4#

*Jan  9 22:02:45.554: %CELLWAN-2-SMS_ARCH_PATH_UNCONFIGURED: Cellular0/0/0 failed to archive SMS because 'gsm|cdma|lte sms archive path' under cellular controller is not configured.

*Jan  9 22:02:45.554: %CELLWAN-5-OUTGOING_SMS_SENT: Cellular0/0/0 has just sent an outgoing SMS successfully.

*Jan  9 22:02:47.942: Cellular0/0/0: New SMS received on index 7. Please issue a view command to see it

C1921_pod4#

C1921_pod4#cell 0/0/0 lte sms view 7

SMS ID: 7

TIME: 14/01/09 17:02:12

FROM: xxx694yyyy

SIZE: 68

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms

C1921_pod4#

Comments
tavaresbelmont87
Beginner

Hello,

Nice post however when i tried to do this on cisco router C887VAG-4G-GA-K9 does not worked :( and the messages on "terminal monitor" are showed like that bellow:

Jul 15 2016 16:34:34.510 BRST: %CRYPTO-6-IKMP_POLICY_DEFAULT: Using ISAKMP Default policies
Jul 15 2016 16:34:34.554 BRST: Cellular0: New SMS received on index 4. Please issue a view command to see it
Jul 15 2016 16:34:34.878 BRST: %HA_EM-6-LOG: sms_lte_sgp.tcl: interface = Cellular 0
Jul 15 2016 16:34:37.002 BRST: %HA_EM-6-LOG: sms_lte_sgp.tcl: Successfully deleted SMS message 4 from SIM

Any tips?

Thanks!

davidfarley
Beginner

I don't mean to dig up an old thread but I also came across the same problem as tavaresbelmont87 on the ISR4000 series routers and thought this might help others looking for the fix. I discovered that the date format had changed for "cell 0/1/0 lte sms view summary" output which broke the regex looking for the phone number. Old IOS had "/" between the day/month/year whereas the new code used "-" as the separator.

 

The original string in the script is:

 

if {[regexp -nocase [subst -nocommands -nobackslashes {$index\s+(\d+)\s+[\d/]+\s+[\d:]+\s+\d+\s+([A-Za-z0-9]+.*)}] $line match phonenumber cmd ]} {

 

 

When I changed it to the following it started working: if {[regexp -nocase [subst -nocommands -nobackslashes {$index\s+(\d+)\s+[\d-]+\s+[\d:]+\s+\d+\s+([A-Za-z0-9]+.*)}] $line match phonenumber cmd ]} {