summaryrefslogtreecommitdiff
path: root/FS/FS/NetworkMonitoringSystem
diff options
context:
space:
mode:
authorlevinse <levinse>2011-02-07 05:20:41 +0000
committerlevinse <levinse>2011-02-07 05:20:41 +0000
commit8c37ba9a0caeffdbe133968750f5b4d1e7b7fb69 (patch)
treefaa7322e969cc71cdeae57b2eaf619689e28d3eb /FS/FS/NetworkMonitoringSystem
parent3a4bf42c4385863ea83423b279b39ff6e650f79d (diff)
torrus, UI, RT10574
Diffstat (limited to 'FS/FS/NetworkMonitoringSystem')
-rw-r--r--FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm49
1 files changed, 49 insertions, 0 deletions
diff --git a/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm b/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm
index 5d1bb06..736d178 100644
--- a/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm
+++ b/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm
@@ -6,6 +6,9 @@ use Fcntl qw(:flock);
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 @@ sub new {
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) = @_;