cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2300
Views
26
Helpful
20
Replies

Event manager $_cli_pattern ignored

Ditter
Level 3
Level 3

Hi to all,

 

i would like to send the output of a single command to an email address so i have created a simple script you can see below.


The email is successfully sent to the recipient with the correct subject but the body is empty without the output of the show interface status command which i need to send by email.


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

event manager applet show-int-status
description show-int-status
event none sync yes
action 0.5 cli command "enable"
action 1.0 cli command "show int status"
action 1.5 mail server "mta.xyz.com" to "support@xyz.com" from "rtr@xyz.com" subject "show int status output" body "show int status $_cli_pattern"


I also noticed that although i did put the $_cli_pattern is in the email command when i created it , when i enter a

"show event manager policy registered" i do not see the $_cli_pattern variable in this specific line as if i did not put it in the command in the first place.

 

That is :


action 1.5 mail server "mta.xyz.com" to "support@xyz.com" from "rtr@xyz.com" subject "show int status output" body "show int status" and there is not present the rest of the input that is the "WITHOUT THE $_CLI_PATTERN" part.


Any ideas, why the email is sent without the body and why the $_cli_pattern has disappeared from the command?


Thanks,

 

Ditter.

1 Accepted Solution

Accepted Solutions

Hi,

 

i found the culprit!

 

In the past i had activated shell processing in the one of the two 6500. So it parsed the $ sign whenever i was trying to enter the $_cli_result parameter in order to interpret it as part of a script !

 

I removed shell processing and now everything works as expected.

 

Many thanks balaji.bandi for his help and advice (as well as Georg Pauwen).

 

Ditter.

View solution in original post

20 Replies 20

balaji.bandi
Hall of Fame
Hall of Fame

if you looking to store the results of interface status and email  - is this correct?

 

then you need use 

puts "$_cli_result"

 

if that is not the case look the document :

 

https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/eem/command/eem-cr-book/eem-cr-e1.html

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Yes that is what i want.

 

But how to use the puts $_cli_pattern in the email that i want to send?

 

Thanks again.

Ditter.

try this and let me know if that works.

 

event manager applet show-int-status
action 0.5 cli command "enable"
action 1.0 cli command "
show interface status"

action 1.5 mail server "mta.xyz.com" to "support@xyz.com" from "rtr@xyz.com" subject "show int status output" body "$_cli_result"

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

I get the message :

 

rtr#event manager run show-int-status
EEM policy show-int-status not registered with event none Event Detector

 

I think that a line like  "event none sync yes" is also needed which i added.

 

The problem is that when i run the command : show event manager policy registered

 

31 applet user none Off Sat Mar 6 22:03:18 2021 show-int-status
policyname {show-int-status} sync {yes}
maxrun 20.000
action 0.5 cli command "enable"
action 1.0 cli command "show interface status"
action 1.5 mail server "mta.xyz.com" to "support@xyz.com" from "rtr@xyz.com" subject "show int status output"

 

As you can see the body output is disappeared although i put the command as you proposed i mean the body "$_cli_result"!

 

Thanks.

 

 

what device is this :

 

just added in my Lab :

 

 

PE-4#show event manager policy registered
No. Class Type Event Type Trap Time Registered Name
1 applet user none Off Sat Mar 6 22:11:15 2021 show-int-status
policyname {show-int-status} sync {yes}
maxrun 20.000
action 0.5 cli command "enable"
action 1.0 cli command "show int status"
action 1.5 mail server "mta.xyz.com" to "support@xyz.com" from "rtr@xyz.com" subject "show int status output" body "show int status $_cli_results"

 

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

It is a cisco 6500 with s72033_rp-ADVIPSERVICESK9-M), Version 15.1(2)SY6.

 

And the event manager version is :

 

