#630 display full oui vendor
This commit is contained in:
@@ -257,7 +257,7 @@ sub deploy_oui {
|
|||||||
print color 'reset';
|
print color 'reset';
|
||||||
}
|
}
|
||||||
|
|
||||||
# This subroutine is from Wireshark's make-manuf
|
# This subroutine is baed on Wireshark's make-manuf
|
||||||
# http://anonsvn.wireshark.org/wireshark/trunk/tools/make-manuf
|
# http://anonsvn.wireshark.org/wireshark/trunk/tools/make-manuf
|
||||||
sub shorten {
|
sub shorten {
|
||||||
my $manuf = shift;
|
my $manuf = shift;
|
||||||
@@ -271,22 +271,27 @@ sub shorten {
|
|||||||
# & isn't needed when Standalone
|
# & isn't needed when Standalone
|
||||||
$manuf =~ s/ \& / /g;
|
$manuf =~ s/ \& / /g;
|
||||||
|
|
||||||
|
# remove junk whitespace
|
||||||
|
$manuf =~ s/\s+/ /g;
|
||||||
|
|
||||||
# Remove any "the", "inc", "plc" ...
|
# Remove any "the", "inc", "plc" ...
|
||||||
$manuf
|
$manuf
|
||||||
=~ s/\s(the|inc|incorporated|plc|systems|corp|corporation|s\/a|a\/s|ab|ag|kg|gmbh|co|company|limited|ltd|holding|spa)(?= )//gi;
|
=~ s/\s(?:the|inc|incorporated|plc|systems|corp|corporation|s\/a|a\/s|ab|ag|kg|gmbh|co|company|limited|ltd|holding|spa)(?= )//gi;
|
||||||
|
|
||||||
# Convert to consistent case
|
# Convert to consistent case
|
||||||
$manuf =~ s/(\w+)/\u\L$1/g;
|
$manuf =~ s/(\w+)/\u\L$1/g;
|
||||||
|
|
||||||
# Remove all spaces
|
|
||||||
$manuf =~ s/\s+//g;
|
|
||||||
|
|
||||||
# Deviating from make-manuf for HP
|
# Deviating from make-manuf for HP
|
||||||
$manuf =~ s/Hewlett[-]?Packard/Hp/;
|
$manuf =~ s/Hewlett[-]?Packard/Hp/;
|
||||||
|
|
||||||
# Truncate all names to a reasonable length, say, 8 characters.
|
# Truncate all names to first two words max 20 chars
|
||||||
# If the string contains UTF-8, this may be substantially more than 8 bytes.
|
if (length($manuf) > 21) {
|
||||||
$manuf = substr( $manuf, 0, 8 );
|
my @twowords = grep {defined} (split ' ', $manuf)[0 .. 1];
|
||||||
|
$manuf = join ' ', @twowords;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove all spaces
|
||||||
|
$manuf =~ s/\s+//g;
|
||||||
|
|
||||||
return encode( "utf8", $manuf );
|
return encode( "utf8", $manuf );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ get '/ajax/content/report/nodevendor/data' => require_login sub {
|
|||||||
my $match = $vendor eq 'blank' ? undef : $vendor;
|
my $match = $vendor eq 'blank' ? undef : $vendor;
|
||||||
|
|
||||||
$rs = $rs->search( { 'oui.abbrev' => $match },
|
$rs = $rs->search( { 'oui.abbrev' => $match },
|
||||||
{ '+columns' => [qw/ device.dns device.name oui.abbrev /],
|
{ '+columns' => [qw/ device.dns device.name oui.abbrev oui.company /],
|
||||||
join => [qw/ oui device /],
|
join => [qw/ oui device /],
|
||||||
collapse => 1,
|
collapse => 1,
|
||||||
});
|
});
|
||||||
@@ -86,7 +86,7 @@ get '/ajax/content/report/nodevendor' => require_login sub {
|
|||||||
my $match = $vendor eq 'blank' ? undef : $vendor;
|
my $match = $vendor eq 'blank' ? undef : $vendor;
|
||||||
|
|
||||||
$rs = $rs->search( { 'oui.abbrev' => $match },
|
$rs = $rs->search( { 'oui.abbrev' => $match },
|
||||||
{ '+columns' => [qw/ device.dns device.name oui.abbrev /],
|
{ '+columns' => [qw/ device.dns device.name oui.abbrev oui.company /],
|
||||||
join => [qw/ oui device /],
|
join => [qw/ oui device /],
|
||||||
collapse => 1,
|
collapse => 1,
|
||||||
});
|
});
|
||||||
@@ -102,9 +102,9 @@ get '/ajax/content/report/nodevendor' => require_login sub {
|
|||||||
$rs = $rs->search(
|
$rs = $rs->search(
|
||||||
{ },
|
{ },
|
||||||
{ join => 'oui',
|
{ join => 'oui',
|
||||||
select => [ 'oui.abbrev', { count => {distinct => 'me.mac'}} ],
|
select => [ 'oui.abbrev', 'oui.company', { count => {distinct => 'me.mac'}} ],
|
||||||
as => [qw/ vendor count /],
|
as => [qw/ abbrev vendor count /],
|
||||||
group_by => [qw/ oui.abbrev /]
|
group_by => [qw/ oui.abbrev oui.company /]
|
||||||
}
|
}
|
||||||
)->order_by( { -desc => 'count' } );
|
)->order_by( { -desc => 'count' } );
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ $(document).ready(function() {
|
|||||||
}, {
|
}, {
|
||||||
"data": 'oui.abbrev',
|
"data": 'oui.abbrev',
|
||||||
"render": function(data, type, row, meta) {
|
"render": function(data, type, row, meta) {
|
||||||
return '<a href="[% uri_for('/report/nodevendor') %]?vendor=' + encodeURIComponent(data || 'blank') + '">' + he.encode(data ||'(Unknown Vendor)') + '</a>';
|
return '<a href="[% uri_for('/report/nodevendor') %]?vendor=' + encodeURIComponent(row.oui.abbrev || 'blank') + '">' + he.encode(row.oui.company ||'(Unknown Vendor)') + '</a>';
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"data": 'port',
|
"data": 'port',
|
||||||
@@ -71,7 +71,7 @@ $(document).ready(function() {
|
|||||||
{
|
{
|
||||||
"data": 'vendor',
|
"data": 'vendor',
|
||||||
"render": function(data, type, row, meta) {
|
"render": function(data, type, row, meta) {
|
||||||
return '<a href="[% uri_for('/report/nodevendor') %]?vendor=' + encodeURIComponent(data || 'blank') + '">' + he.encode(data ||'(Unknown Vendor)') + '</a>';
|
return '<a href="[% uri_for('/report/nodevendor') %]?vendor=' + encodeURIComponent(row.abbrev || 'blank') + '">' + he.encode(row.vendor ||'(Unknown Vendor)') + '</a>';
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"data": 'count',
|
"data": 'count',
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
[% USE CSV -%]
|
[% USE CSV -%]
|
||||||
[% IF opt %]
|
[% IF opt %]
|
||||||
[% CSV.dump(['MAC' 'Vendor' 'Company' 'Device' 'Port']) %]
|
[% CSV.dump(['MAC' 'Company' 'Device' 'Port']) %]
|
||||||
|
|
||||||
[% FOREACH row IN results %]
|
[% FOREACH row IN results %]
|
||||||
[% mylist = [] %]
|
[% mylist = [] %]
|
||||||
[% device = row.device.dns || row.device.name || row.switch %]
|
[% device = row.device.dns || row.device.name || row.switch %]
|
||||||
[% FOREACH col IN [ row.mac.upper row.oui.abbrev row.oui.company device row.port ] %]
|
[% FOREACH col IN [ row.mac.upper row.oui.company device row.port ] %]
|
||||||
[% mylist.push(col) %]
|
[% mylist.push(col) %]
|
||||||
[% END %]
|
[% END %]
|
||||||
[% CSV.dump(mylist) %]
|
[% CSV.dump(mylist) %]
|
||||||
|
|||||||
Reference in New Issue
Block a user