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

EEM script of check if DHCP is working or not

Satish Rayanki
Cisco Employee
Cisco Employee

Hi,

I need help on configuring a EEM script to check if the dhcp is working or not in our lab, Below is the idea.

On every access swtich i will create a eem scrip to check if the dhcp is working or not, if the dhcp is not working it has to send a mail.

event manager applet DHCP_TEST
event none
action 10 cli command "enable"
action 11 cli command "configure terminal"
action 12 cli command "interface vlan 12"
action 13 cli command "ip add dhcp"
action 14 wait 10
action 15 cli command "do show ip interface brief | in DHCP"
action 16 regexp "unassigned" $_cli_result

action 17 if $_regexp_result eq 1
action TEST mail server "outbound.cisco.com" to "caloweb@cisco.com" from "srayanki" cc "calo-bgl-support@cisco.com" subject "[CALO-BGL]" body "DHCP not working".

I have tried with the above script but i am not getting the desired output. Please help me.

Thanks

Satish

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

I don't know what you mean by not getting the desired output.  More details would be helpful.

But six things about this applet.  First, are these switches using AAA command authorization?  If so, then you also need to configure:

event manager session cli username USER

Where USER is a username authorized to run all of the commands.

Second, a wait within a policy can be bad.  It can cause the policy to die because it hits its maxrun.  You may want to increase maxrun to something like 30 seconds to account for the added delay (add "maxrun 30" to the end of the "event none").

Third, I never recommend using a hostname for an SMTP server since that adds a bit more delay and has been known to lock up policies in older versions of IOS.

Fourth, you need an action "end" after your mail action.  You start an if block, you need to end it.

Fifth, you shouldn't mix labels like you're doing.  Continue the theme, and use a number for your mail action.  This will make adding the "end" action easier.

And sixth, you should also use a fully qualified email address for "from".

View solution in original post

2 Replies 2

Joe Clarke
Cisco Employee
Cisco Employee

I don't know what you mean by not getting the desired output.  More details would be helpful.

But six things about this applet.  First, are these switches using AAA command authorization?  If so, then you also need to configure:

event manager session cli username USER

Where USER is a username authorized to run all of the commands.

Second, a wait within a policy can be bad.  It can cause the policy to die because it hits its maxrun.  You may want to increase maxrun to something like 30 seconds to account for the added delay (add "maxrun 30" to the end of the "event none").

Third, I never recommend using a hostname for an SMTP server since that adds a bit more delay and has been known to lock up policies in older versions of IOS.

Fourth, you need an action "end" after your mail action.  You start an if block, you need to end it.

Fifth, you shouldn't mix labels like you're doing.  Continue the theme, and use a number for your mail action.  This will make adding the "end" action easier.

And sixth, you should also use a fully qualified email address for "from".

Hi Joseph clarke,

After following your suggestions, i have made it working, thanks a lot for your help and support

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: