Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MAC address script

Status
Not open for further replies.

jaybed

MIS
Aug 30, 2005
5
GB
Hi

I'm trying to creat a script which will run at a specified time interval. The script will then do a show fdb to bring up a list of currently connected MAC addresses. It will then compare that list with a list I have created. If a MAC appears from the show fdb list that is not in my list it should create a log entry. I can then set up syslog alerting for those messages. The reason why I want this is to be a able to see when people connect wireless devices into our network. The list of MACs in my list will include Dell, HP, etc so will be a large list, hence the use of a timed script rather than on a port up/down message.

I'm still unable to get this working. I have simplified it by putting 1 MAC in my list for now. I have also tried to remove some of the crap from the show fdb list. I also want to know how to get the list to put the next MAC on a new line when it runs show var list 2.

Here is the output from the switch, if anyone can offer some assistance that would be great. If you look at the show log section it looks to have not matched list2, (the fdb table) with list3, my list of MACS. Whether its the formatting of list 2 which is the issue I don't know.

Obvioulsy my create log entries will be something better than yeah or aaagh!!! ;o)


commstestsw.12 # sh upm pro "MAC1"
Created at : 2011-01-31 11:52:30
Last edited at : 2011-01-31 11:52:30

************Profile Contents Begin************
enable cli scripting output
set var CLI.OUT " "
show fdb
set var list1 $TCL(split ${CLI.OUT} "\n")
set var list2 $TCL(lrange $(list1) 2 end-9)
show var list1
show var list2
set var list3 $TCL(list "00:1C:23")
show var list3
if (!$match($list2, $list3)) then
create log entry yeah
else
create log entry aaagh
endif

************Profile Contents Ends*************

Profile State: Enabled
Profile Maximimum Execution Time: 30
Events and ports configured on the profile:
===========================================================
Event Port list/Log filter
===========================================================
device-detect :
device-undetect :
user-authenticated :
user-unauthenticated :
===========================================================




commstestsw.14 # sh upm timers
Current Time: 2011-01-31 12:08:50
--------------------------------------------------------------------------------
UPM Profile Flags Next Execution
Timer Name time
--------------------------------------------------------------------------------
test MAC1 ep 2011-01-31 12:09:41(Every 60 secs)
--------------------------------------------------------------------------------
Flags: e - Profile is enabled, d: Profile is disabled
o -Timer is non-periodic, p - Timer is periodic




commstestsw.10 # sh upm hi ex 15

UPM Profile: MAC1
Event: test
Profile Execution start time: 2011-01-31 12:06:41
Profile Execution Finish time: 2011-01-31 12:06:41
Execution Identifier: 15 Execution Status: Pass

Execution Information:
1 # enable cli scripting
2 # configure cli mode non-persistent
3 # set var EVENT.TIMER_NAME test
4 # set var EVENT.NAME TIMER-AFTER
5 # set var EVENT.TIMER_TYPE PERIODIC
6 # set var EVENT.TIME 1296475601
7 # set var EVENT.TIMER_LATE_SECS 0
8 # set var EVENT.PROFILE MAC1
9 # enable cli scripting output
10 # set var CLI.OUT " "
11 # show fdb
Mac Vlan Age Flags Port / Virtual Port List
-----------------------------------------------------------------------------
00:1c:23:3e:60:0f test(4094) 0033 d m 1

Flags : d - Dynamic, s - Static, p - Permanent, n - NetLogin, m - MAC, i - IP,
x - IPX, l - lockdown MAC, L - lockdown-timeout MAC, M- Mirror, B - Egress Blackhole,
b - Ingress Blackhole, v - MAC-Based VLAN, P - Private VLAN, T - VLAN translation,
D - drop packet.

