/usr/share/netdisco/html/public_debugging.html is in netdisco-frontend 1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | <h1 class="pagehead">Debugging information</h1>
<p>
You're visiting this page from <% $r->connection->remote_ip %>.
% if (!defined($arp)) {
I can't find that IP address in my database. Possible reasons:
<ul>
<li>You've just started using the network. I only poll every 10 minutes,
so try again in a bit.
<li>You're using a proxy or VPN, and the address that the web server
sees is not actually the address you're using on the network.
</ul>
% } else {
<p>
I found MAC address <% $arp->{mac} %> in use since <% $arp->{time_first} %>.
<p>
<%perl>
#XXX copied from public_map.html
$ports = sql_rows('node',
['mac','switch','port','active','oui','extract(epoch from time_first) as time_first', 'extract(epoch from time_last) as time_last'],
{mac => $arp->{mac}},
undef,
'order by time_first desc limit 10'
);
# for efficiency: build up a set of 'ip', and use a single sql_rows()
# to get all of them.
my %ipuniq = ();
foreach my $port (@$ports) {
$ipuniq{$port->{switch}} = 1;
}
#XXX could really use a variant of sql_column that returns hash refs for
# multiple returns
my $nameret = sql_rows('device', ['ip','dns','name','location'], {'ip' => [[keys %ipuniq]]});
my %namemap = ();
foreach my $ret (@$nameret) {
$namemap{$ret->{ip}}->{switchname}=$ret->{name} || $ret->{dns};
$namemap{$ret->{ip}}->{switchloc} = $ret->{location};
}
foreach my $port (@$ports) {
$port->{switchname} = $namemap{$port->{switch}}->{switchname} || '';
$port->{switchloc} = $namemap{$port->{switch}}->{switchloc} || '';
$port->{first} = scalar(localtime($port->{time_first}));
$port->{last} = scalar(localtime($port->{time_last}));
}
# XXX We don't care about the locations here, we leave that to the
# png generator. We just care which maps to display.
my $mapret = sql_rows('device_port_location', ['image'], { 'ip' => [[keys %ipuniq]]});
my %maplist = ();
foreach my $entry (@$mapret) {
$maplist{$entry->{image}} = 1;
}
</%perl>
% if (@$ports) {
This MAC address was seen on the following ports:
<ul>
% foreach my $port (@$ports) {
<li>On <% $port->{switchname} %> (<% $port->{switchloc} %>) port <% $port->{port} %> from <% $port->{first} %> to <% $port->{last} %>
% }
</ul>
% } else {
This MAC address hasn't been seen on any ports.
% }
% }
<%init>
# TODO: Get this out of here, big memory hog
use Data::Dumper;
my $arp;
my $ports;
$arp = sql_hash('node_ip', ['mac','ip','time_first'], { ip => $r->connection->remote_ip });
</%init>
<%method title>
- Debugging Info
</%method>
%# $Id: public_debugging.html,v 1.4 2009/06/11 00:22:33 maxbaker Exp $
%# vim:syntax=mason
|