relocate repo files so ND2 is the only code
This commit is contained in:
19
lib/App/Netdisco/DB/Result/Virtual/ActiveNode.pm
Normal file
19
lib/App/Netdisco/DB/Result/Virtual/ActiveNode.pm
Normal file
@@ -0,0 +1,19 @@
|
||||
use utf8;
|
||||
package App::Netdisco::DB::Result::Virtual::ActiveNode;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'App::Netdisco::DB::Result::Node';
|
||||
|
||||
__PACKAGE__->load_components('Helper::Row::SubClass');
|
||||
__PACKAGE__->subclass;
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
__PACKAGE__->table("active_node");
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(q{
|
||||
SELECT * FROM node WHERE active
|
||||
});
|
||||
|
||||
1;
|
||||
27
lib/App/Netdisco/DB/Result/Virtual/ActiveNodeWithAge.pm
Normal file
27
lib/App/Netdisco/DB/Result/Virtual/ActiveNodeWithAge.pm
Normal file
@@ -0,0 +1,27 @@
|
||||
use utf8;
|
||||
package App::Netdisco::DB::Result::Virtual::ActiveNodeWithAge;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'App::Netdisco::DB::Result::Virtual::ActiveNode';
|
||||
|
||||
__PACKAGE__->load_components('Helper::Row::SubClass');
|
||||
__PACKAGE__->subclass;
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
__PACKAGE__->table("active_node_with_age");
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(q{
|
||||
SELECT *,
|
||||
replace( date_trunc( 'minute', age( now(), time_last + interval '30 second' ) ) ::text, 'mon', 'month')
|
||||
AS time_last_age
|
||||
FROM node WHERE active
|
||||
});
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
"time_last_age",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
);
|
||||
|
||||
1;
|
||||
71
lib/App/Netdisco/DB/Result/Virtual/ApRadioChannelPower.pm
Normal file
71
lib/App/Netdisco/DB/Result/Virtual/ApRadioChannelPower.pm
Normal file
@@ -0,0 +1,71 @@
|
||||
package App::Netdisco::DB::Result::Virtual::ApRadioChannelPower;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table('ap_radio_channel_power');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
|
||||
SELECT w.channel,
|
||||
w.power,
|
||||
w.ip,
|
||||
w.port,
|
||||
dp.name AS port_name,
|
||||
dp.descr,
|
||||
d.name AS device_name,
|
||||
d.dns,
|
||||
d.model,
|
||||
d.location,
|
||||
CASE
|
||||
WHEN w.power > 0 THEN round((10.0 * log(w.power) / log(10))::numeric, 1)
|
||||
ELSE NULL
|
||||
END AS power2
|
||||
FROM device_port_wireless AS w
|
||||
JOIN device_port AS dp ON dp.port = w.port
|
||||
AND dp.ip = w.ip
|
||||
JOIN device AS d ON d.ip = w.ip
|
||||
WHERE w.channel != '0'
|
||||
ENDSQL
|
||||
);
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
'channel' => {
|
||||
data_type => 'integer',
|
||||
},
|
||||
'power' => {
|
||||
data_type => 'integer',
|
||||
},
|
||||
'ip' => {
|
||||
data_type => 'inet',
|
||||
},
|
||||
'port' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'port_name' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'descr' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'device_name' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'dns' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'model' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'location' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'power2' => {
|
||||
data_type => 'numeric',
|
||||
},
|
||||
);
|
||||
|
||||
1;
|
||||
50
lib/App/Netdisco/DB/Result/Virtual/CidrIps.pm
Normal file
50
lib/App/Netdisco/DB/Result/Virtual/CidrIps.pm
Normal file
@@ -0,0 +1,50 @@
|
||||
package App::Netdisco::DB::Result::Virtual::CidrIps;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use utf8;
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table('cidr_ips');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<'ENDSQL');
|
||||
SELECT host(network (prefix) + sub.int)::inet AS ip,
|
||||
NULL AS mac,
|
||||
NULL::text AS dns,
|
||||
NULL::timestamp AS time_first,
|
||||
NULL::timestamp AS time_last,
|
||||
false::boolean AS active
|
||||
FROM (
|
||||
SELECT prefix,
|
||||
generate_series(1, (broadcast(prefix) - network(prefix) - 1)) AS int
|
||||
FROM (
|
||||
SELECT ?::inet AS prefix
|
||||
) AS addr
|
||||
) AS sub
|
||||
ENDSQL
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
"ip",
|
||||
{ data_type => "inet", is_nullable => 0 },
|
||||
"mac",
|
||||
{ data_type => "macaddr", is_nullable => 1 },
|
||||
"dns",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"active",
|
||||
{ data_type => "boolean", is_nullable => 1 },
|
||||
"time_first",
|
||||
{
|
||||
data_type => "timestamp",
|
||||
is_nullable => 1,
|
||||
},
|
||||
"time_last",
|
||||
{
|
||||
data_type => "timestamp",
|
||||
is_nullable => 1,
|
||||
},
|
||||
);
|
||||
|
||||
1;
|
||||
24
lib/App/Netdisco/DB/Result/Virtual/DeviceDnsMismatch.pm
Normal file
24
lib/App/Netdisco/DB/Result/Virtual/DeviceDnsMismatch.pm
Normal file
@@ -0,0 +1,24 @@
|
||||
package App::Netdisco::DB::Result::Virtual::DeviceDnsMismatch;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use utf8;
|
||||
use base 'App::Netdisco::DB::Result::Device';
|
||||
|
||||
__PACKAGE__->load_components('Helper::Row::SubClass');
|
||||
__PACKAGE__->subclass;
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
__PACKAGE__->table('device_dns_mismatch');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<'ENDSQL');
|
||||
SELECT *
|
||||
FROM device
|
||||
WHERE dns IS NULL
|
||||
OR name IS NULL
|
||||
OR regexp_replace(lower(dns), ? || '$', '')
|
||||
!= regexp_replace(lower(name), ? || '$', '')
|
||||
ENDSQL
|
||||
|
||||
1;
|
||||
48
lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm
Normal file
48
lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm
Normal file
@@ -0,0 +1,48 @@
|
||||
package App::Netdisco::DB::Result::Virtual::DeviceLinks;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table('device_links');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
|
||||
SELECT dp.ip AS left_ip, dp.port AS left_port, di.ip AS right_ip, dp.remote_port AS right_port
|
||||
FROM ( SELECT device_port.ip, device_port.port, device_port.remote_ip, device_port.remote_port
|
||||
FROM device_port
|
||||
WHERE device_port.remote_port IS NOT NULL
|
||||
GROUP BY device_port.ip, device_port.port, device_port.remote_ip, device_port.remote_port
|
||||
ORDER BY device_port.ip) dp
|
||||
LEFT JOIN device_ip di ON dp.remote_ip = di.alias
|
||||
WHERE di.ip IS NOT NULL
|
||||
ORDER BY dp.ip
|
||||
ENDSQL
|
||||
);
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
'left_ip' => {
|
||||
data_type => 'inet',
|
||||
},
|
||||
'left_port' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'right_ip' => {
|
||||
data_type => 'inet',
|
||||
},
|
||||
'right_port' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
);
|
||||
|
||||
__PACKAGE__->has_many('left_vlans', 'App::Netdisco::DB::Result::DevicePortVlan',
|
||||
{ 'foreign.ip' => 'self.left_ip', 'foreign.port' => 'self.left_port' },
|
||||
{ join_type => 'INNER' } );
|
||||
|
||||
__PACKAGE__->has_many('right_vlans', 'App::Netdisco::DB::Result::DevicePortVlan',
|
||||
{ 'foreign.ip' => 'self.right_ip', 'foreign.port' => 'self.right_port' },
|
||||
{ join_type => 'INNER' } );
|
||||
|
||||
1;
|
||||
87
lib/App/Netdisco/DB/Result/Virtual/DevicePoeStatus.pm
Normal file
87
lib/App/Netdisco/DB/Result/Virtual/DevicePoeStatus.pm
Normal file
@@ -0,0 +1,87 @@
|
||||
package App::Netdisco::DB::Result::Virtual::DevicePoeStatus;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table('device_poe_status');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<'ENDSQL');
|
||||
SELECT DISTINCT ON (dp.ip,dp.module)
|
||||
dp.ip,
|
||||
dp.module,
|
||||
dp.power::bigint,
|
||||
dp.status,
|
||||
d.dns,
|
||||
d.name,
|
||||
d.model,
|
||||
d.location,
|
||||
COUNT(dpp.port) OVER (PARTITION BY dp.ip, dp.module) AS poe_capable_ports,
|
||||
SUM(CASE WHEN dpp.status = 'deliveringPower' THEN 1 ELSE 0 END) OVER (PARTITION BY dp.ip, dp.module) AS poe_powered_ports,
|
||||
SUM(CASE WHEN dpp.admin = 'false' THEN 1 ELSE 0 END) OVER (PARTITION BY dp.ip, dp.module) AS poe_disabled_ports,
|
||||
SUM(CASE WHEN dpp.status ILIKE '%fault' THEN 1
|
||||
ELSE 0 END) OVER (PARTITION BY dp.ip, dp.module) AS poe_errored_ports,
|
||||
SUM(CASE WHEN dpp.status = 'deliveringPower' AND dpp.class = 'class4' THEN 30.0
|
||||
WHEN dpp.status = 'deliveringPower' AND dpp.class = 'class2' THEN 7.0
|
||||
WHEN dpp.status = 'deliveringPower' AND dpp.class = 'class1' THEN 4.0
|
||||
WHEN dpp.status = 'deliveringPower' AND dpp.class = 'class3' THEN 15.4
|
||||
WHEN dpp.status = 'deliveringPower' AND dpp.class = 'class0' THEN 15.4
|
||||
WHEN dpp.status = 'deliveringPower' AND dpp.class IS NULL THEN 15.4
|
||||
ELSE 0 END) OVER (PARTITION BY dp.ip, dp.module) AS poe_power_committed,
|
||||
SUM(CASE WHEN (dpp.power IS NULL OR dpp.power = '0') THEN 0
|
||||
ELSE round(dpp.power/1000.0, 1) END) OVER (PARTITION BY dp.ip, dp.module) AS poe_power_delivering
|
||||
FROM device_power dp
|
||||
JOIN device_port_power dpp ON dpp.ip = dp.ip
|
||||
AND dpp.module = dp.module
|
||||
JOIN device d ON dp.ip = d.ip
|
||||
ENDSQL
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
'ip' => {
|
||||
data_type => 'inet',
|
||||
},
|
||||
'module' => {
|
||||
data_type => 'integer',
|
||||
},
|
||||
'power' => {
|
||||
data_type => 'integer',
|
||||
},
|
||||
'status' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'dns' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'name' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'model' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'location' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'poe_capable_ports' => {
|
||||
data_type => 'bigint',
|
||||
},
|
||||
'poe_powered_ports' => {
|
||||
data_type => 'bigint',
|
||||
},
|
||||
'poe_disabled_ports' => {
|
||||
data_type => 'bigint',
|
||||
},
|
||||
'poe_errored_ports' => {
|
||||
data_type => 'bigint',
|
||||
},
|
||||
'poe_power_committed' => {
|
||||
data_type => 'numeric',
|
||||
},
|
||||
'poe_power_delivering' => {
|
||||
data_type => 'numeric',
|
||||
},
|
||||
);
|
||||
|
||||
1;
|
||||
61
lib/App/Netdisco/DB/Result/Virtual/DuplexMismatch.pm
Normal file
61
lib/App/Netdisco/DB/Result/Virtual/DuplexMismatch.pm
Normal file
@@ -0,0 +1,61 @@
|
||||
package App::Netdisco::DB::Result::Virtual::DuplexMismatch;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table('duplex_mismatch');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
|
||||
SELECT dp.ip AS left_ip, d1.dns AS left_dns, dp.port AS left_port, dp.duplex AS left_duplex,
|
||||
di.ip AS right_ip, d2.dns AS right_dns, dp.remote_port AS right_port, dp2.duplex AS right_duplex
|
||||
FROM ( SELECT device_port.ip, device_port.remote_ip, device_port.port, device_port.duplex, device_port.remote_port
|
||||
FROM device_port
|
||||
WHERE
|
||||
device_port.remote_port IS NOT NULL
|
||||
AND device_port.up NOT ILIKE '%down%'
|
||||
GROUP BY device_port.ip, device_port.remote_ip, device_port.port, device_port.duplex, device_port.remote_port
|
||||
ORDER BY device_port.ip) dp
|
||||
LEFT JOIN device_ip di ON dp.remote_ip = di.alias
|
||||
LEFT JOIN device d1 ON dp.ip = d1.ip
|
||||
LEFT JOIN device d2 ON di.ip = d2.ip
|
||||
LEFT JOIN device_port dp2 ON (di.ip = dp2.ip AND dp.remote_port = dp2.port)
|
||||
WHERE di.ip IS NOT NULL
|
||||
AND dp.duplex <> dp2.duplex
|
||||
AND dp.ip <= di.ip
|
||||
AND dp2.up NOT ILIKE '%down%'
|
||||
ORDER BY dp.ip
|
||||
ENDSQL
|
||||
);
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
'left_ip' => {
|
||||
data_type => 'inet',
|
||||
},
|
||||
'left_dns' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'left_port' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'left_duplex' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'right_ip' => {
|
||||
data_type => 'inet',
|
||||
},
|
||||
'right_dns' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'right_port' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'right_duplex' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
);
|
||||
|
||||
1;
|
||||
13
lib/App/Netdisco/DB/Result/Virtual/GenericReport.pm
Normal file
13
lib/App/Netdisco/DB/Result/Virtual/GenericReport.pm
Normal file
@@ -0,0 +1,13 @@
|
||||
package App::Netdisco::DB::Result::Virtual::GenericReport;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
__PACKAGE__->table("generic_report");
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(q{});
|
||||
|
||||
1;
|
||||
19
lib/App/Netdisco/DB/Result/Virtual/NodeIp4.pm
Normal file
19
lib/App/Netdisco/DB/Result/Virtual/NodeIp4.pm
Normal file
@@ -0,0 +1,19 @@
|
||||
use utf8;
|
||||
package App::Netdisco::DB::Result::Virtual::NodeIp4;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'App::Netdisco::DB::Result::NodeIp';
|
||||
|
||||
__PACKAGE__->load_components('Helper::Row::SubClass');
|
||||
__PACKAGE__->subclass;
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
__PACKAGE__->table("node_ip4");
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(q{
|
||||
SELECT * FROM node_ip WHERE family(ip) = 4
|
||||
});
|
||||
|
||||
1;
|
||||
19
lib/App/Netdisco/DB/Result/Virtual/NodeIp6.pm
Normal file
19
lib/App/Netdisco/DB/Result/Virtual/NodeIp6.pm
Normal file
@@ -0,0 +1,19 @@
|
||||
use utf8;
|
||||
package App::Netdisco::DB::Result::Virtual::NodeIp6;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'App::Netdisco::DB::Result::NodeIp';
|
||||
|
||||
__PACKAGE__->load_components('Helper::Row::SubClass');
|
||||
__PACKAGE__->subclass;
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
__PACKAGE__->table("node_ip6");
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(q{
|
||||
SELECT * FROM node_ip WHERE family(ip) = 6
|
||||
});
|
||||
|
||||
1;
|
||||
49
lib/App/Netdisco/DB/Result/Virtual/NodeMonitor.pm
Normal file
49
lib/App/Netdisco/DB/Result/Virtual/NodeMonitor.pm
Normal file
@@ -0,0 +1,49 @@
|
||||
package App::Netdisco::DB::Result::Virtual::NodeMonitor;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use utf8;
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table('node_monitor_virtual');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<'ENDSQL');
|
||||
SELECT nm.why, nm.cc, trim(trailing '.' from trim(trailing '0123456789' from date::text)) as date,
|
||||
n.mac, n.switch, n.port,
|
||||
d.name, d.location,
|
||||
dp.name AS portname
|
||||
FROM node_monitor nm, node n, device d, device_port dp
|
||||
WHERE nm.mac = n.mac
|
||||
AND nm.active
|
||||
AND nm.cc IS NOT NULL
|
||||
AND d.ip = n.switch
|
||||
AND dp.ip = n.switch
|
||||
AND dp.port = n.port
|
||||
AND d.last_macsuck = n.time_last
|
||||
ENDSQL
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
"why",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"cc",
|
||||
{ data_type => "text", is_nullable => 0 },
|
||||
"date",
|
||||
{ data_type => "timestamp", is_nullable => 0 },
|
||||
"mac",
|
||||
{ data_type => "macaddr", is_nullable => 0 },
|
||||
"switch",
|
||||
{ data_type => "inet", is_nullable => 0 },
|
||||
"port",
|
||||
{ data_type => "text", is_nullable => 0 },
|
||||
"name",
|
||||
{ data_type => "text", is_nullable => 0 },
|
||||
"location",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"portname",
|
||||
{ data_type => "text", is_nullable => 0 },
|
||||
);
|
||||
|
||||
1;
|
||||
27
lib/App/Netdisco/DB/Result/Virtual/NodeWithAge.pm
Normal file
27
lib/App/Netdisco/DB/Result/Virtual/NodeWithAge.pm
Normal file
@@ -0,0 +1,27 @@
|
||||
use utf8;
|
||||
package App::Netdisco::DB::Result::Virtual::NodeWithAge;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'App::Netdisco::DB::Result::Node';
|
||||
|
||||
__PACKAGE__->load_components('Helper::Row::SubClass');
|
||||
__PACKAGE__->subclass;
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
__PACKAGE__->table("node_with_age");
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(q{
|
||||
SELECT *,
|
||||
replace( date_trunc( 'minute', age( now(), time_last + interval '30 second' ) ) ::text, 'mon', 'month')
|
||||
AS time_last_age
|
||||
FROM node
|
||||
});
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
"time_last_age",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
);
|
||||
|
||||
1;
|
||||
68
lib/App/Netdisco/DB/Result/Virtual/NodesDiscovered.pm
Normal file
68
lib/App/Netdisco/DB/Result/Virtual/NodesDiscovered.pm
Normal file
@@ -0,0 +1,68 @@
|
||||
package App::Netdisco::DB::Result::Virtual::NodesDiscovered;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table('nodes_discovered');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
|
||||
SELECT d.ip,
|
||||
d.dns,
|
||||
d.name,
|
||||
p.port,
|
||||
p.remote_ip,
|
||||
p.remote_port,
|
||||
p.remote_type,
|
||||
p.remote_id
|
||||
FROM device_port p,
|
||||
device d
|
||||
WHERE d.ip = p.ip
|
||||
AND NOT EXISTS
|
||||
(SELECT 1
|
||||
FROM device_port q
|
||||
WHERE q.ip = p.remote_ip
|
||||
AND q.port = p.remote_port)
|
||||
AND NOT EXISTS
|
||||
(SELECT 1
|
||||
FROM device_ip a,
|
||||
device_port q
|
||||
WHERE a.alias = p.remote_ip
|
||||
AND q.ip = a.ip
|
||||
AND q.port = p.remote_port)
|
||||
AND (p.remote_id IS NOT NULL OR p.remote_type IS NOT NULL)
|
||||
ORDER BY d.name, p.port
|
||||
ENDSQL
|
||||
);
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
'ip' => {
|
||||
data_type => 'inet',
|
||||
},
|
||||
'dns' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'name' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'port' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'remote_ip' => {
|
||||
data_type => 'inet',
|
||||
},
|
||||
'remote_port' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'remote_type' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'remote_id' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
);
|
||||
|
||||
1;
|
||||
32
lib/App/Netdisco/DB/Result/Virtual/OrphanedDevices.pm
Normal file
32
lib/App/Netdisco/DB/Result/Virtual/OrphanedDevices.pm
Normal file
@@ -0,0 +1,32 @@
|
||||
package App::Netdisco::DB::Result::Virtual::OrphanedDevices;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use utf8;
|
||||
use base 'App::Netdisco::DB::Result::Device';
|
||||
|
||||
__PACKAGE__->load_components('Helper::Row::SubClass');
|
||||
__PACKAGE__->subclass;
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
__PACKAGE__->table('orphaned_devices');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<'ENDSQL');
|
||||
SELECT *
|
||||
FROM device
|
||||
WHERE ip NOT IN
|
||||
( SELECT DISTINCT dp.ip AS ip
|
||||
FROM
|
||||
(SELECT device_port.ip,
|
||||
device_port.remote_ip
|
||||
FROM device_port
|
||||
WHERE device_port.remote_port IS NOT NULL
|
||||
GROUP BY device_port.ip,
|
||||
device_port.remote_ip
|
||||
ORDER BY device_port.ip) dp
|
||||
LEFT JOIN device_ip di ON dp.remote_ip = di.alias
|
||||
WHERE di.ip IS NOT NULL)
|
||||
ENDSQL
|
||||
|
||||
1;
|
||||
42
lib/App/Netdisco/DB/Result/Virtual/PollerPerformance.pm
Normal file
42
lib/App/Netdisco/DB/Result/Virtual/PollerPerformance.pm
Normal file
@@ -0,0 +1,42 @@
|
||||
package App::Netdisco::DB::Result::Virtual::PollerPerformance;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table('poller_performance');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
|
||||
SELECT action, entered, to_char( entered, 'YYYY-MM-DD HH24:MI:SS' ) AS entered_stamp,
|
||||
COUNT( device ) AS number, MIN( started ) AS start, MAX( finished ) AS end,
|
||||
justify_interval( extract ( epoch FROM( max( finished ) - min( started ) ) ) * interval '1 second' ) AS elapsed
|
||||
FROM admin
|
||||
WHERE action IN ( 'discover', 'macsuck', 'arpnip', 'nbtstat' )
|
||||
GROUP BY action, entered
|
||||
HAVING count( device ) > 1
|
||||
ORDER BY entered DESC, elapsed DESC
|
||||
LIMIT 30
|
||||
ENDSQL
|
||||
);
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
"action",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"entered",
|
||||
{ data_type => "timestamp", is_nullable => 1 },
|
||||
"entered_stamp",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"number",
|
||||
{ data_type => "integer", is_nullable => 1 },
|
||||
"start",
|
||||
{ data_type => "timestamp", is_nullable => 1 },
|
||||
"end",
|
||||
{ data_type => "timestamp", is_nullable => 1 },
|
||||
"elapsed",
|
||||
{ data_type => "interval", is_nullable => 1 },
|
||||
);
|
||||
|
||||
1;
|
||||
46
lib/App/Netdisco/DB/Result/Virtual/PortUtilization.pm
Normal file
46
lib/App/Netdisco/DB/Result/Virtual/PortUtilization.pm
Normal file
@@ -0,0 +1,46 @@
|
||||
package App::Netdisco::DB::Result::Virtual::PortUtilization;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table('port_utilization');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
|
||||
SELECT d.dns AS dns, d.ip as ip,
|
||||
sum(CASE WHEN (dp.type != 'propVirtual') THEN 1 ELSE 0 END) as port_count,
|
||||
sum(CASE WHEN (dp.type != 'propVirtual' AND dp.up_admin = 'up' AND dp.up = 'up') THEN 1 ELSE 0 END) as ports_in_use,
|
||||
sum(CASE WHEN (dp.type != 'propVirtual' AND dp.up_admin != 'up') THEN 1 ELSE 0 END) as ports_shutdown,
|
||||
sum(CASE WHEN (dp.type != 'propVirtual' AND dp.up_admin = 'up' AND dp.up != 'up') THEN 1 ELSE 0 END) as ports_free
|
||||
FROM device d LEFT JOIN device_port dp
|
||||
ON d.ip = dp.ip
|
||||
GROUP BY d.dns, d.ip
|
||||
ORDER BY d.dns, d.ip
|
||||
ENDSQL
|
||||
);
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
'dns' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'ip' => {
|
||||
data_type => 'inet',
|
||||
},
|
||||
'port_count' => {
|
||||
data_type => 'integer',
|
||||
},
|
||||
'ports_in_use' => {
|
||||
data_type => 'integer',
|
||||
},
|
||||
'ports_shutdown' => {
|
||||
data_type => 'integer',
|
||||
},
|
||||
'ports_free' => {
|
||||
data_type => 'integer',
|
||||
},
|
||||
);
|
||||
|
||||
1;
|
||||
42
lib/App/Netdisco/DB/Result/Virtual/SlowDevices.pm
Normal file
42
lib/App/Netdisco/DB/Result/Virtual/SlowDevices.pm
Normal file
@@ -0,0 +1,42 @@
|
||||
package App::Netdisco::DB::Result::Virtual::SlowDevices;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table('slow_devices');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
|
||||
SELECT a.action, a.device, a.started, a.finished,
|
||||
justify_interval(extract(epoch FROM (a.finished - a.started)) * interval '1 second') AS elapsed
|
||||
FROM admin a
|
||||
INNER JOIN (
|
||||
SELECT device, action, max(started) AS started
|
||||
FROM admin
|
||||
WHERE status = 'done'
|
||||
AND action IN ('discover','macsuck','arpnip')
|
||||
GROUP BY action, device
|
||||
) b
|
||||
ON a.device = b.device AND a.started = b.started
|
||||
ORDER BY elapsed desc, action, device
|
||||
LIMIT 20
|
||||
ENDSQL
|
||||
);
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
"action",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"device",
|
||||
{ data_type => "inet", is_nullable => 1 },
|
||||
"started",
|
||||
{ data_type => "timestamp", is_nullable => 1 },
|
||||
"finished",
|
||||
{ data_type => "timestamp", is_nullable => 1 },
|
||||
"elapsed",
|
||||
{ data_type => "interval", is_nullable => 1 },
|
||||
);
|
||||
|
||||
1;
|
||||
54
lib/App/Netdisco/DB/Result/Virtual/SubnetUtilization.pm
Normal file
54
lib/App/Netdisco/DB/Result/Virtual/SubnetUtilization.pm
Normal file
@@ -0,0 +1,54 @@
|
||||
package App::Netdisco::DB::Result::Virtual::SubnetUtilization;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use utf8;
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table('cidr_ips');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<'ENDSQL');
|
||||
SELECT net as subnet,
|
||||
power(2, (32 - masklen(net))) as subnet_size,
|
||||
count(DISTINCT ip) as active,
|
||||
round(100 * count(DISTINCT ip) / (power(2, (32 - masklen(net))))) as percent
|
||||
FROM (
|
||||
SELECT DISTINCT net, ni.ip
|
||||
FROM subnets s1, node_ip ni
|
||||
WHERE s1.net <<= ?::cidr
|
||||
AND ni.ip <<= s1.net
|
||||
AND ((
|
||||
ni.time_first IS null
|
||||
AND ni.time_last IS null
|
||||
) OR (
|
||||
ni.time_last >= ?
|
||||
AND ni.time_last <= ?
|
||||
))
|
||||
AND s1.last_discover >= ?
|
||||
UNION
|
||||
SELECT DISTINCT net, di.alias as ip
|
||||
FROM subnets s2, device_ip di JOIN device d USING (ip)
|
||||
WHERE s2.net <<= ?::cidr
|
||||
AND di.alias <<= s2.net
|
||||
AND s2.last_discover >= ?
|
||||
AND d.last_discover >= ?
|
||||
) as joined
|
||||
GROUP BY net
|
||||
ORDER BY percent ASC
|
||||
ENDSQL
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
"subnet",
|
||||
{ data_type => "cidr", is_nullable => 0 },
|
||||
"subnet_size",
|
||||
{ data_type => "integer", is_nullable => 0 },
|
||||
"active",
|
||||
{ data_type => "integer", is_nullable => 0 },
|
||||
"percent",
|
||||
{ data_type => "integer", is_nullable => 0 },
|
||||
);
|
||||
|
||||
1;
|
||||
54
lib/App/Netdisco/DB/Result/Virtual/UnDirEdgesAgg.pm
Normal file
54
lib/App/Netdisco/DB/Result/Virtual/UnDirEdgesAgg.pm
Normal file
@@ -0,0 +1,54 @@
|
||||
package App::Netdisco::DB::Result::Virtual::UnDirEdgesAgg;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table('undir_edges_agg');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<'ENDSQL');
|
||||
SELECT left_ip,
|
||||
array_agg(right_ip) AS links
|
||||
FROM
|
||||
( SELECT dp.ip AS left_ip,
|
||||
di.ip AS right_ip
|
||||
FROM
|
||||
(SELECT device_port.ip,
|
||||
device_port.remote_ip
|
||||
FROM device_port
|
||||
WHERE device_port.remote_port IS NOT NULL
|
||||
GROUP BY device_port.ip,
|
||||
device_port.remote_ip) dp
|
||||
LEFT JOIN device_ip di ON dp.remote_ip = di.alias
|
||||
WHERE di.ip IS NOT NULL
|
||||
UNION SELECT di.ip AS left_ip,
|
||||
dp.ip AS right_ip
|
||||
FROM
|
||||
(SELECT device_port.ip,
|
||||
device_port.remote_ip
|
||||
FROM device_port
|
||||
WHERE device_port.remote_port IS NOT NULL
|
||||
GROUP BY device_port.ip,
|
||||
device_port.remote_ip) dp
|
||||
LEFT JOIN device_ip di ON dp.remote_ip = di.alias
|
||||
WHERE di.ip IS NOT NULL ) AS foo
|
||||
GROUP BY left_ip
|
||||
ORDER BY left_ip
|
||||
ENDSQL
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
'left_ip' => {
|
||||
data_type => 'inet',
|
||||
},
|
||||
'links' => {
|
||||
data_type => 'inet[]',
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->belongs_to('device', 'App::Netdisco::DB::Result::Device',
|
||||
{ 'foreign.ip' => 'self.left_ip' });
|
||||
|
||||
1;
|
||||
61
lib/App/Netdisco/DB/Result/Virtual/UndiscoveredNeighbors.pm
Normal file
61
lib/App/Netdisco/DB/Result/Virtual/UndiscoveredNeighbors.pm
Normal file
@@ -0,0 +1,61 @@
|
||||
package App::Netdisco::DB::Result::Virtual::UndiscoveredNeighbors;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use utf8;
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table('undiscovered_neighbors');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<'ENDSQL');
|
||||
SELECT DISTINCT ON (p.remote_ip) d.ip,
|
||||
d.name,
|
||||
d.dns,
|
||||
p.port,
|
||||
p.remote_ip,
|
||||
p.remote_id,
|
||||
p.remote_type,
|
||||
p.remote_port,
|
||||
a.log,
|
||||
a.finished
|
||||
FROM device_port p
|
||||
JOIN device d
|
||||
ON d.ip = p.ip
|
||||
LEFT JOIN admin a
|
||||
ON (p.remote_ip = a.device AND a.action = 'discover')
|
||||
WHERE
|
||||
(p.remote_ip NOT IN (SELECT alias FROM device_ip))
|
||||
OR
|
||||
((p.remote_ip IS NULL) AND p.is_uplink)
|
||||
ORDER BY
|
||||
p.remote_ip ASC,
|
||||
a.finished DESC
|
||||
ENDSQL
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
"ip",
|
||||
{ data_type => "inet", is_nullable => 0 },
|
||||
"name",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"dns",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"port",
|
||||
{ data_type => "text", is_nullable => 0 },
|
||||
"remote_ip",
|
||||
{ data_type => "inet", is_nullable => 1 },
|
||||
"remote_port",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"remote_type",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"remote_id",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"log",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"finished",
|
||||
{ data_type => "timestamp", is_nullable => 1 },
|
||||
);
|
||||
|
||||
1;
|
||||
30
lib/App/Netdisco/DB/Result/Virtual/UserRole.pm
Normal file
30
lib/App/Netdisco/DB/Result/Virtual/UserRole.pm
Normal file
@@ -0,0 +1,30 @@
|
||||
use utf8;
|
||||
package App::Netdisco::DB::Result::Virtual::UserRole;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table("user_role");
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
|
||||
SELECT username, 'port_control' AS role FROM users
|
||||
WHERE port_control
|
||||
UNION
|
||||
SELECT username, 'admin' AS role FROM users
|
||||
WHERE admin
|
||||
UNION
|
||||
SELECT username, 'ldap' AS role FROM users
|
||||
WHERE ldap
|
||||
ENDSQL
|
||||
);
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
'username' => { data_type => 'text' },
|
||||
'role' => { data_type => 'text' },
|
||||
);
|
||||
|
||||
1;
|
||||
Reference in New Issue
Block a user