03-06-2021 04:35 AM
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.
Solved! Go to Solution.
03-11-2021 04:31 AM
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.
03-06-2021 04:52 AM - edited 03-06-2021 05:05 AM
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
03-06-2021 10:20 AM
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.
03-06-2021 10:59 AM
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"
03-06-2021 12:09 PM
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.
03-06-2021 02:12 PM
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"
03-07-2021 01:56 AM
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 !
03-07-2021 02:12 AM
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)
03-07-2021 02:40 AM
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!
03-07-2021 03:34 AM
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.
03-07-2021 03:52 AM
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.
03-06-2021 03:30 PM
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"
03-07-2021 02:28 AM
>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
03-07-2021 08:00 AM
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"
03-08-2021 05:28 AM
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
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