Total: 1 Static: 0 Perm: 0 Dyn: 1 Dropped: 0 Locked: 0 Locked with Timeout: 0
FDB Aging time: 300
FDB VPLS Aging time: 300
12 # set var list1 $TCL(split ${CLI.OUT} "\n")
13 # set var list2 $TCL(lrange $(list1) 2 end-9)
14 # show var list1
{Mac Vlan Age Flags Port / Virtual Port List} ----------------------------------------------------------------------------- {00:1c:23:3e:60:0f test(4094) 0033 d m 1} {} {Flags : d - Dynamic, s - Static, p - Permanent, n - NetLogin, m - MAC, i - IP,} { x - IPX, l - lockdown MAC, L - lockdown-timeout MAC, M- Mirror, B - Egress Blackhole,} { b - Ingress Blackhole, v - MAC-Based VLAN, P - Private VLAN, T - VLAN translation,} { D - drop packet.} {} {Total: 1 Static: 0 Perm: 0 Dyn: 1 Dropped: 0 Locked: 0 Locked with Timeout: 0} {FDB Aging time: 300} {FDB VPLS Aging time: 300} {}
15 # show var list2
{00:1c:23:3e:60:0f test(4094) 0033 d m 1} {}
16 # set var list3 $TCL(list "00:1C:23")
17 # show var list3
00:1C:23
18 # if (!$match($list2, $list3)) then
19 # create log entry yeah
20 # else
21 # create log entry aaagh
22 # endif


Number of UPM Events in Queue for execution: 0




01/31/2011 12:05:41.76 <Info:System.userComment> aaagh
01/31/2011 12:05:41.76 <Info:cli.logLocalCmd> serial UPM: create log entry aaagh
01/31/2011 12:05:41.76 <Info:cli.logLocalCmd> serial UPM: if (!1) then
01/31/2011 12:05:41.76 <Info:cli.logLocalCmd> serial UPM: show var list3
01/31/2011 12:05:41.75 <Info:cli.logLocalCmd> serial UPM: set var list3 $TCL(list "00:1C:23")
01/31/2011 12:05:41.75 <Info:cli.logLocalCmd> serial UPM: show var list2
01/31/2011 12:05:41.75 <Info:cli.logLocalCmd> serial UPM: show var list1
01/31/2011 12:05:41.74 <Info:cli.logLocalCmd> serial UPM: set var list2 $TCL(lrange $list1 2 end-9)
01/31/2011 12:05:41.73 <Info:cli.logLocalCmd> serial UPM: set var list1 $TCL(split ${CLI.OUT} "\n")
01/31/2011 12:05:41.68 <Info:cli.logLocalCmd> serial UPM: set var CLI.OUT " "
01/31/2011 12:05:41.68 <Info:cli.logLocalCmd> serial UPM: enable cli scripting output
01/31/2011 12:05:41.68 <Info:cli.logLocalCmd> serial UPM: set var EVENT.PROFILE MAC1
01/31/2011 12:05:41.67 <Info:cli.logLocalCmd> serial UPM: set var EVENT.TIMER_LATE_SECS 0
01/31/2011 12:05:41.67 <Info:cli.logLocalCmd> serial UPM: set var EVENT.TIME 1296475541
01/31/2011 12:05:41.67 <Info:cli.logLocalCmd> serial UPM: set var EVENT.TIMER_TYPE PERIODIC
01/31/2011 12:05:41.67 <Info:cli.logLocalCmd> serial UPM: set var EVENT.NAME TIMER-AFTER
01/31/2011 12:05:41.66 <Info:cli.logLocalCmd> serial UPM: set var EVENT.TIMER_NAME test
01/31/2011 12:05:41.66 <Info:cli.logLocalCmd> serial UPM: configure cli mode non-persistent
01/31/2011 12:05:41.66 <Info:cli.logLocalCmd> serial UPM: enable cli scripting
01/31/2011 12:05:41.57 <Noti:UPM.Msg.upmMsgExshLaunch> Launched profile MAC1 for the event UPM Timer test


Cheers


Jay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top