implement connected devices list for ports
This commit is contained in:
@@ -64,16 +64,48 @@ __PACKAGE__->set_primary_key("port", "ip");
|
|||||||
# Created by DBIx::Class::Schema::Loader v0.07015 @ 2012-01-07 14:20:02
|
# Created by DBIx::Class::Schema::Loader v0.07015 @ 2012-01-07 14:20:02
|
||||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lcbweb0loNwHoWUuxTN/hA
|
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lcbweb0loNwHoWUuxTN/hA
|
||||||
|
|
||||||
|
__PACKAGE__->has_many( nodes => 'Netdisco::DB::Result::Node',
|
||||||
|
{
|
||||||
|
'foreign.switch' => 'self.ip',
|
||||||
|
'foreign.port' => 'self.port',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prefetch => 'ips',
|
||||||
|
order_by => 'me.mac',
|
||||||
|
'+select' => [
|
||||||
|
\"replace(age(me.time_last, me.time_recent)::text, 'mon', 'month')",
|
||||||
|
],
|
||||||
|
'+as' => [
|
||||||
|
'me.time_last',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
sub get_nodes {
|
||||||
|
my ($row, $archive) = @_;
|
||||||
|
return $row->nodes({ ($archive ? () : ('me.active' => 1, 'ips.active' => 1)) });
|
||||||
|
}
|
||||||
|
|
||||||
|
__PACKAGE__->belongs_to( neighbor_alias => 'Netdisco::DB::Result::DeviceIp',
|
||||||
|
{
|
||||||
|
'foreign.alias' => 'self.remote_ip',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
join_type => 'left',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
# FIXME make this more efficient by specifying the full join to DBIC
|
||||||
|
sub neighbor { return eval { (shift)->neighbor_alias->device } }
|
||||||
__PACKAGE__->belongs_to( device => 'Netdisco::DB::Result::Device', 'ip',
|
__PACKAGE__->belongs_to( device => 'Netdisco::DB::Result::Device', 'ip',
|
||||||
{
|
{
|
||||||
'+select' => [
|
'+select' => [
|
||||||
\"replace(age(timestamp 'epoch' + uptime / 100 * interval '1 second', timestamp '1970-01-01 00:00:00-00')::text, 'mon', 'month')",
|
\"replace(age(timestamp 'epoch' + uptime / 100 * interval '1 second', timestamp '1970-01-01 00:00:00-00')::text, 'mon', 'month')",
|
||||||
\"to_char(last_discover, 'YYYY-MM-DD HH24:MI')",
|
\"to_char(last_discover, 'YYYY-MM-DD HH24:MI')",
|
||||||
\"to_char(last_macsuck, 'YYYY-MM-DD HH24:MI')",
|
\"to_char(last_macsuck, 'YYYY-MM-DD HH24:MI')",
|
||||||
\"to_char(last_arpnip, 'YYYY-MM-DD HH24:MI')",
|
\"to_char(last_arpnip, 'YYYY-MM-DD HH24:MI')",
|
||||||
],
|
],
|
||||||
'+as' => [qw/ uptime last_discover last_macsuck last_arpnip /],
|
'+as' => [qw/ uptime last_discover last_macsuck last_arpnip /],
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
__PACKAGE__->has_many( port_vlans_tagged => 'Netdisco::DB::Result::DevicePortVlan',
|
__PACKAGE__->has_many( port_vlans_tagged => 'Netdisco::DB::Result::DevicePortVlan',
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
[% FOREACH item IN vars.port_columns %]
|
[% FOREACH item IN vars.port_columns %]
|
||||||
[% NEXT UNLESS params.${item.name} %]
|
[% NEXT UNLESS params.${item.name} %]
|
||||||
<th[% ' class="center_cell"' IF NOT loop.first %]>[% item.label %]</th>
|
<th[% ' class="center_cell"' IF NOT loop.first %]>[% item.label %]</th>
|
||||||
[% END %]
|
[% END %]
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -74,15 +74,44 @@
|
|||||||
[% SET count = count + 1 %]
|
[% SET count = count + 1 %]
|
||||||
[% END %]
|
[% END %]
|
||||||
[% IF count > 10 %]
|
[% IF count > 10 %]
|
||||||
[% SET output = '<div class="vlan_total">(' _ count _ ')</div><a href="#" class="nd_linkcell nd_collapse_vlans">'
|
[% SET output = '<div class="vlan_total">(' _ count _ ')</div><a href="#" class="nd_linkcell nd_collapse_vlans">'
|
||||||
_ 'Show VLANs</a><div class="nd_collapse_pre_hidden">' _ output %]
|
_ 'Show VLANs</a><div class="nd_collapse_pre_hidden">' _ output %]
|
||||||
[% SET output = output _ '</div>' %]
|
[% SET output = output _ '</div>' %]
|
||||||
[% END %]
|
[% END %]
|
||||||
[% output %]
|
[% output %]
|
||||||
</td>
|
</td>
|
||||||
[% END %]
|
[% END %]
|
||||||
[% IF params.c_connected %]
|
[% IF params.c_connected %]
|
||||||
<td>[% row.connected | html_entity %]</td>
|
<td>
|
||||||
|
[% IF row.remote_ip %]
|
||||||
|
[% IF row.neighbor %]
|
||||||
|
<a href="/device?tab=ports&ip=[% row.neighbor.ip | uri %]&q=[% row.remote_port | uri %]">
|
||||||
|
[% row.neighbor.dns.remove(settings.domain_suffix) || row.neighbor.ip %]
|
||||||
|
([% row.remote_port | html_entity %])</a>
|
||||||
|
[% ELSE %]
|
||||||
|
<span class="label important">n</span>
|
||||||
|
<a href="/search?tab=node&q=[% row.remote_ip | uri %]">[% row.remote_ip %] ([% row.remote_port %])
|
||||||
|
<br/> ([% row.remote_type %]) / ([% row.remote_id %]</a>
|
||||||
|
[% END %]
|
||||||
|
[% END %]
|
||||||
|
[% FOREACH node IN row.get_nodes(params.n_archived) %]
|
||||||
|
[% '<br/>' IF row.remote_ip OR NOT loop.first %]
|
||||||
|
[% '<span class="label warning">a</span> ' IF NOT node.active %]
|
||||||
|
<a href="/search?tab=node&q=[% node.mac | uri %]">[% node.mac %]</a>
|
||||||
|
[% ' (' _ node.time_last _ ')' IF params.n_age %]
|
||||||
|
[% IF params.n_ip %]
|
||||||
|
[% FOREACH ip IN node.ips %]
|
||||||
|
<br/> [% '<span class="label warning">a</span> ' IF NOT node.active %]
|
||||||
|
[% SET dns = ip.dns %]
|
||||||
|
[% IF dns %]
|
||||||
|
<a href="/search?tab=node&q=[% ip.ip | uri %]">[% ip.dns %] ([% ip.ip %])</a>
|
||||||
|
[% ELSE %]
|
||||||
|
<a href="/search?tab=node&q=[% ip.ip | uri %]">[% ip.ip %]</a>
|
||||||
|
[% END %]
|
||||||
|
[% END %]
|
||||||
|
[% END %]
|
||||||
|
[% END %]
|
||||||
|
</td>
|
||||||
[% END %]
|
[% END %]
|
||||||
[% IF params.c_stp %]
|
[% IF params.c_stp %]
|
||||||
<td class="center_cell">[% row.stp | html_entity %]</td>
|
<td class="center_cell">[% row.stp | html_entity %]</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user