Script to send alerts when new IP Interface from the DHCP server

Hi all

I have a few branches with a cable ISP with dynamic IP company, I'm trying to create a script to automatically send an e-mail if the interface get a new IP address if the GET the previous interface IP do not send an email.

So far, this is the script that I created:

TEST2 event manager applet
event syslog "Interface FastEthernet1 assigned DHCP" model
command action 1.1 cli 'enable '.
action 1.2 cli command "show int FastEthernet1 | I have Internet address. "
Action 1.51 regexp "Internet address is 9.9.9.9/30" "$_cli_result".
Action 1.6 If $_regexp_result eq '0 '.
action mail 2.0 to [email protected] / * / to [email protected] / * / subject to "NEW IP ADDRESS' SMTP server. Making body "$_syslog_msg".
2.1 action ended

The only problem with the script is that if the interface get a new IP address, I need to update the script in action 1.51 regexp with the new IP address so next time the interface to change the IP address to compare with the Internet address variable is...

Thank you

Advertisement

There are a number of ways to do what you want.  A Flash file is probably the easiest because it persisted resets.

Event Manager applet check-ip

event syslog "Interface FastEthernet1 assigned DHCP" model

command action 1.0 cli 'enable '.

type of handle-error action 2.0 ignore

Action 3.0 file open fd flash: myip.txt r

Action 4.0 if $_error don't FH_EOK

4.1 action set currip "0.0.0.0".

Action 4.2 else

Action 4.3 file gets fd currip

Action 4.4 file close fd

end of the action 4.5

out of action 4.6 type handle-error

action 4.7 cli command "show int Fa1 | address Internet Inc"