Embedded Event Manager Version 4.00
Component Versions:
eem: (rel3)1.0.8
eem-gold: (rel1)1.0.2
eem-call-home: (rel1)1.0.5
Event Detectors:
Name Version Node Type
application 01.00 node5/1 RP
identity 01.00 node5/1 RP
rf 01.00 node5/1 RP
routing 02.00 node5/1 RP
syslog 01.00 node5/1 RP
generic 01.00 node5/1 RP
track 01.00 node5/1 RP
cli 01.00 node5/1 RP
counter 01.00 node5/1 RP
interface 01.00 node5/1 RP
ioswdsysmon 01.00 node5/1 RP
ipsla 01.00 node5/1 RP
none 01.00 node5/1 RP
oir 01.00 node5/1 RP
snmp 01.00 node5/1 RP
snmp-object 01.00 node5/1 RP
snmp-notification 01.00 node5/1 RP
timer 01.00 node5/1 RP
test 01.00 node5/1 RP
config 01.00 node5/1 RP
env 01.00 node5/1 RP
ds 01.00 node5/1 RP
crash 01.00 node5/1 RP
gold 01.00 node5/1 RP
rpc 01.00 node5/1 RP

 

It just ignores the $_cli_pattern variable. In the show commands as i mentioned the $_cli_pattern is disappeared !

have you tried as suggested before :

 

action 1.5 mail server "mta.xyz.com" to "support@xyz.com" from "rtr@xyz.com" subject "show int status output" body "$_cli_result"

 

can you post all the configuration if possible to understand the issue deeper (15.1 is good code)

 

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

31 applet user none Off Sat Mar 6 22:03:18 2021 show-int-status
policyname {show-int-status} sync {yes}
maxrun 20.000
action 0.5 cli command "enable"
action 1.0 cli command "show interface status"
action 1.5 mail server "mta.xyz.com" to "support@xyz.com" from "rtr@xyz.com" subject "show int status output" body "show int statusn"

 

As you can see at the last command it ignored the "\" as well as the $_cli_pattern in the  body "show int status\n$_cli_result" and in the show registered output it showed only the "show int statusn" without the special character as well as the $_cli_result

Thanks!

are you copy and pasting on the device, what notepad you using? 

 

can you try manually and see if that command works?

 

before you do on the console, set terminal width maximum so you can view the full command.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Hi,

i am using putty (actually superputty) , i am not copying and pasting, i issue the command in the putty terminal , i can see the full command with the $_cli_result as part of the command (in one line) with terminal width 512  but when i do a show run | begin event manager or a show event manager policy registered the $_cli_result is disappeared !

 

Thanks again, for your help.

Ditter.

 

Hello,

 

you might have to add the variable first in order to see it in the output:

 

event manager environment $_cli_pattern

 

However, the variable has no value and is not a built-in variable, so in order to achieve your goal (which is to send the output of the 'show' command (the last cli command) in the message body, the script below should work, as '$_cli_result' is a built-in action variable:

 

event manager applet show-int-status
description show-int-status
event none sync yes
action 0.5 cli command "enable"
action 1.0 cli command "show int status"
action 1.5 mail server "mta.xyz.com" to "support@xyz.com" from "rtr@xyz.com" subject "show int status output" body "$_cli_result"

 

or if you want 'show int status' to be part of the body:

 

event manager applet show-int-status
description show-int-status
event none sync yes
action 0.5 cli command "enable"
action 1.0 cli command "show int status"
action 1.5 mail server "mta.xyz.com" to "support@xyz.com" from "rtr@xyz.com" subject "show int status output" body "show int status\n$_cli_result"

>you might have to add the variable first in order to see it in the output:

 

>event manager environment $_cli_pattern

 

Hi, the subject in this thread is wrong as the problem is with the $_cli_result which is ignored (by mistake i mentioned $_cli_pattern)

 

So i tried to add it as a variable as you can see below:

 

rtr(config)#event manager environment $_cli_result
% Incomplete command.

rtr(config)#event manager environment $_cli_result ?
LINE Value of the global environment variable
<cr>

 

 

In addition , i tried to add the body "show int status\n$_cli_result"

The email was sent and in the body i got only this:

show int statusn

Hello,

 

what if you just use:

 

event manager applet show-int-status
description show-int-status
event none sync yes
action 0.5 cli command "enable"
action 1.0 cli command "show int status"
action 1.5 mail server "mta.xyz.com" to "support@xyz.com" from "rtr@xyz.com" subject "show int status output" body "$_cli_result"

Thanks Georg,

 

i have done this already, although i issue the command $_cli_result   when i do a show event manager policy registered the $_cli_result variable is disappeared (only the subject is present and the body command is disappeared in the show output).

 

It seems like a bug, so i used another router (7206 instead of the 6500) and the command executes fine and when i do a show event manager policy registered it shows the $_cli_result just fine.

 

So something is different with the 6500.  

 

What also seems strange is that the 6500 has 30 entries in the show event manager policy registered which off course i never put there and most probably are system tcl scripts  (however the 7206 router does not have any of these tcl scripts):

 

2 script system gold Off Mon Mar 8 11:24:44 2021 Mandatory.go_aclfpgamon.tcl
card {all} action-notify {true} testing-type {monitoring} test-name {TestAclFpgaMonitor} consecutive-failure 1
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


3 script system gold Off Mon Mar 8 11:24:44 2021 Mandatory.go_asicsync.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestAsicSync}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


