On Wed, 19 Oct 2011, Justin J. Novack wrote:

Again, thank you John, David, et. al.

My full solution is posted for reference.  Please feel free to include in
documentation.

/etc/sec/friendlynames.txt
====================
GigabitEthernet1/37=TEST SERVER
GigabitEthernet3/39=IMPORTANT SERVER

/etc/sec/testing.sec
===============
type=Single
desc=Load hashes at startup
ptype=SubStr
continue=TakeNext
pattern=SEC_STARTUP|SEC_RESTART
context=SEC_INTERNAL_EVENT
action=eval %a ( open(FILE, "</etc/sec/friendlynames.txt"); \
   while (<FILE>) { chomp; my ($key, $val) = split /=/; $hash{"$key"} =
$val; })

#Aug  1 12:14:54 switchname 362351: %LINK-3-UPDOWN: Interface
GigabitEthernet1/37, changed state to down
type=Single
desc=Fire Event
ptype=RegExp
pattern=%LINK-3-UPDOWN: Interface ([\w\/]+), changed state to down
context= =($hash{"$1"})
action=eval %host ( return $hash{"$1"}; ); logonly **** Uh-oh! Problem with
%host ****

From here, you can do what you want with %host as normal.

(P.S. - David, since a reload will reload the hashes, does that count as
completing the extra credit? Do contexts persist a  'kill $PID -HUP'?)

I am thinking that they are lost on a -HUP because the -HUP recompiles the rules.

I am thinking that you need something along the lines of

type=Single
desc=Load hashes at startup
ptype=SubStr
continue=TakeNext
pattern=reload friendlynames.txt file
action=eval %a ( open(FILE, "</etc/sec/friendlynames.txt"); %hash=();\
   while (<FILE>) { chomp; my ($key, $val) = split /=/; $hash{"$key"} =
$val; })

since you run things on reload, you probably need the clearing of the hash in your original version as well (since this file is something that usually only grows, the fact that a reload would not remove an entry from the hash is probably not a big problem, but in other contexts it will matter)

David Lang
------------------------------------------------------------------------------

The demand for IT networking professionals continues to grow, and the

demand for specialized networking skills is growing even more rapidly.

Take a complimentary Learning@Ciosco Self-Assessment and learn 

about Cisco certifications, training, and career opportunities. 

http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________

Simple-evcorr-users mailing list

[email protected]

https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Ciosco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Simple-evcorr-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

Reply via email to