Find Devices: |
|
Find Devices: |
|
Device |
IP |
Vendor - Model |
<%$arg_age_type eq 'uptime' ? 'Uptime' : 'First Discovered'%> |
Last Updated |
<%perl>
my @results;
if ($arg_age_type eq 'uptime') {
@results = sort { $b->{uptime} <=> $a->{uptime} } @$age;
} else {
@results = sort {
return $a->{dns} cmp $b->{dns} unless (! defined($a->{dns}) or ! defined $b->{dns});
return $a->{ip} cmp $b->{ip};
} @$age;
}
$odd = 1; $count = 0;
foreach my $dev (@results) {
my $dns = $dev->{dns} || 'No DNS';
$dns =~ s/\Q$domain\E//;
my $creation_age = $m->comp("SELF:.trim_age", age => $dev->{creation_age});
my $last_discover_age = $m->comp("SELF:.trim_age", age => $dev->{last_discover_age});
my $uptime = $m->comp('device.html:uptime',uptime => $dev->{uptime});
$odd++;
%perl>
<%$dns|h%> |
<%$dev->{ip}|h%> |
<%$dev->{vendor} || "Unknown"%> - <%$dev->{model} || "Unknown"|h%> |
<%$arg_age_type eq 'uptime' ? $uptime : $creation_age|h%> |
<%$last_discover_age|h%> |
% }
Found <%scalar @$age%> devices.
%method>
%#
%# .trim_age(age=>string) - Trim postgres ugly age string
%#
<%method .trim_age>
<%args>
$age => ''
%args>
<%perl>
$age =~ s/mon/month/;
if ($age =~ /(day|month|year)/){
$age =~ s/(-)?\d{2}:\d{2}.*$//;
} else {
$age =~ s/(\d{2}:\d{2}):\d{2}(\.\d*)$/$1/;
}
return $age;
%perl>
%method>
%#
%# show_ssid() - Inventory based on SSID
%#
<%method show_ssid>
SSID |
Broadcast? |
Count |
<%perl>
my $ssid_count = sql_rows('device_port_ssid',['ssid','broadcast','count(ssid)'],
undef,undef,'group by ssid,broadcast');
$count = 0; $odd = 1; my $old_loc = '';
foreach my $row (sort { $b->{count} <=> $a->{count} } @$ssid_count) {
$odd++;
%perl>
<%$row->{ssid}|h%> |
<%$row->{broadcast} ? "Broadcast" : "Stealth"%> |
<%$row->{count}%> |
% }
Location |
IP Address |
sysName |
Vendor |
Model |
<%perl>
my $location_count = sql_rows('device',['location','dns','name','ip','vendor','model'],
undef,undef,undef);
$count = 0; $odd = 0; my $old_loc = '';
foreach my $row (sort
{
# Sort by Location => Name => IP Address => Vendor => Model
return $a->{location} cmp $b->{location} if $a->{location} ne $b->{location};
return $a->{name} cmp $b->{name} if $a->{name} ne $b->{name};
return $a->{ip} cmp $b->{ip} if $a->{ip} ne $b->{ip};
return $a->{vendor} cmp $b->{vendor} if $a->{vendor} ne $b->{vendor};
return $a->{model} cmp $b->{model} if $a->{model} ne $b->{model};
} @$location_count
) {
$count += $row->{count};
$odd++ if $row->{location} ne $old_loc;
$old_loc = $row->{location};
my $dns = $row->{dns} || $row->{ip};
$dns =~ s/\Q$domain\E//;
%perl>
<%$row->{location} || '[Not Set]'%> |
<%$dns|h%> |
<%$row->{name}|h%> |
<%$row->{vendor} || "Unknown"|h%> |
<%$row->{model} || "Unknown"|h%> |
% } $odd++;
|
Total: |
<%scalar(@$location_count)%> |