[freeside-commits] freeside/FS/FS/NetworkMonitoringSystem Torrus_Internal.pm, 1.12, 1.13
Ivan,,,
ivan at wavetail.420.am
Tue Mar 1 10:37:18 PST 2011
Update of /home/cvs/cvsroot/freeside/FS/FS/NetworkMonitoringSystem
In directory wavetail.420.am:/tmp/cvs-serv30651
Modified Files:
Torrus_Internal.pm
Log Message:
get serviceids from torrus config + our torrus_srvderive table, not from srvexport
Index: Torrus_Internal.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -w -d -r1.12 -r1.13
--- Torrus_Internal.pm 28 Feb 2011 23:42:46 -0000 1.12
+++ Torrus_Internal.pm 1 Mar 2011 18:37:16 -0000 1.13
@@ -9,6 +9,7 @@
use XML::Simple;
use FS::Record qw(qsearch qsearchs dbh);
use FS::svc_port;
+use FS::torrus_srvderive;
use FS::torrus_srvderive_component;
use Torrus::ConfigTree;
@@ -40,14 +41,16 @@
my $find_serviceid = shift;
my $found_serviceid = 0;
my $ddx_hash = $self->ddx2hash;
- if($ddx_hash->{host}){
+ return '' unless $ddx_hash->{'host'};
+
my @hosts = @{$ddx_hash->{host}};
foreach my $host ( @hosts ) {
my $param = $host->{param};
if($param && $param->{'snmp-host'}
&& (!$router || $param->{'snmp-host'}->{'value'} eq $router)
&& $param->{'RFC2863_IF_MIB::external-serviceid'}) {
- my $serviceids = $param->{'RFC2863_IF_MIB::external-serviceid'}->{'content'};
+ my $serviceids =
+ $param->{'RFC2863_IF_MIB::external-serviceid'}->{'content'};
my %hash = ();
if($serviceids) {
my @serviceids = split(',',$serviceids);
@@ -65,10 +68,39 @@
return \%hash if ($router || $found_serviceid);
}
}
- }
'';
}
+#false laziness and probably should be merged w/above, but didn't want to mess
+# that up
+sub all_router_serviceids {
+ my $self = shift;
+ my $ddx_hash = $self->ddx2hash;
+ return () unless $ddx_hash->{'host'};
+
+ my %hash = ();
+ my @hosts = @{$ddx_hash->{host}};
+ foreach my $host ( @hosts ) {
+ my $param = $host->{param};
+ if($param && $param->{'snmp-host'}
+ && (!$router || $param->{'snmp-host'}->{'value'} eq $router)
+ && $param->{'RFC2863_IF_MIB::external-serviceid'}) {
+ my $serviceids =
+ $param->{'RFC2863_IF_MIB::external-serviceid'}->{'content'};
+ if ($serviceids) {
+ my @serviceids = split(',',$serviceids);
+ foreach my $serviceid ( @serviceids ) {
+ $serviceid =~ s/^\s+|\s+$//g;
+ my @s = split(':',$serviceid);
+ next unless scalar(@s) == 4;
+ $hash{$s[0]}=1;
+ }
+ }
+ }
+ }
+ return sort keys %hash;
+}
+
sub port_graphs_link {
# hardcoded for 'main' tree for now
my $self = shift;
@@ -236,23 +268,30 @@
}
+#sub torrus_serviceids {
+# my $self = shift;
+#
+# #is this going to get too slow or will the index make it okay?
+# my $sth = dbh->prepare("SELECT DISTINCT(serviceid) FROM srvexport")
+# or die dbh->errstr;
+# $sth->execute or die $sth->errstr;
+# my %serviceid = ();
+# while ( my $row = $sth->fetchrow_arrayref ) {
+# my $serviceid = $row->[0];
+# $serviceid =~ s/_(IN|OUT)$//;
+# $serviceid{$serviceid}=1;
+# }
+# my @serviceids = sort keys %serviceid;
+#
+# @serviceids;
+#
+#}
+
sub torrus_serviceids {
my $self = shift;
-
- #is this going to get too slow or will the index make it okay?
- my $sth = dbh->prepare("SELECT DISTINCT(serviceid) FROM srvexport")
- or die dbh->errstr;
- $sth->execute or die $sth->errstr;
- my %serviceid = ();
- while ( my $row = $sth->fetchrow_arrayref ) {
- my $serviceid = $row->[0];
- $serviceid =~ s/_(IN|OUT)$//;
- $serviceid{$serviceid}=1;
- }
- my @serviceids = sort keys %serviceid;
-
- @serviceids;
-
+ my @serviceids = $self->all_router_serviceids;
+ push @serviceids, map $_->serviceid, qsearch('torrus_srvderive', {});
+ return sort @serviceids;
}
1;
More information about the freeside-commits
mailing list