Subversion Repositories sysadmin_scripts

Rev

Rev 136 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 136 Rev 164
Line 62... Line 62...
62
# then third column (mac address )
62
# then third column (mac address )
63
# NOTE: this is not csv safe; only works for tab delimited
63
# NOTE: this is not csv safe; only works for tab delimited
64
sub sortArray {
64
sub sortArray {
65
   my @a = split( "\t", $a );
65
   my @a = split( "\t", $a );
66
   my @b = split( "\t", $b );
66
   my @b = split( "\t", $b );
67
   return $a[0] cmp $b[0] || $a[1] <=> $b[1] || $a[4] cmp $b[4];
67
   return $a[0] cmp $b[0] || $a[2] <=> $b[2] || $a[5] cmp $b[5];
68
}
68
}
69
 
69
 
70
 
70
 
71
# simple display if --help is passed
71
# simple display if --help is passed
72
sub help {
72
sub help {
Line 114... Line 114...
114
my @out;
114
my @out;
115
 
115
 
116
foreach my $mac ( keys %{ $saveFile->{'macList'} } ) {
116
foreach my $mac ( keys %{ $saveFile->{'macList'} } ) {
117
   my $switchName = $saveFile->{'switchInfo'}->{$saveFile->{'macList'}->{$mac}->{'switch'}}->{'name'};
117
   my $switchName = $saveFile->{'switchInfo'}->{$saveFile->{'macList'}->{$mac}->{'switch'}}->{'name'};
118
   my $portAlias =  $saveFile->{'switchInfo'}->{$saveFile->{'macList'}->{$mac}->{'switch'}}->{'ports'}->{$saveFile->{'macList'}->{$mac}->{'port'}}->{'alias'};
118
   my $portAlias =  $saveFile->{'switchInfo'}->{$saveFile->{'macList'}->{$mac}->{'switch'}}->{'ports'}->{$saveFile->{'macList'}->{$mac}->{'port'}}->{'alias'};
-
 
119
   my $portDescription =  $saveFile->{'switchInfo'}->{$saveFile->{'macList'}->{$mac}->{'switch'}}->{'ports'}->{$saveFile->{'macList'}->{$mac}->{'port'}}->{'description'};
119
   push @out, &dumpLine( 
120
   push @out, &dumpLine( 
120
      $delimiter, 
121
      $delimiter, 
121
      $encapsulate, 
122
      $encapsulate, 
122
      $saveFile->{'macList'}->{$mac}->{'switch'}, 
123
      $saveFile->{'macList'}->{$mac}->{'switch'}, 
123
      $saveFile->{'macList'}->{$mac}->{'port'},
-
 
124
      $switchName,
124
      $switchName,
-
 
125
      $saveFile->{'macList'}->{$mac}->{'port'},
125
      $portAlias,
126
      $portAlias,
-
 
127
      $portDescription,
126
      &prettyMAC( $mac ),
128
      &prettyMAC( $mac ),
127
      $saveFile->{'macList'}->{$mac}->{'ip'},
129
      $saveFile->{'macList'}->{$mac}->{'ip'},
128
      $saveFile->{'macList'}->{$mac}->{'hostname'},
130
      $saveFile->{'macList'}->{$mac}->{'hostname'},
129
      &prettyTime( $saveFile->{'macList'}->{$mac}->{'lastseen'} )
131
      &prettyTime( $saveFile->{'macList'}->{$mac}->{'lastseen'} )
130
   );
132
   );
131
}
133
}
132
 
134
 
133
print &dumpLine(
135
print &dumpLine(
134
   $delimiter, 
136
   $delimiter, 
135
   $encapsulate, 
137
   $encapsulate, 
136
   'switch','port','alias','description','mac','ip','host_name','last_seen'
138
   'switch','switch_name','port','alias','description','mac','ip','host_name','last_seen'
137
   );
139
   );
138
 
140
 
139
print sort sortArray @out;
141
print sort sortArray @out;
140
 
142
 
141
1;
143
1;