cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
cancel
748
Views
0
Helpful
7
Replies

LTE Site Survey Via SMS using EEM applet /Script on Cisco C1121-4PLTEP

kirandeep.singh
Level 1
Level 1
I am trying to find a EEM Applet or EEM TCL Script for Cisco C1121-4PLTEP that can be used to do LTE Site Survey.

I have tried to use one script using syslog pattern but logging buffer is missing incoming sms index messages, so pattern is not getting matched although I see messages received under this command cellular 0/2/0 lte sms view all

 

Any solution/fix?

 

Thanks

KD

7 Replies 7

Hello,

 

you could still use an EEM script in combination with the output of 'cellular 0/2/0 lte sms view'.

 

You just need to parse the output of that command with a regular expression. Can you post the output of that command ? 

XXXX_WBU_TestKit#cellular 0/2/0 lte sms view summary
ID FROM YY/MM/DD HR:MN:SC SIZE CONTENT
0 1XXX-XXX-XXXX 22-06-15 12:58:19 6 status
1 1XXX-XXX-XXXX 22-06-15 12:58:57 6 status
2 1XXX-XXX-XXXX 22-06-15 13:03:36 6 Status
3 1XXX-XXX-XXXX 22-06-15 13:04:45 3 gps
4 1XXX-XXX-XXXX 22-06-15 13:22:05 2 Hi
5 1XXX-XXX-XXXX 22-06-15 13:22:54 6 status

::cisco::eem::event_register_syslog pattern " New SMS received on index .*" maxrun 120

##-
# Copyright (c) 2013 Dan Frey <dafrey@cisco.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY

# Installation Steps
# Place this file on the router media, typically the flash drive.
# Execute these two CLI commands in global config mode:
# event manager directory user policy "flash:/"
# event manager policy <filename> type user

# Functionality: Send a SMS message to the router with the word "status" without quotes and this EEM policy will respond
# via sms back to the sender with the current band, RSSI value, and SNR values. Send a SMS message with "ping example.com" without
# quotes and this EEM policy will respond via SMS with the results of the ping.
# EEM policy will delete each SMS message after the message is processed.

# Date: April 4, 2013
# Summary - Provide diagnostic information via SMS
# Version 1.0

namespace import ::cisco::eem::*
namespace import ::cisco::lib::*

