auto-add service ips to network monitoring, RT#15536
authorivan <ivan>
Fri, 9 Dec 2011 05:09:20 +0000 (05:09 +0000)
committerivan <ivan>
Fri, 9 Dec 2011 05:09:20 +0000 (05:09 +0000)
FS/FS/Conf.pm
FS/FS/svc_Common.pm
FS/FS/svc_acct.pm
FS/FS/svc_broadband.pm
FS/FS/svc_dsl.pm

index fcdcd57..94669ff 100644 (file)
@@ -2650,14 +2650,28 @@ and customer address. Include units.',
 
   {
     'key'         => 'network_monitoring_system',
-    'section'     => '',
+    'section'     => 'network_monitoring',
     'description' => 'Networking monitoring system (NMS) integration.  <b>Torrus_Internal</b> uses the built-in Torrus ticketing system (see the <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:2.1:Documentation:Torrus_Installation">integrated networking monitoring system installation instructions</a>).',
     'type'        => 'select',
-    #'select_enum' => [ '', qw(RT_Internal RT_Libs RT_External) ],
     'select_enum' => [ '', qw(Torrus_Internal) ],
   },
 
   {
+    'key'         => 'nms-auto_add-svc_ips',
+    'section'     => 'network_monitoring',
+    'description' => 'Automatically add (and remove) IP addresses from these service tables to the network monitoring system.',
+    'type'        => 'selectmultiple',
+    'select_enum' => [ 'svc_acct', 'svc_broadband', 'svc_dsl' ],
+  },
+
+  {
+    'key'         => 'nms-auto_add-community',
+    'section'     => 'network_monitoring',
+    'description' => 'SNMP community string to use when automatically adding IP addresses from these services to the network monitoring system.',
+    'type'        => 'text',
+  },
+
+  {
     'key'         => 'ticket_system-default_queueid',
     'section'     => 'ticketing',
     'description' => 'Default queue used when creating new customer tickets.',
index 02e159b..fbab64d 100644 (file)
@@ -5,6 +5,7 @@ use vars qw( @ISA $noexport_hack $DEBUG $me
              $overlimit_missing_cust_svc_nonfatal_kludge );
 use Carp qw( cluck carp croak confess ); #specify cluck have to specify them all
 use Scalar::Util qw( blessed );
+use FS::Conf;
 use FS::Record qw( qsearch qsearchs fields dbh );
 use FS::cust_main_Mixin;
 use FS::cust_svc;
@@ -13,6 +14,7 @@ use FS::queue;
 use FS::cust_main;
 use FS::inventory_item;
 use FS::inventory_class;
+use FS::NetworkMonitoringSystem;
 
 @ISA = qw( FS::cust_main_Mixin FS::Record );
 
@@ -316,6 +318,8 @@ sub insert {
 
   }
 
+  $self->nms_ip_insert;
+
   if ( exists $options{'jobnums'} ) {
     push @{ $options{'jobnums'} }, @jobnums;
   }
@@ -1160,6 +1164,32 @@ sub getstatus_html {
 
 }
 
+=item nms_ip_insert
+
+=cut
+
+sub nms_ip_insert {
+  my $self = shift;
+  my $conf = new FS::Conf;
+  return '' unless grep { $self->table eq $_ }
+                     $conf->config('nms-auto_add-svc_ips');
+  my $ip_field = $self->table_info->{'ip_field'};
+
+  #XXX perhaps i should be job-queued, i take awhile, right?
+  my $nms = new FS::NetworkMonitoringSystem;
+  $nms->add_router( $self->$ip_field(),
+                    $conf->config('nms-auto_add-community')
+                  );
+}
+
+=item nms_delip
+
+=cut
+
+sub nms_ip_delete {
+#XXX not yet implemented
+}
+
 =back
 
 =head1 BUGS
index 12d3b8e..53f3b26 100644 (file)
@@ -254,6 +254,7 @@ sub table_info {
     'sorts' => [ 'username', 'uid', 'seconds', 'last_login' ],
     'display_weight' => 10,
     'cancel_weight'  => 50, 
+    'ip_field' => 'slipip',
     'fields' => {
         'dir'       => 'Home directory',
         'uid'       => {
index 2ac24e5..83c481e 100755 (executable)
@@ -95,6 +95,7 @@ sub table_info {
     'longname_plural' => 'Fixed (username-less) broadband services',
     'display_weight' => 50,
     'cancel_weight'  => 70,
+    'ip_field' => 'ip_addr',
     'fields' => {
       'description' => 'Descriptive label for this particular device.',
       'speed_down'  => 'Maximum download speed for this service in Kbps.  0 denotes unlimited.',
index 5e6a149..8c47f88 100644 (file)
@@ -137,6 +137,7 @@ sub table_info {
         'sorts' => [ 'phonenum' ],
         'display_weight' => 55,
         'cancel_weight' => 75,
+        'ip_field' => 'staticips',
         'fields' => {
             'pushed'                => { label => 'Pushed', 
                                          type  => 'disabled' },