summaryrefslogtreecommitdiff
path: root/FS/FS/NetworkMonitoringSystem
diff options
context:
space:
mode:
authorivan <ivan>2011-02-26 01:44:10 +0000
committerivan <ivan>2011-02-26 01:44:10 +0000
commitcc4799a676331db92e00a0f56361007eb561c407 (patch)
tree4d213eeff5a93165fb1255e00e1ea219965403ec /FS/FS/NetworkMonitoringSystem
parent2888eb3dd278260b3ed6ad4a2d4ae3ba656f6a57 (diff)
fix newlines in interface addition, throw some sort of error for duplicate addition, RT#10574
Diffstat (limited to 'FS/FS/NetworkMonitoringSystem')
-rw-r--r--FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm14
1 files changed, 9 insertions, 5 deletions
diff --git a/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm b/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm
index e7d3db1..4c3264e 100644
--- a/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm
+++ b/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm
@@ -132,9 +132,13 @@ sub add_interface {
#should just use a proper XML parser huh
+ my @ddx = split(/\n/, $self->_torrus_loadddx);
+
+ die "Torrus Service ID $serviceid in use\n"
+ if grep /^\s*$serviceid:/, @ddx;
+
my $newline = " $serviceid:$interface:Both:main,";
- my @ddx = split(/\n/, $self->_torrus_loadddx);
my $new = '';
my $added = 0;
@@ -149,10 +153,10 @@ sub add_interface {
while ( my $paramline = shift(@ddx) ) {
if ( $paramline =~ /^\s*<\/param>/ ) {
- $new .= "$newline\n$paramline";
+ $new .= "$newline\n$paramline\n";
last; #paramline
} else {
- $new .= $paramline;
+ $new .= "$paramline\n";
}
}
@@ -165,7 +169,7 @@ sub add_interface {
qq( $newline\n").
qq( </param>\n);
}
- $new .= $hostline;
+ $new .= "$hostline\n";
last; #hostline
}
@@ -212,7 +216,7 @@ sub _torrus_newddx {
sub _torrus_reload {
my($self) = @_;
- #i should have better error checking
+ #i should use IPC::Run and have better error checking
system('torrus', 'devdiscover', "--in=$ddxfile");