1 # Copyright (C) 2002 Stanislav Sinyagin
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17 # $Id: CiscoIOS_SAA.pm,v 1.1 2010-12-27 00:03:50 ivan Exp $
18 # Stanislav Sinyagin <ssinyagin@yahoo.com>
20 # Cisco IOS Service Assurance Agent
22 # should really consider rtt-type and rtt-echo-protocol when applying
25 # translate TOS bits into DSCP values
27 package Torrus::DevDiscover::CiscoIOS_SAA;
30 use Socket qw(inet_ntoa);
35 $Torrus::DevDiscover::registry{'CiscoIOS_SAA'} = {
37 'checkdevtype' => \&checkdevtype,
38 'discover' => \&discover,
39 'buildConfig' => \&buildConfig
46 'rttMonCtrlAdminTable' => '1.3.6.1.4.1.9.9.42.1.2.1',
47 'rttMonCtrlAdminOwner' => '1.3.6.1.4.1.9.9.42.1.2.1.1.2',
48 'rttMonCtrlAdminTag' => '1.3.6.1.4.1.9.9.42.1.2.1.1.3',
49 'rttMonCtrlAdminRttType' => '1.3.6.1.4.1.9.9.42.1.2.1.1.4',
50 'rttMonCtrlAdminFrequency' => '1.3.6.1.4.1.9.9.42.1.2.1.1.6',
51 'rttMonCtrlAdminStatus' => '1.3.6.1.4.1.9.9.42.1.2.1.1.9',
52 'rttMonEchoAdminTable' => '1.3.6.1.4.1.9.9.42.1.2.2',
53 'rttMonEchoAdminProtocol' => '1.3.6.1.4.1.9.9.42.1.2.2.1.1',
54 'rttMonEchoAdminTargetAddress' => '1.3.6.1.4.1.9.9.42.1.2.2.1.2',
55 'rttMonEchoAdminPktDataRequestSize' => '1.3.6.1.4.1.9.9.42.1.2.2.1.3',
56 'rttMonEchoAdminTargetPort' => '1.3.6.1.4.1.9.9.42.1.2.2.1.5',
57 'rttMonEchoAdminTOS' => '1.3.6.1.4.1.9.9.42.1.2.2.1.9',
58 'rttMonEchoAdminTargetAddressString' => '1.3.6.1.4.1.9.9.42.1.2.2.1.11',
59 'rttMonEchoAdminNameServer' => '1.3.6.1.4.1.9.9.42.1.2.2.1.12',
60 'rttMonEchoAdminURL' => '1.3.6.1.4.1.9.9.42.1.2.2.1.15',
61 'rttMonEchoAdminInterval' => '1.3.6.1.4.1.9.9.42.1.2.2.1.17',
62 'rttMonEchoAdminNumPackets' => '1.3.6.1.4.1.9.9.42.1.2.2.1.18'
69 'rttMonCtrlAdminOwner' => {
71 'legend' => 'Owner: %s;',
72 'param' => 'rtt-owner'
75 'rttMonCtrlAdminTag' => {
77 'legend' => 'Tag: %s;',
82 'rttMonCtrlAdminRttType' => {
84 'legend' => 'Type: %s;',
85 'translate' => \&translateRttType,
89 'rttMonCtrlAdminFrequency' => {
91 'legend' => 'Frequency: %d seconds;',
92 'param' => 'rtt-frequency'
95 'rttMonEchoAdminProtocol' => {
97 'legend' => 'Protocol: %s;',
98 'translate' => \&translateRttEchoProtocol,
99 'param' => 'rtt-echo-protocol'
102 'rttMonEchoAdminTargetAddress' => {
104 'legend' => 'Target: %s;',
105 'comment' => 'Target=%s ',
106 'translate' => \&translateRttTargetAddr,
107 'param' => 'rtt-echo-target-addr',
108 'ignore-text' => '0.0.0.0'
111 'rttMonEchoAdminPktDataRequestSize' => {
113 'legend' => 'Packet size: %d octets;',
114 'param' => 'rtt-echo-request-size'
117 'rttMonEchoAdminTargetPort' => {
119 'legend' => 'Port: %d;',
120 'param' => 'rtt-echo-port',
121 'ignore-numeric' => 0
124 'rttMonEchoAdminTOS' => {
126 'legend' => 'TOS: %d;',
127 'comment' => 'TOS=%d ',
128 'param' => 'rtt-echo-tos',
129 'ignore-numeric' => 0
132 'rttMonEchoAdminTargetAddressString' => {
134 'legend' => 'Address string: %s;',
135 'param' => 'rtt-echo-addr-string'
138 'rttMonEchoAdminNameServer' => {
140 'legend' => 'NameServer: %s;',
141 'translate' => \&translateRttTargetAddr,
142 'param' => 'rtt-echo-name-server',
143 'ignore-text' => '0.0.0.0'
146 'rttMonEchoAdminURL' => {
148 'legend' => 'URL: %s;',
149 'param' => 'rtt-echo-url'
152 'rttMonEchoAdminInterval' => {
154 'legend' => 'Interval: %d milliseconds;',
155 'param' => 'rtt-echo-interval',
156 'ignore-numeric' => 0
159 'rttMonEchoAdminNumPackets' => {
161 'legend' => 'Packets: %d;',
162 'param' => 'rtt-echo-num-packets',
163 'ignore-numeric' => 0
172 my $devdetails = shift;
174 my $session = $dd->session();
176 if( $devdetails->isDevType('CiscoIOS') )
179 $session->get_table( -baseoid =>
180 $dd->oiddef('rttMonCtrlAdminTable') );
181 if( defined $rttAdminTable and scalar( %{$rttAdminTable} ) > 0 )
183 $devdetails->storeSnmpVars( $rttAdminTable );
195 my $devdetails = shift;
197 my $session = $dd->session();
198 my $data = $devdetails->data();
200 my $rttEchoAdminTable =
201 $session->get_table( -baseoid =>
202 $dd->oiddef('rttMonEchoAdminTable') );
203 if( defined $rttEchoAdminTable )
205 $devdetails->storeSnmpVars( $rttEchoAdminTable );
206 undef $rttEchoAdminTable;
209 $data->{'rtt_entries'} = {};
212 ( $devdetails->getSnmpIndices( $dd->oiddef('rttMonCtrlAdminOwner') ) )
214 # we're interested in Active agents only
215 if( $devdetails->snmpVar($dd->oiddef('rttMonCtrlAdminStatus') .
216 '.' . $rttIndex) != 1 )
222 $data->{'rtt_entries'}{$rttIndex} = $ref;
223 $ref->{'param'} = {};
228 foreach my $adminField
229 ( sort {$adminInterpret{$a}{'order'} <=>
230 $adminInterpret{$b}{'order'}}
231 keys %adminInterpret )
233 my $value = $devdetails->snmpVar( $dd->oiddef( $adminField ) .
235 if( defined( $value ) and length( $value ) > 0 )
237 my $intrp = $adminInterpret{$adminField};
238 if( ref( $intrp->{'translate'} ) )
240 $value = &{$intrp->{'translate'}}( $value );
243 if( ( defined( $intrp->{'ignore-numeric'} ) and
244 $value == $intrp->{'ignore-numeric'} )
246 ( defined( $intrp->{'ignore-text'} ) and
247 $value eq $intrp->{'ignore-text'} ) )
252 if( defined( $intrp->{'param'} ) )
254 $ref->{'param'}{$intrp->{'param'}} = $value;
257 if( defined( $intrp->{'comment'} ) )
259 $comment .= sprintf( $intrp->{'comment'}, $value );
262 if( defined( $intrp->{'legend'} ) )
264 $legend .= sprintf( $intrp->{'legend'}, $value );
269 $ref->{'param'}{'rtt-index'} = $rttIndex;
270 $ref->{'param'}{'comment'} = $comment;
271 $ref->{'param'}{'legend'} = $legend;
280 my $devdetails = shift;
284 my $data = $devdetails->data();
287 $cb->addSubtree( $devNode, 'SAA', undef,
288 ['CiscoIOS_SAA::cisco-saa-subtree']);
290 foreach my $rttIndex ( sort {$a<=>$b} keys %{$data->{'rtt_entries'}} )
292 my $subtreeName = 'rtt_' . $rttIndex;
293 my $param = $data->{'rtt_entries'}{$rttIndex}{'param'};
294 $param->{'precedence'} = sprintf('%d', 10000 - $rttIndex);
296 # TODO: should really consider rtt-type and rtt-echo-protocol
298 $cb->addSubtree( $subtreeNode, $subtreeName, $param,
299 ['CiscoIOS_SAA::cisco-rtt-echo-subtree']);
323 return $rttType{$value};
327 our %rttEchoProtocol =
329 '1' => 'notApplicable',
331 '3' => 'ipUdpEchoAppl',
333 '5' => 'snaLU0EchoAppl',
334 '6' => 'snaLU2EchoAppl',
335 '7' => 'snaLU62Echo',
336 '8' => 'snaLU62EchoAppl',
337 '9' => 'appleTalkEcho',
338 '10' => 'appleTalkEchoAppl',
339 '11' => 'decNetEcho',
340 '12' => 'decNetEchoAppl',
342 '14' => 'ipxEchoAppl',
343 '15' => 'isoClnsEcho',
344 '16' => 'isoClnsEchoAppl',
346 '18' => 'vinesEchoAppl',
348 '20' => 'xnsEchoAppl',
349 '21' => 'apolloEcho',
350 '22' => 'apolloEchoAppl',
351 '23' => 'netbiosEchoAppl',
355 '27' => 'jitterAppl',
361 sub translateRttEchoProtocol
364 return $rttEchoProtocol{$value};
367 sub translateRttTargetAddr
371 return inet_ntoa( pack( 'H8', $value ) );
380 # indent-tabs-mode: nil
381 # perl-indent-level: 4