The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

use Dancer ':syntax';
register_report(
{ category => 'Port',
tag => 'portadmindown',
label => 'Ports administratively disabled',
provides_csv => 1,
api_endpoint => 1,
}
);
get '/ajax/content/report/portadmindown' => require_login sub {
my @results = schema('netdisco')->resultset('Device')->search(
{ 'up_admin' => 'down' },
{ select => [ 'ip', 'dns', 'name' ],
join => [ 'ports' ],
'+columns' => [
{ 'port' => 'ports.port' },
{ 'description' => 'ports.name' },
{ 'up_admin' => 'ports.up_admin' },
]
}
)->hri->all;
return unless scalar @results;
if ( request->is_ajax ) {
my $json = to_json (\@results);
template 'ajax/report/portadmindown.tt', { results => $json };
}
else {
header( 'Content-Type' => 'text/comma-separated-values' );
template 'ajax/report/portadmindown_csv.tt',
{ results => \@results, };
}
};
1;