~ubuntu-branches/ubuntu/trusty/torrus/trusty-proposed

« back to all changes in this revision

Viewing changes to perllib/Torrus/DevDiscover.pm

  • Committer: Bazaar Package Importer
  • Author(s): Marc Haber
  • Date: 2008-03-08 00:18:46 UTC
  • mfrom: (1.2.1 upstream) (3.1.3 hardy)
  • Revision ID: james.westby@ubuntu.com-20080308001846-q3pinwcswe3uf7wj
Tags: 1.0.6-2
Add torrus-common.NEWS advising people to recompile their
configuration upon upgrading to torrus 1.0.6.
Thanks to Joerg Dorchain. Closes: #469274

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#  along with this program; if not, write to the Free Software
15
15
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
16
16
 
17
 
# $Id: DevDiscover.pm,v 1.21 2006/07/20 09:34:28 ssinyagin Exp $
 
17
# $Id: DevDiscover.pm,v 1.29 2007/05/04 11:08:04 ssinyagin Exp $
18
18
# Stanislav Sinyagin <ssinyagin@yahoo.com>
19
19
 
20
20
# Core SNMP device discovery module
39
39
    }
40
40
}
41
41
 
 
42
# Custom overlays for templates
 
43
# overlayName ->
 
44
#     'Module::templateName' -> { 'name' => 'templateName',
 
45
#                                 'source' => 'filename.xml' }
 
46
our %templateOverlays;
 
47
 
42
48
our @requiredParams =
43
49
    (
44
50
     'snmp-port',
55
61
$defaultParams{'domain-name'} = '';
56
62
$defaultParams{'host-subtree'} = '';
57
63
$defaultParams{'snmp-check-sysuptime'} = 'yes';
 
64
$defaultParams{'show-recursive'} = 'yes';
58
65
 
59
66
our @copyParams =
60
67
    ( 'collector-period',
67
74
      'domain-name',
68
75
      'monitor-period',
69
76
      'monitor-timeoffset',
 
77
      'show-recursive',
70
78
      'snmp-host',
71
79
      'snmp-port',
 
80
      'snmp-localaddr',
 
81
      'snmp-localport',
72
82
      'snmp-community',
73
83
      'snmp-version',
74
84
      'snmp-username',
122
132
    }
123
133
 
124
134
    $self->{'datadirs'} = {};
 
135
    $self->{'globalData'} = {};
125
136
 
126
137
    return $self;
127
138
}
128
139
 
129
140
 
130
141
 
 
142
sub globalData
 
143
{
 
144
    my $self = shift;
 
145
    return $self->{'globalData'};
 
146
}
 
147
 
131
148
 
132
149
sub discover
133
150
{
143
160
 
144
161
    foreach my $param ( @requiredParams )
145
162
    {
146
 
        if( not $devdetails->param( $param ) )
 
163
        if( not defined( $devdetails->param( $param ) ) )
147
164
        {
148
165
            Error('Required parameter not defined: ' . $param);
149
166
            return 0;
155
172
    my $version = $devdetails->param( 'snmp-version' );
156
173
    $snmpargs{'-version'} = $version;    
157
174
 
158
 
    foreach my $arg ( qw(-port -timeout -retries) )
 
175
    foreach my $arg ( qw(-port -localaddr -localport -timeout -retries) )
159
176
    {
160
 
        $snmpargs{$arg} = $devdetails->param( 'snmp' . $arg );
 
177
        if( defined( $devdetails->param( 'snmp' . $arg ) ) )
 
178
        {
 
179
            $snmpargs{$arg} = $devdetails->param( 'snmp' . $arg );
 
180
        }
161
181
    }
162
182
    
163
183
    if( $version eq '1' or $version eq '2c' )
440
460
 
441
461
            my $data = $devdetails->data();
442
462
 
 
463
            my @registryOverlays = ();
 
464
            if( defined( $devdetails->param('template-registry-overlays' ) ) )
 
465
            {
 
466
                my @overlayNames = 
 
467
                    split(/\s*,\s*/,
 
468
                          $devdetails->param('template-registry-overlays' ));
 
469
                foreach my $overlayName ( @overlayNames )
 
470
                {
 
471
                    if( defined( $templateOverlays{$overlayName}) )
 
472
                    {
 
473
                        push( @registryOverlays,
 
474
                              $templateOverlays{$overlayName} );
 
475
                    }
 
476
                    else
 
477
                    {
 
478
                        Error('Cannot find the template overlay named ' .
 
479
                              $overlayName);
 
480
                    }
 
481
                }
 
482
            }
 
483
 
 
484
            # we should call this anyway, in order to flush the overlays
 
485
            # set by previous host
 
486
            $cb->setRegistryOverlays( @registryOverlays );            
 
487
            
443
488
            if( $devdetails->param('disable-snmpcollector' ) eq 'yes' )
444
489
            {
445
490
                push( @{$data->{'templates'}}, '::viewonly-defaults' );
485
530
                  $devdetails->getDevTypes() )
486
531
            {
487
532
                &{$reg->{$devtype}{'buildConfig'}}
488
 
                ( $devdetails, $cb, $devNode );
 
533
                ( $devdetails, $cb, $devNode, $self->{'globalData'} );
489
534
            }
490
535
 
491
536
            $cb->{'statistics'}{'hosts'}++;
492
537
        }
493
538
    }
494
539
 
 
540
    foreach my $devtype
 
541
        ( sort {$reg->{$a}{'sequence'} <=> $reg->{$b}{'sequence'}}
 
542
          keys %{$reg} )
 
543
    {
 
544
        if( defined( $reg->{$devtype}{'buildGlobalConfig'} ) )
 
545
        {
 
546
            &{$reg->{$devtype}{'buildGlobalConfig'}}($cb,
 
547
                                                     $self->{'globalData'});
 
548
        }
 
549
    }
 
550
    
495
551
    if( defined( $self->{'define-tokensets'} ) )
496
552
    {
497
553
        my $tsetsNode = $cb->startTokensets();