Action 4.8 regexp 'address Internet's ([0 - 9.] (+)' ' $_cli_result ' match myip

Action 4.9 If $myip not $currip

Our action 5.0 mail from [email protected] / * / to [email protected] / * / subject to "NEW IP ADDRESS' SMTP server. Making body "$_syslog_msg".

Action 5.1 file open fd flash: myip.txt w

action file 5.2 puts nonewline fd $myip

action file 5.3 close fd

end of the action 5.4

Tags: Cisco Network

Similar Questions

  • 5s iPhone cannot send emails when it is connected to the host server Exchange 2013

    We moved just email providers of in home (Exchange knock-off called 'Kerio' on a server) to 2013 exchanged hosted Microsoft. My iPhone 4 (7.x) is able to connect on the new e-mail server and send and receive e-mails. I tried to connect my 5s (8,0) and a 5 c (7.1.2) but I am only able to receive emails, do not send. 5 5 c/s have been setup using 'Exchange' in the e-mail application. Any advice?

    Hello

    See the link below for this problem.

    1. apple discussion click here

    2. link to the configuration page click here

  • create a description of the interface if no ip address received from the dhcp server

    Hi Experts,

    I would like to create simple script revved my interface isn't getting an IP address, it will add the description of this interface. I tried writing but no luck. BTW, this is my first attempt of EEM. Thanks in advance...

    Event Manager applet change-address_2
    model event syslog "DHCP_Description."
    order cli action 001 'enable '.
    action 002 cli command "show int G0/0 | address Internet Inc. will be negotiated"
    football action 003 cli match $_cli_result
    action 004, «config t» cli command
    005 action, command cli "int g0/0".
    action 006 cli "description of the command NO IP ASSIGN"

    I built a task of laboratory for this kind of thing for CiscoLive.  In the laboratory, a static IP address is assigned to the interface, but it's easy to change to simply put a description.  The following policies:

    "event Manager environment q.
    Dhcp-intf-up applet event handler
    event syslog LINEPROTO.*GigabitEthernet0/0,.*changed state model up to
    order cli action 001 'enable '.
    action 002, «config t» cli command
    action 003 cli command "event manager applet dhcp-intf-timer."
    action 004 cli command 'event timer countdown 60 '.
    005 action, command cli "action 1.0 cli command enable."
    action 006 cli command "action 2.0 cli command $q config t$ q.
    action 007 cli command "action 3.0 $q interface cli command Gi0/0$ q.
    action 008 cli command "action 4.0 cli don't command $q description NO ATTRIBUTION of IP $q.
    action 010 cli command "action 6.0 cli don't command $q no event manager applet dhcp-intf-timer-disable$ q.
    action 011 cli command "action 7.0 cli don't command $q no event manager applet dhcp-intf-timer$ q.
    action 012 cli command "event manager applet dhcp-intf-timer-disable.
    action 013 cli command "syslog events model $q%DHCP-6-ADDRESS_ASSIGN:.*GigabitEthernet0/0 $q.
    action, command cli 014 'action 1.0 cli enable command '.
    action 015 cli command "action 2.0 cli command $q config t$ q.
    action 016 cli command "action 3.0 cli don't command $q no event manager applet dhcp-intf-timer$ q.
    action 017 cli command "action 4.0 cli don't command $q no event manager applet dhcp-intf-timer-disable$ q.
    action 018 cli command 'end '.

  • Weird, NIC is not getting an IP address from the DHCP server, but when you set a static IP address of works...

    Someone at - it will meet it before? Of course it is in a LAB environment, but what a Win 2012R2 VM is simply not cooperate... lol

    I tried to vMotion there something hot but even. Other virtual machines, 2008 R2 can obtain a static IP address fine as well as works fine. It is the only 2012R2 VM in the LABORATORY.

    No 'ghosts' NIC or whatever it is. It's a new generation of machine virtual Windows.

    Thank you

    EDIT:

    I use the VMXNET3 card.

    Figured it out. Someone added an IP in DHCP address range rule "out for delivery" and they used the whole range of... lol

  • PHP form script is missing from the web server or PHP is not properly configured on your web hosting provider. Help - I get this message on my site when the form is filled out and you press send... Check if the form PHP script has been downloaded correctl

    PHP form script is missing from the web server or PHP is not properly configured on your web hosting provider. Help - I get this message on my site when the form is filled out and you press send... Check if the form PHP script has been downloaded correctly, contact your host about the configuration of PHP.

    Hi Graham,

    If you, please add your site to this link ( http://my-site.com/scripts/form_check.php ) and make sure that all green checkmarks are appearing. If they don't, let us know what errors you seem to receive and include the link to your site.

    In addition, check out this guide on the forums of Muse troubleshooting: Troubleshooting Muse form used on the servers of third party Widgets

    I hope this helps!

    Emily

  • Windows 8 going on the new user interface on the desktop.

    Windows 8 going on the new user interface on the desktop.  I don't want to do.  How can I prevent it from the new UI on the old desktop?

    I ran the install checker and it can and it works fine.

    I found the answer last night with the help of some very helpful tech support from Microsoft.  Find it, it was the touchpad driver.  It was an older version, and once that it has been updated the user interface seems to be 'don't call him underground mode.
    As I said, fine, but we'll see over time.
     
  • Tecra A2 crashes when you are disconnected from the internet

    We have a customer with a Tecra A2 provided by ourselves that, after 5 months without a problem from time to time, hangs when it is disconnected from the internet.
    Reboot the laptop and the internet can be found sometimes up to 20 times and then it blocks again when we disconnect from the internet IE. A Ref post causing VOIP problems were found and the software disabled and disconnected hardware. No difference. Running XP SP2, IE6, Kaspersky Anti Virus, Tiscali ISP ADSL, modem ADSL Tiscal (a new requested just in case). A lot of work to do and lose valuable time with customer problem.
    Thank you

    Hello

    It seems that a 3rd party software causes this very strange problem.
    You suggested that VOIP is causing the problem. Well, the problem is that Toshiba doesn't support any 3rd party software and applications.
    What I can suggest is to check the Event Viewer logs. You will find all the errors that appear on the OS. Double-click the error and you should see the description of Microsoft.
    Maybe you will find a solution.

    Good luck

  • Current file to use when it is disconnected from the network wireless/wired - shared network drive

    Hello

    We have a problem where we receive a "file in use" message when you are disconnected from the network. To reproduce the problem, what we do is:

    (1) connect to the wired network wireless disabled with

    (2) create a test document

    (3) to enter text and save on network share

    (4) remove the network cable

    (5) add additional text

    (6) reconnect the network cable

    (7) try to save the file to the network share

    At the beginning by clicking the X is the new message you want to save. Click Yes and the message arrives until the next time you hit the Hit of X no. and he loses the last change.

    From here we then go up to the network share, open the file and it comes up with "file in use. Open read-only. File is opened by us (Administrator account), and there is NO temporary file in the shared folder.

    Tried so far:

    -Run net config server/autodisconnect:-1 for trying to stop it disconnect the share

    -Checked pane, pane preview and off 'display the description of the pop-up window for folder and desktop items '.

    -Windows Update

    We try to reproduce on wired connection, because it is easier to reproduce that disconnects wireless. Seems to have an impact on several operating systems. Share folder is shared on a Windows 2008 R2 x 64 machine.

    Is this a known problem or is there something that we can configure to try to prevent the locking file after logging out? Ideally, we want the decline to go unnoticed and provide uninterrupted service to the user, unless they are trying to save during the fall.

    Thanks in advance for comments :)

    Hello

    Post your question in the TechNet Server Forums, as your question kindly is beyond the scope of these Forums.

    http://social.technet.Microsoft.com/forums/WindowsServer/en-us/home?category=WindowsServer

    See you soon.

  • File extension is missing when you download files from the web

    I just got a new PC with preinstalled Windows7. From day one, I have the problem that when I download files from the internet while you have no extension, so when I try to run them, told me that they do not have an associated program. I then rename and add the missing extension and all is well. But it's very annoying to have to do every time :(

    I come home from work and now everything works fine - even my webcam which worked yesterday either. Just shows how much it means to close and start fee in time ;)

    Seems that my problem has healed itself, but thanks for the help that was offered to me.

  • How to send the email from the content server?

    How to send the email from the content server? Is this enough to configure the SMTP server with the content server oracle? I want to send a mail generated both system admin system and author of the content when a content is expired. Please suggest how to enable e-mail functionality. Please suggest how the mail will be sent both SYSADMIN and author.

    Thank you

    In particular, this can be achieved by configuring - see EnableExpirationNotifier

  • New content directly from the server

    How can I force my browser to download new content directly from the server? It was possible to do so using the SHIFT key pressed and make page reload at the same time. I tried and it didn't work. I'm doing something wrong?

    You can reload webpages and ignore the cache to refresh potentially stale or corrupt.

    • Hold down the SHIFT key and click the Reload button
    • Press 'Ctrl + F5' or 'Ctrl + Shift + R' (Windows, Linux)
    • Press 'Command + shift + R' (Mac)
  • When I download programs from the internet, they appear just in the form of collections of files TextEditor. How can I convert them into a program.

    When I download programs from the internet, they appear just in the form of collections of files TextEditor. How can I convert them into a program.

    What kind of programs? When you download from? How do download you them?

  • access to the content of the files downloaded from the internet: when I download PDFs from the internet to my documents, they get there but does not open

    When I download PDFs from the internet to my documents, they get there but does not open.

    Download Adobe Reader; Uncheck the box first the Google toolbar:

    http://get.Adobe.com/reader/

    How to set file Associations:

    http://articles.TechRepublic.com.com/5100-10878_11-6172036.html

    How do I... Change file extension associations in Windows Vista?

    See you soon.

    Mick Murphy - Microsoft partner

  • When downloading an app from the trial of creative cloud app error ocured with the message "Download appers corrupted.please try to download again(-60), please provide a guide step by step to solve this problem."

    When downloading an app from the trial of creative cloud app error ocured with the message "Download appers corrupted.please try to download again(-60), please provide a guide step by step to solve this problem."

    Contact adobe support using a Web browser that accepts cookies and allows pop up windows, click here and as soon as it is available, click "still need help," https://helpx.adobe.com/contact.html

  • Recently, when I download files from the SD card, LR6 not rename the files. How can I fix it?

    Recently, when I download files from the SD card, LR6 not rename the files. How can I fix it?

    If I open the folder, not through Lr, I can rename the file. Now, the problem disappeared. Maybe it was related to the DD. I removed and put back in place the protections in SD via the menu of my camera and the problem disappeared. Now, he works as usual. Amount and rename the files by LR. Thank you for your interest

Maybe you are looking for