diff options
| author | ivan <ivan> | 2011-12-19 01:26:13 +0000 | 
|---|---|---|
| committer | ivan <ivan> | 2011-12-19 01:26:13 +0000 | 
| commit | 425b5f85e183064be4cc3e1a8ce444f11fe011df (patch) | |
| tree | 44472187f80fd8deeaa6937fefdcc6d93985d093 | |
| parent | 34d1b9d0053e3946a7a64a83966b8428da5a852c (diff) | |
missing commit from nms auto-addition fixes, RT#15536
| -rw-r--r-- | FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm | 36 | ||||
| -rw-r--r-- | FS/FS/svc_acct.pm | 1 | ||||
| -rw-r--r-- | FS/FS/svc_dsl.pm | 1 | 
3 files changed, 28 insertions, 10 deletions
diff --git a/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm b/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm index 04a6b2954..28bc8a761 100644 --- a/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm +++ b/FS/FS/NetworkMonitoringSystem/Torrus_Internal.pm @@ -5,6 +5,7 @@ use strict;  use Fcntl qw(:flock);  use IO::File;  use File::Slurp qw(slurp); +use IPC::Run qw(run);  use Date::Format;  use XML::Simple;  use FS::Record qw(qsearch qsearchs dbh); @@ -154,11 +155,18 @@ sub report {  } +sub queued_add_router { +  my $self = shift; +  my $error = $self->add_router(@_); +  die $error if $error; +} +  sub add_router {    my($self, $ip, $community) = @_; -  $community = qq!<param name="snmp-community" value="$community"/>\n ! -    if length($community) > 1; +  $community = (defined($community) && length($community) > 1) +                 ? qq!<param name="snmp-community" value="$community"/>\n ! +                 : '';    my $newhost =       qq(  <host>\n). @@ -257,23 +265,31 @@ sub _torrus_newddx {    close $new;    my $tmpname = $ddxfile . Date::Format::time2str('%Y%m%d%H%M%S',time); -  rename("$ddxfile", $tmpname) or die $!; +  rename($ddxfile, $tmpname) or die $!;    rename("$ddxfile.new", $ddxfile) or die $!; -  $self->_torrus_reload; +  my $error = $self->_torrus_reload; +  if ( $error ) { #revert routers.ddx +    rename($ddxfile, "$tmpname.FAILED") or die $!; +    rename($tmpname, $ddxfile) or die $!; +  } +   +  $self->_torrus_unlock; + +  return $error;  }  sub _torrus_reload {    my($self) = @_; -  #i should use IPC::Run and have better error checking (commands are silent -  # for success, or output errors) - -  system('torrus', 'devdiscover', "--in=$ddxfile"); +  my $stderr = ''; +  run( ['torrus', 'devdiscover', "--in=$ddxfile"], '2>'=>\$stderr ); +  return $stderr if $stderr; -  system('torrus', 'compile', '--tree=main'); # , '--verbose' +  run( ['torrus', 'compile', '--tree=main'] ); # , '--verbose' +  #typically the errors happen at the discover stage... -  $self->_torrus_unlock; +  '';  } diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index 73f91321b..64f2c35d5 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -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'       => { diff --git a/FS/FS/svc_dsl.pm b/FS/FS/svc_dsl.pm index 5e6a149e8..8c47f8887 100644 --- a/FS/FS/svc_dsl.pm +++ b/FS/FS/svc_dsl.pm @@ -137,6 +137,7 @@ sub table_info {          'sorts' => [ 'phonenum' ],          'display_weight' => 55,          'cancel_weight' => 75, +        'ip_field' => 'staticips',          'fields' => {              'pushed'                => { label => 'Pushed',                                            type  => 'disabled' },  | 
