fix first port addition on new routers, RT#10574
[freeside.git] / FS / FS / NetworkMonitoringSystem / Torrus_Internal.pm
index f436e3b..9df1975 100644 (file)
@@ -11,7 +11,7 @@ use FS::Record qw(qsearch qsearchs dbh);
 use FS::svc_port;
 use FS::torrus_srvderive;
 use FS::torrus_srvderive_component;
-use Torrus::ConfigTree;
+#use Torrus::ConfigTree;
 
 #$DEBUG = 0;
 #$me = '[FS::NetworkMonitoringSystem::Torrus_Internal]';
@@ -108,6 +108,11 @@ sub port_graphs_link {
     my @keys = keys %$hash; # yeah this is weird...
     my $host = $keys[0];
     my $iface = $hash->{$keys[0]};
+
+    #Torrus::ConfigTree is only available when running under the web UI
+    eval 'use Torrus::ConfigTree;';
+    die $@ if $@;
+
     my $config_tree = new Torrus::ConfigTree( -TreeName => 'main' );
     my $token = $config_tree->token("/Routers/$host/Interface_Counters/$iface/InOut_bps");
     return $Torrus::Freeside::FSURL."/torrus/main?token=$token";
@@ -207,7 +212,7 @@ sub add_interface {
         unless ( $added ) {
           $new .= 
             qq(   <param name="RFC2863_IF_MIB::external-serviceid">\n).
-            qq(     $newline\n").
+            qq(     $newline\n).
             qq(   </param>\n);
         }
         $new .= "$hostline\n";