[c-nsp] EEM applets and conditional statements
Ivan Pepelnjak
ip at ioshints.info
Wed Aug 12 00:16:02 EDT 2009
You can do it with EEM 3.0 (12.4(22)T if I'm not mistaken). Unfortunately I
haven't been writing about this feature yet, but here's a sample applet that
compares DHCP-acquired address to the previously-acquired one, maybe it will
come handy:
event manager applet DetectDHCPChange
event syslog pattern "DHCP-6-ADDRESS_ASSIGN"
action 1.0 regexp "Interface (.*) assigned DHCP address ([0-9.]+)"
"$_syslog_msg" match interface ipaddress
action 2.0 context retrieve key DHCP_address variable "addr"
action 2.3 set oldip "$addr"
action 2.4 set addr "$ipaddress"
action 2.5 context save key DHCP_address variable "addr"
action 8.0 if $ipaddress ne $oldip
action 9.1 info type routername
action 9.2 mail server "$_mail_smtp" to "$_mail_rcpt" from
"$_info_routername@$_mail_domain" subject "DHCP address on $interface
changed to $ipaddress" body "\n$_syslog_msg"
action 9.3 syslog msg "address changed to $ipaddress, e-mail sent to the
operator"
action 9.4 else
action 9.5 syslog msg "DHCP address on $interface still $ipaddress"
action 9.9 end
!
event manager applet SetDHCPKey
event syslog pattern "SYS-5-RESTART"
action 1.0 set addr ""
action 1.1 context save key DHCP_address variable "addr"
This article has a sample applet that uses command output (in $_cli_result
variable)
http://wiki.nil.com/Send_a_list_of_high-CPU_processes_on_CPU_overload
Hope this helps
Ivan
http://www.ioshints.info/about
http://blog.ioshints.info/
> -----Original Message-----
> From: Rodney Dunn [mailto:rodunn at cisco.com]
> Sent: Wednesday, August 12, 2009 4:04 AM
> To: Justin Shore
> Cc: 'Cisco-nsp'
> Subject: Re: [c-nsp] EEM applets and conditional statements
>
> I don't think you can do it with an EEM applet to compare
> data in the output. I think you need to do it via a TCL
> script where you can save the variables.
>
> Rodney
>
>
>
> Justin Shore wrote:
> > I'm having trouble figuring out how to use the conditional
> > capabilities of EEM applets to do something fairly simple.
> I'd like
> > to check for DHCP conflicts on a schedule and if any exist
> I'd like to
> > generate a syslog message and send an email. What I can't
> figure out
> > how to do is parse the output of 'sh ip dh con' and if then
> perform an
> > action if there are any conflicts (ie, more than just the single
> > header line in the output). I've gone through some of the EEM
> > community scripts but they all seem to be full blown TCL
> scripts. I'm
> > thinking that I can handle this with a simple applet. The applets
> > have if, for, and while capabilities but I haven't figured
> out how to
> > apply them to parsing command output?
> >
> > Any suggestions or pointers? Example scripts that
> demonstrate how to
> > use the EEM logic capabilities would be fine too. I can build off
> > that to do what I need.
> >
> > Thanks
> > Justin
> >
> >
> > _______________________________________________
> > cisco-nsp mailing list cisco-nsp at puck.nether.net
> > https://puck.nether.net/mailman/listinfo/cisco-nsp
> > archive at http://puck.nether.net/pipermail/cisco-nsp/
>
>
More information about the cisco-nsp
mailing list