cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5105
Views
0
Helpful
24
Replies

EEM - IP Routing

pugs17211721
Level 1
Level 1

We have some windows based scripts that run and check to make sure that certain servers (web monitors) are up and running. If they are not up, then it will log into the routers and change the routing tables on the router. I do not have access to these scripts or get emailed on their results, so I would like to set up a EEM applet to let me know on this.

These are the two possibilities:

Normal Routing

ip route 0.0.0.0 0.0.0.0 fa0/1 10

ip route 0.0.0.0 0.0.0.0 172.20.240.1 20

After routing has been changed

ip route 0.0.0.0 0.0.0.0 172.20.240.1

ip route 0.0.0.0 0.0.0.0 fa0/1 10

So I need to trigger off of 172.20.240.1 20.

Also if possible, I would like this to run and check every 10 minutes, but I only want emailed every 60 minutes? Is this option possible?

This is what I have come up with so far, but this is my first adventure into EEM. Can anyone provide some assistance? Thanks.

 
event manager applet iprouting-check
event timer watchdog time 600
action 001 cli command "enable"
action 002 cli command "show run | inc ip route"
action 003 regexp "(172\.20\.240\.1\_\20\")" $_cli_result ignore match
action 004 if $_regexp_result eq 1
action 005 mail subject "Branch Routing Is Not Local" body "Found $match in IP Routing" to user@company.com from user@company.com server y.y.y.y
action 006 end

24 Replies 24

Enable "debug event manager tcl cli" and "debug event manager tcl smtp", have your script run, then post the output.

Here is the result. I have edited some of the IP's in the show ip route commands and also edited the banner, but other than that it is exactly what I get.

Dec  1 06:23:08.603 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : CTL : cli_open called.
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :            Company Banner
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :          Company Banner
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :         Company Banner
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :        Company Banner
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :       Company Banner
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :       Company Banner
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :       Company Banner
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :       Company Banner
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :        Company Banner
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :          
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :                        Company Name
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :          
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :                       Unauthorized access prohibited
Dec  1 06:23:08.735 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :
Dec  1 06:23:08.739 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : CTL : 20+ lines read from cli_read, debug output truncated.
Dec  1 06:23:08.739 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : IN  : BOID-1841-001>enable
Dec  1 06:23:08.939 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :
Dec  1 06:23:08.939 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT : BOID-1841-001#
Dec  1 06:23:08.939 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : IN  : BOID-1841-001#show run | inc ip route
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :  ip route-cache flow
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :  ip route-cache flow
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :  ip route-cache flow
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :  ip route-cache flow
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :  ip route-cache flow
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :  ip route-cache flow
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT :  ip route-cache flow
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT : ip route 0.0.0.0 0.0.0.0 172.20.240.1
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT : ip route 0.0.0.0 0.0.0.0 10
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT : ip route 255.255.255.248
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT : ip route 172.20.151.1 255.255.255.255
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT : ip route 172.20.240.2 255.255.255.255
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT : ip route 172.20.240.19 255.255.255.255
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT : ip route 172.20.240.100 255.255.255.255 Serial0/0/0
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT : ip route 255.255.252.0
Dec  1 06:23:09.851 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : OUT : BOID-1841-001#
Dec  1 06:23:09.859 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : CTL : cli_close called.
Dec  1 06:23:09.859 MST: %HA_EM-6-LOG: routing_check_test.tcl : DEBUG(cli_lib) : IN  : BOID-1841-001#exit
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl: invalid command name "'"
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl:     while executing
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl: "'"
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl:     invoked from within
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl: "$slave eval $Contents"
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl:     (procedure "eval_script" line 7)
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl:     invoked from within
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl: "eval_script slave $scriptname"
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl:     invoked from within
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl: "if {$security_level == 1} {       #untrusted script
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl:      interp create -safe slave
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl:      interp share {} stdin slave
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl:      interp share {} stdout slave
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl: ..."
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl:     (file "system:/lib/tcl/base.tcl" line 50)
Dec  1 06:23:09.983 MST: %HA_EM-6-LOG: routing_check_test.tcl: Tcl policy execute failed: invalid command name "'"

First, it looks like the output of your "show run | inc ip route" command does not include the expression necessary to trigger the script.  That explains why no email is going out.  The invalid command is weird, though.  Can you post the actual script file?

Sorry for the delay in answering you, I have been traveling the last week. Here is the script file, the only changes that I have made are in the email addresses.

Here's a fixed version.  You still need to make sure the "show ip route" output contains the pattern:

172\.20\.240\.1 20

That is, the literal string "172.20.240.1" followed by a space followed by the literal string "20".  Only when that happens will the email possibly be sent out.

I just want to make sure that we are thinking on the same page. I want it to alert if it finds "172.20.240.1" (with no 20 after). I don't want any alerts if it find "172.20.240.1 20"

So in normal non-error situations this line should exist

ip route 0.0.0.0 0.0.0.0 172.20.240.1 20

In alarm status this is what will be in the config

ip route 0.0.0.0 0.0.0.0 172.20.240.1

Are we still talking the same thing?

Ah, I think I misunderstood based on your initial applet example.  Try this version.

This is the message that I get now

Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl: wrong 4th line format.
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl: usage: Cc:
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl:     while executing
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl: "smtp_send_email $mail_msg"
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl:     invoked from within
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl: "$slave eval $Contents"
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl:     (procedure "eval_script" line 7)
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl:     invoked from within
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl: "eval_script slave $scriptname"
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl:     invoked from within
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl: "if {$security_level == 1} {       #untrusted script
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl:      interp create -safe slave
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl:      interp share {} stdin slave
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl:      interp share {} stdout slave
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl: ..."
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl:     (file "system:/lib/tcl/base.tcl" line 50)
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl: Tcl policy execute failed: wrong 4th line format.
Dec 13 07:23:26.382 MST: %HA_EM-6-LOG: routing_check_local.tcl: usage: Cc:

The Cc: field got dropped.  Try this version.

This is working now, thanks for your help.