1package App::Netdisco::DB::Result::Virtual::NodeMonitor; 2 3use strict; 4use warnings; 5 6use utf8; 7use 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'); 14SELECT 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 18FROM node_monitor nm, node n, device d, device_port dp 19WHERE ((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 26ENDSQL 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 491; 50