« blib/lib/App/Netdisco/DB/Result/Virtual/NodeIp6.pm
↑ Summary
blib/lib/App/Netdisco/DB/Result/Virtual/NodeWithAge.pm »
| 1 | package App::Netdisco::DB::Result::Virtual::NodeMonitor; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use utf8; | ||
| 7 | use base 'DBIx::Class::Core'; | ||
| 8 | |||
| 9 | __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); | ||
| 10 | |||
| 11 | __PACKAGE__->table('node_monitor_virtual'); | ||
| 12 | __PACKAGE__->result_source_instance->is_virtual(1); | ||
| 13 | __PACKAGE__->result_source_instance->view_definition(<<'ENDSQL'); | ||
| 14 | SELECT nm.why, nm.cc, trim(trailing '.' from trim(trailing '0123456789' from date::text)) as date, | ||
| 15 | n.mac, n.switch, n.port, | ||
| 16 | d.name, d.location, | ||
| 17 | dp.name AS portname | ||
| 18 | FROM node_monitor nm, node n, device d, device_port dp | ||
| 19 | WHERE ((nm.mac = n.mac) OR (nm.matchoui AND (substring(nm.mac::text from 1 for 8) = n.oui))) | ||
| 20 | AND nm.active | ||
| 21 | AND nm.cc IS NOT NULL | ||
| 22 | AND d.ip = n.switch | ||
| 23 | AND dp.ip = n.switch | ||
| 24 | AND dp.port = n.port | ||
| 25 | AND d.last_macsuck = n.time_last | ||
| 26 | ENDSQL | ||
| 27 | |||
| 28 | __PACKAGE__->add_columns( | ||
| 29 | "why", | ||
| 30 | { data_type => "text", is_nullable => 1 }, | ||
| 31 | "cc", | ||
| 32 | { data_type => "text", is_nullable => 0 }, | ||
| 33 | "date", | ||
| 34 | { data_type => "timestamp", is_nullable => 0 }, | ||
| 35 | "mac", | ||
| 36 | { data_type => "macaddr", is_nullable => 0 }, | ||
| 37 | "switch", | ||
| 38 | { data_type => "inet", is_nullable => 0 }, | ||
| 39 | "port", | ||
| 40 | { data_type => "text", is_nullable => 0 }, | ||
| 41 | "name", | ||
| 42 | { data_type => "text", is_nullable => 0 }, | ||
| 43 | "location", | ||
| 44 | { data_type => "text", is_nullable => 1 }, | ||
| 45 | "portname", | ||
| 46 | { data_type => "text", is_nullable => 0 }, | ||
| 47 | ); | ||
| 48 | |||
| 49 | 1; |