[freeside-commits] freeside/FS/FS/NetworkMonitoringSystem Torrus_Internal.pm, 1.3, 1.4
Erik Levinson
levinse at wavetail.420.am
Sun Feb 6 21:20:44 PST 2011
Update of /home/cvs/cvsroot/freeside/FS/FS/NetworkMonitoringSystem
In directory wavetail.420.am:/tmp/cvs-serv25880/FS/FS/NetworkMonitoringSystem
Modified Files:
Torrus_Internal.pm
Log Message:
torrus, UI, RT10574
Index: Torrus_Internal.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -d -r1.3 -r1.4
--- Torrus_Internal.pm 5 Feb 2011 06:04:32 -0000 1.3
+++ Torrus_Internal.pm 7 Feb 2011 05:20:41 -0000 1.4
@@ -6,6 +6,9 @@
use IO::File;
use File::Slurp qw(slurp);
use Date::Format;
+use XML::Simple;
+use FS::svc_port;
+use FS::Record qw(qsearch);
#$DEBUG = 0;
#$me = '[FS::NetworkMonitoringSystem::Torrus_Internal]';
@@ -21,6 +24,52 @@
return $self;
}
+sub get_router_serviceids {
+ my $self = shift;
+ my $router = shift;
+
+ my $ddx_xml = slurp($ddxfile);
+ my $xs = new XML::Simple(RootName=> undef, SuppressEmpty => '',
+ ForceArray => 1, );
+ my $ddx_hash = $xs->XMLin($ddx_xml);
+ if($ddx_hash->{host}){
+ my @hosts = @{$ddx_hash->{host}};
+ foreach my $host ( @hosts ) {
+ my $param = $host->{param};
+ if($param && $param->{'snmp-host'}
+ && $param->{'snmp-host'}->{'value'} eq $router
+ && $param->{'RFC2863_IF_MIB::external-serviceid'}) {
+ my $serviceids = $param->{'RFC2863_IF_MIB::external-serviceid'}->{'content'};
+ my %hash = ();
+ 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[1]} = $s[0];
+ }
+ }
+ return \%hash;
+ }
+ }
+ }
+ '';
+}
+
+sub find_svc {
+ my $self = shift;
+ my $serviceid = shift;
+ return '' unless $serviceid =~ /^[0-9A-Za-z_\-.\\\/ ]+$/;
+
+ my @svc_port = qsearch('svc_port', { 'serviceid' => $serviceid });
+ return '' unless scalar(@svc_port);
+
+ # for now it's like this, later on just change to qsearchs
+
+ return $svc_port[0];
+}
+
sub add_router {
my($self, $ip) = @_;
More information about the freeside-commits
mailing list