4 script system gold Off Mon Mar 8 11:24:44 2021 Mandatory.go_bootup.tcl
severity-major card {all} testing-type {bootup}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


5 script system gold Off Mon Mar 8 11:24:44 2021 Mandatory.go_dataportlbk.tcl
card {all} action-notify {true} testing-type {monitoring} test-name {TestDataPortLoopback} consecutive-failure 10
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


6 script system gold Off Mon Mar 8 11:24:44 2021 Mandatory.go_dplbk.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestDCPLoopback}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


7 script system gold Off Mon Mar 8 11:24:44 2021 Mandatory.go_earl7cc.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestEARLInternalTables}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


8 script system gold Off Mon Mar 8 11:24:44 2021 Mandatory.go_fabric.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestFabricHealth}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


9 script system gold Off Mon Mar 8 11:24:44 2021 Mandatory.go_fabrich0.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestFabricCh0Health}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


10 script system gold Off Mon Mar 8 11:24:44 2021 Mandatory.go_fabrich1.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestFabricCh1Health}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


11 script system gold Off Mon Mar 8 11:24:44 2021 Mandatory.go_fabriclinkstatus.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestFEXFabricLinkStatus}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


12 script system gold Off Mon Mar 8 11:24:44 2021 Mandatory.go_fabsync.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestSynchedFabChannel}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


13 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_fwdiagstat.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestFirmwareDiagStatus}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


14 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_intlpbk.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestIntPortLoopback}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


15 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_ipsec.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestIPSecEncrypDecrypPkt}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


16 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_l3tcam.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestL3TcamMonitoring}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


17 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_ltlmemconsty.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestLtlFpoeMemoryConsistency}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


18 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_mac.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestMacNotification}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


19 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_mgmtlbk.tcl
card {all} action-notify {true} testing-type {monitoring} test-name {TestMgmtPortsLoopback} consecutive-failure 10
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


20 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_microburst.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestMicroburst}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


21 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_nondislp.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestNonDisruptiveLoopback}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


22 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_nplbk.tcl
card {all} testing-type {monitoring} test-name {TestNPLoopback} consecutive-failure 1
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


23 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_nvrambatterymon.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestNVRAMBatteryMonitor}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


24 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_porttx.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestPortTxMonitoring}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


25 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_s2lem.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestSupToLcEarlMonitoring}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


26 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_scratchreg.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestScratchRegister}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


27 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_sprping.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestSPRPInbandPing}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


28 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_spuriousisr.tcl
card {all} testing-type {ondemand} test-name {TestSpuriousIsrDetection} consecutive-failure 1
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none


29 script system syslog Off Mon Mar 8 11:24:45 2021 Mandatory.go_switchbus.tcl
occurs 1 pattern {Switching Bus FIFO counter stuck}
nice 0 queue-priority high maxrun 90.000 scheduler rp_primary Secu none


30 script system gold Off Mon Mar 8 11:24:45 2021 Mandatory.go_unusedportlpbk.tcl
card {all} testing-type {monitoring} event-type {threshold-reached} test-name {TestUnusedPortLoopback}
nice 0 queue-priority last maxrun 20.000 scheduler rp_primary Secu none

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: