#!/usr/bin/perl # # Run 3cglobalcache in parallel batch mode using xargs # to update the global bridge table cache # # $Id: batch-cacheupdate,v 1.6 2002/04/11 13:45:01 trockij Exp $ use Getopt::Std; getopts ("dhvAa:p:s:n:", \%opt); $SWLIST = "swlist"; $SWLIST = "$ENV{HOME}/a3com/switchlist"; $ARPFILE = "$ENV{HOME}/a3com/routerlist"; $SWLIST = $opt{"s"} if ($opt{"s"}); $ARPFILE = $opt{"a"} if ($opt{"a"}); $NUM = $opt{"n"} || 5; # # this requires the GNU xargs for the -P option # $XARGS = "xargs -P$NUM -l1 -n1"; $GC = "./3cglobalcache"; if ($opt{"v"}) { $XARGS .= " -t"; } if ($opt{"d"}) { $GC .= " -d"; } if ($opt{"p"}) { $GC .= " -p $opt{p}"; } # # bridge tables # if (!$opt{"A"}) { open (I, $SWLIST) || die "could not open switch list: $!\n"; while () { next if (/^\s*#/ || /^\s*$/); chomp; push @sw, $_; } close (I); open (O, "| $XARGS $GC -b") || die "could not open pipe to xargs: $!\n"; for (@sw) { print O "$_\n"; } close (O); # # ARP history table # } else { system ("$GC -a $ARPFILE"); }