allow stats to run smoothly on ancient Pg 8.4
This commit is contained in:
@@ -34,6 +34,7 @@ sub update_stats {
|
|||||||
my $schema = schema('netdisco');
|
my $schema = schema('netdisco');
|
||||||
eval { require SNMP::Info };
|
eval { require SNMP::Info };
|
||||||
my $snmpinfo_ver = ($@ ? 'n/a' : $SNMP::Info::VERSION);
|
my $snmpinfo_ver = ($@ ? 'n/a' : $SNMP::Info::VERSION);
|
||||||
|
my $postgres_ver = pretty_version($schema->storage->dbh->{pg_server_version}, 2);
|
||||||
|
|
||||||
# TODO: (when we have the capabilities table?)
|
# TODO: (when we have the capabilities table?)
|
||||||
# $stats{waps} = sql_scalar('device',['COUNT(*)'], {"model"=>"AIR%"});
|
# $stats{waps} = sql_scalar('device',['COUNT(*)'], {"model"=>"AIR%"});
|
||||||
@@ -47,10 +48,11 @@ sub update_stats {
|
|||||||
device_ip_count =>
|
device_ip_count =>
|
||||||
$schema->resultset('DeviceIp')->count_rs->as_query,
|
$schema->resultset('DeviceIp')->count_rs->as_query,
|
||||||
device_link_count =>
|
device_link_count =>
|
||||||
|
( $postgres_ver =~ m/^8\./ ? 0 :
|
||||||
$schema->resultset('Virtual::DeviceLinks')->search(undef, {
|
$schema->resultset('Virtual::DeviceLinks')->search(undef, {
|
||||||
select => [ { coalesce => [ { sum => 'aggports' }, 0 ] } ],
|
select => [ { coalesce => [ { sum => 'aggports' }, 0 ] } ],
|
||||||
as => ['totlinks'],
|
as => ['totlinks'],
|
||||||
})->get_column('totlinks')->as_query,
|
})->get_column('totlinks')->as_query ),
|
||||||
device_port_count =>
|
device_port_count =>
|
||||||
$schema->resultset('DevicePort')->count_rs->as_query,
|
$schema->resultset('DevicePort')->count_rs->as_query,
|
||||||
device_port_up_count =>
|
device_port_up_count =>
|
||||||
@@ -70,8 +72,7 @@ sub update_stats {
|
|||||||
snmpinfo_ver => $snmpinfo_ver,
|
snmpinfo_ver => $snmpinfo_ver,
|
||||||
schema_ver => $schema->schema_version,
|
schema_ver => $schema->schema_version,
|
||||||
perl_ver => pretty_version($], 3),
|
perl_ver => pretty_version($], 3),
|
||||||
pg_ver =>
|
pg_ver => $postgres_ver,
|
||||||
pretty_version($schema->storage->dbh->{pg_server_version}, 2),
|
|
||||||
|
|
||||||
}, { key => 'primary' });
|
}, { key => 'primary' });
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,9 +17,11 @@
|
|||||||
of which [% stats.device_port_up_count | format_number %] are up
|
of which [% stats.device_port_up_count | format_number %] are up
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
[% IF stats.device_link_count %]
|
||||||
<tr>
|
<tr>
|
||||||
<th>[% stats.device_link_count| format_number %] layer 2 links between devices</th>
|
<th>[% stats.device_link_count| format_number %] layer 2 links between devices</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
[% END %]
|
||||||
<tr>
|
<tr>
|
||||||
<th>[% stats.node_table_count | format_number %] nodes logged, of which [% stats.node_active_count | format_number %] are active</th>
|
<th>[% stats.node_table_count | format_number %] nodes logged, of which [% stats.node_active_count | format_number %] are active</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user