Subject: | fixes for the dhcp-lease contrib script |
Date: | Sat, 12 Dec 2015 12:56:26 -0500 |
To: | dhcp-bugs@isc.org |
From: | "Antoine Beaupré" <anarcat@debian.org> |
the contrib/dhcp-lease-list.pl script is great! unfortunately, it seems
it trims the MAC addresses when the oui lookup is enabled, probably
because of garbage in the oui.txt file. For example:
MAC IP hostname valid until manufacturer
===============================================================================================
80:6c:1b:2e:54:f0 192.168.0.186 android-4e25a30330d9195a2015-12-12 17:41:18 Motorola Mobility LLC, a Lenovo Company
:f9:9d:d7 192.168.0.182 iMac-de-mac-4962015-12-12 18:22:02 Apple, Inc.
:35:24:50 192.168.0.189 SimonVV 2015-12-12 18:06:01 Apple, Inc.
e8:9a:8f:6e:0f:60 192.168.0.127 angela 2015-12-12 17:42:52 Quanta Computer Inc.
ec:55:f9:c5:f2:55 192.168.0.179 angela 2015-12-12 17:40:18 Hon Hai Precision Ind. Co.,Ltd.
9e:dc 192.168.0.183 -NA- 2015-12-12 17:42:59 Private
f4:ec:38:e2:f9:67 192.168.0.185 -NA- 2015-12-12 17:41:31 TP-LINK TECHNOLOGIES CO.,LTD.
f8:d1:11:b7:5a:62 192.168.0.184 -NA- 2015-12-12 17:43:05 TP-LINK TECHNOLOGIES CO.,LTD.
notice the blank spaces with some manufacturers. i suspect some control
characters are garbling the display. The following patch cleans up the
whitespace on both sides of the manufacturer string, which fixes the
problem for me. It also fixes the width of the hostname field which was
garbling the display above:
--- dhcp-lease-list.pl.orig 2015-12-12 12:30:00.000000000 -0500
+++ dhcp-lease-list.pl 2015-12-12 12:54:31.000000000 -0500
@@ -41,7 +41,7 @@
if (defined $oui) {
$manu = join('-', ($_[0] =~ /^(..):(..):(..):/));
$manu = `grep -i '$manu' $oui | cut -f3`;
- chomp($manu);
+ $manu =~ s/^\s+|\s+$//g;
}
return $manu;
@@ -142,7 +142,7 @@
}
foreach (@leases) {
if ($opt_format eq 'human') {
- printf("%-19s%-16s%-15s%-20s%-20s\n",
+ printf("%-19s%-16s%-14.14s %-20s%-20s\n",
$_->{'mac'}, # MAC
$_->{'ip'}, # IP address
$_->{'hostname'}, # hostname
The resulting output looks much better:
MAC IP hostname valid until manufacturer
===============================================================================================
80:6c:1b:2e:54:f0 192.168.0.186 android-4e25a3 2015-12-12 17:55:44 Motorola Mobility LLC, a Lenovo Company
90:27:e4:f9:9d:d7 192.168.0.182 iMac-de-mac-49 2015-12-12 18:22:02 Apple, Inc.
b8:8d:12:35:24:50 192.168.0.189 SimonVV 2015-12-12 18:06:01 Apple, Inc.
e8:9a:8f:6e:0f:60 192.168.0.127 angela 2015-12-12 17:55:45 Quanta Computer Inc.
ec:55:f9:c5:f2:55 192.168.0.179 angela 2015-12-12 17:58:25 Hon Hai Precision Ind. Co.,Ltd.
f0:4f:7c:3f:9e:dc 192.168.0.183 kindle-6814334 2015-12-12 17:58:05 Private
f4:ec:38:e2:f9:67 192.168.0.185 -NA- 2015-12-12 17:56:31 TP-LINK TECHNOLOGIES CO.,LTD.
f8:d1:11:b7:5a:62 192.168.0.184 -NA- 2015-12-12 17:58:05 TP-LINK TECHNOLOGIES CO.,LTD.
Thanks!
A.
--
N'aimer qu'un seul est barbarie, car c'est au détriment de tous les
autres. Fût-ce l'amour de Dieu.
- Nietzsche, "Par delà le bien et le mal"