cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1445
Views
0
Helpful
2
Replies

Cisco IR809G EEM TCL Script stuck in pending

boneyact
Level 1
Level 1

Hi there,

 

This is the first time I am participating in any community discussions. Pardon me, if I have missed any formalities.

 

I am using IR809G router which is running on IOS 15.9(3)M1 with the I have created an EEM TCL script to be triggered on a syslog pattern " New SMS received on index .* ". All this script does is, parse the received SMS and forward the SMS through a TCP Socket to another IP device. Below is the script.

 

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

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

array set arr_einfo [event_reqinfo]
set runthis 0
set msg "$arr_einfo(msg)"
if { ![regexp {: ([^:]+)$} $msg-> info] } {
action_syslog msg "Failed to parse syslog message"
exit
}
array set _sinfo [sys_reqinfo_routername]
set host $_sinfo(routername)
regsub -all {\n+} $msg "" msg
action_syslog msg "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 "Intf:$intf"
}

proc deletesms {} {
variable index
variable errorInfo
variable intf

catch {cli_close $cli1(fd) $cli1(tty_id)}
# 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 delete $index\r" } result ] {
error $result $errorInfo
}

action_syslog msg "Successfully deleted SMS message $index from SIM\n"

if {$index > 9} {
if [catch {cli_exec $cli1(fd) "$intf lte sms delete all\r\r" } result ] {
error $result $errorInfo
}
puts "Successfully deleted all messages on SIM\n"
}
catch {cli_close $cli1(fd) $cli1(tty_id)}
exit 1
}

proc TCPSocket_SendSMS {phonenumber cmd} {
set server 192.168.24.163
set sockChan [socket $server 61000]
puts $sockChan "$phonenumber $cmd"
action_syslog msg "SMS Forwarded to RTU successfully"
close $sockChan
return 1
}

# 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 $index"} result] {
error $result $errorInfo
}

set lines [split $result "\n"]
set loop 0

foreach line $lines {
incr loop
regexp -nocase [subst -nocommands -nobackslashes {FROM:\s+([0-9]+)}] $line match phonenumber

if { [regexp {(SIZE: [0-9]+)} $line match size]} {
set cmd [lindex $lines $loop]
regsub -all {CONTENT:} $cmd "" cmd

}
}

if {![info exists cmd]} {
action_syslog msg "Unable to read body of SMS message (variable cmd not set) & loop = $loop"
exit 1
}

if {[info exists phoneprefix]} {
set phonenumber "$phoneprefix$phonenumber"
action_syslog msg "Prepending prefix to phonenumber = $phonenumber"
}

if {[info exists removeprefix]} {
regsub "$removeprefix" $phonenumber "" phonenumber
}

action_syslog msg "Received SMS from $phonenumber : $cmd"

if {![TCPSocket_SendSMS $phonenumber $cmd]} {
action_syslog msg "Unable to send SMS message through TCP Socket to RTU"
exit 1
} else {
deletesms
}
}

Below is the configuration relevant for TCPSocket_SendSMS.tcl script to be functional

 

event manager directory user policy "flash:/"

event manager policy TCPSocket_SendSMS.tcl authorization bypass

 

 

I have turned ON the below EEM debug

 

Embedded Event Manager:

  Debug EEM Server scheduling debugging is on

  Debug EEM Syslog Event Detector debugging is on

 

As the router receives an SMS, I see the below syslog messages.

 

*Feb 19 13:35:56: Cellular0: New SMS received on index 8 . Please issue a view command to see it

*Feb 19 13:35:56: %CELLWAN-2-SMS_ARCH_PATH_UNCONFIGURED: Cellular0 failed to archive SMS because 'gsm|cdma|lte sms archive path' under cellular controller is not configured.

*Feb 19 13:35:56: syslog_pubinfo_enqueue: matched message="

*Feb 19 13:35:56: Cellular0: New SMS received on index 8 . "

*Feb 19 13:35:56: fh_fd_syslog_event_match: num_matches = 0

*Feb 19 13:35:56: fh_fd_syslog_event_match: num_matches = 0

*Feb 19 13:35:56: EEM server schedules scripts

*Feb 19 13:35:56: fh_assign_scheduler_thread: server has no available thread to service the policy class=default policy_type=script.

 

X0789#show event manager policy registered

No.  Class     Type    Event Type          Trap  Time Registered           Name

 

2    script    user    syslog              Off   Wed Feb 19 08:46:12 2020  TCPSocket_SendSMS.tcl

 pattern { New SMS received on index }

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

 

X0789#show event manager policy pending

 

Key: p - Priority        :L - Low, H - High, N - Normal, Z - Last

     s - Scheduling node :A - Active, S - Standby

 

default class - 1 script event

  1. no.  job id      p s status  time of event             event type          name

 1    17          N A pend    Wed Feb19 13:35:56 2020   syslog              TCPSocket_SendSMS.tcl

 

Apparently, Cisco TAC doesn't support EEM scripting and I have to go through Community portal. The issue I am facing at the moment is that the SMS has been successfully received by the router. A syslog message has been raised by the IOS. This syslog message appears to have been picked by the syslog detector. The script goes into a pending state and that is as far as I go. The script just doesn't gets executed. 

 

Has any one faced this type of issue before. I have tried everything that I can think of, in vain. I have started of with a simple script that just matches the syslog and prints a message. Even that got stuck in pending. Please help me out here.

 

 

2 Replies 2

boneyact
Level 1
Level 1

Hi there,

 

I have figured out that the issue is not with the script that I posted in my earlier post. There is another script that opens a TCP Socket in server mode which is stuck in open mode and doesn't let any other script to run while it is in active mode. This script has an event trigger in Cron to start the script at bootup. The only way I can shake off that script is to reboot the router. I am suspecting it is a bug in Cisco IOS. I have raised a TAC ticket and unfortunately, Cisco TAC team came back to me saying that they can not deal with any issues related to TCL scripting. 

 

I have managed to rewrite the script in such a way that instead of having the TCP socket open forever at reboot, I have used a syslog trigger to open the TCP socket for a fixed amount of time and if nothing happens during this period, the TCP socket will be closed. 

calexjack742
Level 1
Level 1

It's possible that the Cisco IR809G EEM TCL script is stuck in the "pending" state due to a variety of reasons. One possible reason is that the script may be waiting for a specific event or trigger to occur before it can proceed. In this case, you may want to check if the event or trigger has been properly configured.

Another possible reason is that there may be some syntax errors in the script itself. You can use the "debugging" feature in the Cisco IOS command-line interface (CLI) to identify and correct any syntax errors in the script.

As an example, imagine you're trying to cook a delicious meal, but your knife is dull and can't cut through the ingredients. In this case, you would need to sharpen your knife before you can proceed with the cooking process. Similarly, in the case of the Cisco IR809G EEM TCL script being stuck in pending, you need to identify and correct the underlying issue before you can proceed with the intended action.