array set arr_einfo [event_reqinfo]
set msg "$arr_einfo(msg)"
if { ! [regexp {: ([^:]+)$} $msg -> info] } {
action_syslog msg "Failed to parse syslog message"
}
array set _sinfo [sys_reqinfo_routername]
set host $_sinfo(routername)
regsub -all {\n+} $msg "" msg
if [ regexp {([A-Za-z\/0-9]+): New SMS received on index ([0-9]+).} $msg match intf ] {
set cellintf $intf
regsub -all {r} $intf "r " intf
action_syslog msg "interface = $intf"
}
# Trigger EEM from a SMS message
if [ regexp {New SMS received on index ([0-9]+).} $info match index ] {

# Open the CLI
if [catch {cli_open} result] {
error $result $errorInfo
} else {
array set cli1 $result
}
# Go into enable mode
if [catch {cli_exec $cli1(fd) "enable"} result] {
error $result $errorInfo
}
if [catch {cli_exec $cli1(fd) "$intf lte sms view summary"} result] {
error $result $errorInfo
}

set lines [split $result "\n"]
foreach line $lines {
if {[regexp -nocase [subst -nocommands -nobackslashes {$index\s+(\d+)\s+[\d/]+\s+[\d:]+\s+\d+\s+([A-Za-z0-9]+.*)}] $line match phonenumber cmd ]} {
action_syslog msg "Received SMS from $phonenumber Body: $cmd"

#Status: SMS format: status
if {[regexp -nocase [subst -nocommands -nobackslashes {(Status)}] $cmd -> command]} {
if [catch {cli_exec $cli1(fd) "show $intf all | inc IP address|Band|Current R|SNR =" } result ] {
error $result $errorInfo
}
#Get RSSI, SNR and Band on one line
set result [split $result "\n"]
regsub -all {\r+|\{|\}} $result "" result
if [catch {cli_exec $cli1(fd) "$intf lte sms send $phonenumber $result" } result ] {
error $result $errorInfo

}
}
#End Status

#GPS: SMS format: gps
if {[regexp -nocase [subst -nocommands -nobackslashes {(Gps)}] $cmd -> command]} {
if [catch {cli_exec $cli1(fd) "show $intf gps | inc GPS S|Lat|Lon|Tim" } result ] {
error $result $errorInfo
}
#Get RSSI, SNR and Band on one line
set result [split $result "\n"]
regsub -all {\r+|\{|\}} $result "" result
if [catch {cli_exec $cli1(fd) "$intf lte sms send $phonenumber $result" } result ] {
error $result $errorInfo

}
}
#End GPS

########PING: SMS format: ping www.example.com
if {[regexp -nocase [subst -nocommands -nobackslashes {(ping .*)}] $cmd -> command]} {
if [catch {cli_exec $cli1(fd) "$command" } result ] {
error $result $errorInfo
}
set result [split $result "\n"]
foreach line $result {
if {[regexp -nocase [subst -nocommands -nobackslashes {(Success .*)}] $line -> result]} {
regsub -all {\r+|\{|\}} $result "" result
if [catch {cli_exec $cli1(fd) "$intf lte sms send $phonenumber $result" } result ] {
error $result $errorInfo
}
} else {
if {[regexp -nocase [subst -nocommands -nobackslashes {(. Unrecognized .*)}] $line -> result]} {
regsub -all {\r+|\{|\}} $result "" result
if [catch {cli_exec $cli1(fd) "$intf lte sms send $phonenumber $result" } result ] {
error $result $errorInfo
}
}
}
}
}
#End Ping
}
}
}
#Delete SMS message
if [catch {cli_exec $cli1(fd) "$intf lte sms view $index" } result ] {
error $result $errorInfo
}
set a [open file a]
puts $a $result
close $a

if [catch {cli_exec $cli1(fd) "$intf lte sms delete $index\r" } result ] {
error $result $errorInfo
}
action_syslog msg "Successfully deleted SMS message $index from SIM\n"

catch {cli_close $cli1(fd) $cli1(tty_id)}

 

kirandeep.singh
Level 1
Level 1

Also my eem applet not working for sending $_cli_result via sms

 

event manager applet RSSI
event syslog pattern "SMS sender 1xxx-xxx-xxxx"
action 1.0 cli command "enable"
action 1.5 cli command "sh cellular 0/2/0 radio"
action 2.0 cli command "cell 0/2/0 lte sms send 1XXX-XXX-XXXX / $_cli_result"
!
end

Hello,

 

so the EEM policy generates the syslog message, and the EEM script is supposed to act on the syslog pattern ?

 

Is the syslog pattern actually being generated, do you get 'SMS sender 1xxx-xxx-xxxx' into the log ?

kirandeep.singh
Level 1
Level 1

EEM policy doesn't generate the syslog message, but after running the debug cellular messages sms command , I can see the messages in syslog. based on that i see SMS sender 1xxx-xxx-xxxx in the syslog.

Hello,

 

you need to match the number with a regular expression, then use the cli result to send the message. The EEM script would look like this:

 

event manager applet RSSI
event syslog pattern "SMS sender *"
action 1.0 cli command "enable"
action 1.5 cli command "show cellular 0/2/0 radio"
action 1.6 regexp "([0-9][0-9][0-9][0-9]\-[0-9][0-9][0-9][0-9]\-[0-9][0-9][0-9][0-9])" $_cli_result
action 2.0 cli command "cell 0/2/0 lte sms send $_cli_result"

Review Cisco Networking for a $25 gift card