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.
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
;
32 use Socket
qw(inet_ntoa);
37 $Torrus::DevDiscover
::registry
{'CiscoIOS_SAA'} = {
39 'checkdevtype' => \
&checkdevtype
,
40 'discover' => \
&discover
,
41 'buildConfig' => \
&buildConfig
48 'rttMonCtrlAdminTable' => '1.3.6.1.4.1.9.9.42.1.2.1',
49 'rttMonCtrlAdminOwner' => '1.3.6.1.4.1.9.9.42.1.2.1.1.2',
50 'rttMonCtrlAdminTag' => '1.3.6.1.4.1.9.9.42.1.2.1.1.3',
51 'rttMonCtrlAdminRttType' => '1.3.6.1.4.1.9.9.42.1.2.1.1.4',
52 'rttMonCtrlAdminFrequency' => '1.3.6.1.4.1.9.9.42.1.2.1.1.6',
53 'rttMonCtrlAdminStatus' => '1.3.6.1.4.1.9.9.42.1.2.1.1.9',
54 'rttMonEchoAdminTable' => '1.3.6.1.4.1.9.9.42.1.2.2',
55 'rttMonEchoAdminProtocol' => '1.3.6.1.4.1.9.9.42.1.2.2.1.1',
56 'rttMonEchoAdminTargetAddress' => '1.3.6.1.4.1.9.9.42.1.2.2.1.2',
57 'rttMonEchoAdminPktDataRequestSize' => '1.3.6.1.4.1.9.9.42.1.2.2.1.3',
58 'rttMonEchoAdminTargetPort' => '1.3.6.1.4.1.9.9.42.1.2.2.1.5',
59 'rttMonEchoAdminTOS' => '1.3.6.1.4.1.9.9.42.1.2.2.1.9',
60 'rttMonEchoAdminTargetAddressString' => '1.3.6.1.4.1.9.9.42.1.2.2.1.11',
61 'rttMonEchoAdminNameServer' => '1.3.6.1.4.1.9.9.42.1.2.2.1.12',
62 'rttMonEchoAdminURL' => '1.3.6.1.4.1.9.9.42.1.2.2.1.15',
63 'rttMonEchoAdminInterval' => '1.3.6.1.4.1.9.9.42.1.2.2.1.17',
64 'rttMonEchoAdminNumPackets' => '1.3.6.1.4.1.9.9.42.1.2.2.1.18'
71 'rttMonCtrlAdminOwner' => {
73 'legend' => 'Owner: %s;',
74 'param' => 'rtt-owner'
77 'rttMonCtrlAdminTag' => {
79 'legend' => 'Tag: %s;',
84 'rttMonCtrlAdminRttType' => {
86 'legend' => 'Type: %s;',
87 'translate' => \
&translateRttType
,
91 'rttMonCtrlAdminFrequency' => {
93 'legend' => 'Frequency: %d seconds;',
94 'param' => 'rtt-frequency'
97 'rttMonEchoAdminProtocol' => {
99 'legend' => 'Protocol: %s;',
100 'translate' => \
&translateRttEchoProtocol
,
101 'param' => 'rtt-echo-protocol'
104 'rttMonEchoAdminTargetAddress' => {
106 'legend' => 'Target: %s;',
107 'comment' => 'Target=%s ',
108 'translate' => \
&translateRttTargetAddr
,
109 'param' => 'rtt-echo-target-addr',
110 'ignore-text' => '0.0.0.0'
113 'rttMonEchoAdminPktDataRequestSize' => {
115 'legend' => 'Packet size: %d octets;',
116 'param' => 'rtt-echo-request-size'
119 'rttMonEchoAdminTargetPort' => {
121 'legend' => 'Port: %d;',
122 'param' => 'rtt-echo-port',
123 'ignore-numeric' => 0
126 'rttMonEchoAdminTOS' => {
128 'legend' => 'TOS: %d;',
129 'comment' => 'TOS=%d ',
130 'param' => 'rtt-echo-tos',
131 'ignore-numeric' => 0
134 'rttMonEchoAdminTargetAddressString' => {
136 'legend' => 'Address string: %s;',
137 'param' => 'rtt-echo-addr-string'
140 'rttMonEchoAdminNameServer' => {
142 'legend' => 'NameServer: %s;',
143 'translate' => \
&translateRttTargetAddr
,
144 'param' => 'rtt-echo-name-server',
145 'ignore-text' => '0.0.0.0'
148 'rttMonEchoAdminURL' => {
150 'legend' => 'URL: %s;',
151 'param' => 'rtt-echo-url'
154 'rttMonEchoAdminInterval' => {
156 'legend' => 'Interval: %d milliseconds;',
157 'param' => 'rtt-echo-interval',
158 'ignore-numeric' => 0
161 'rttMonEchoAdminNumPackets' => {
163 'legend' => 'Packets: %d;',
164 'param' => 'rtt-echo-num-packets',
165 'ignore-numeric' => 0
174 my $devdetails = shift;
176 my $session = $dd->session();
178 if( $devdetails->isDevType('CiscoIOS') )
181 $session->get_table( -baseoid
=>
182 $dd->oiddef('rttMonCtrlAdminTable') );
183 if( defined($rttAdminTable) and scalar(keys %{$rttAdminTable}) > 0 )
185 $devdetails->storeSnmpVars( $rttAdminTable );
197 my $devdetails = shift;
199 my $session = $dd->session();
200 my $data = $devdetails->data();
202 my $rttEchoAdminTable =
203 $session->get_table( -baseoid
=>
204 $dd->oiddef('rttMonEchoAdminTable') );
205 if( defined $rttEchoAdminTable )
207 $devdetails->storeSnmpVars( $rttEchoAdminTable );
208 undef $rttEchoAdminTable;
211 $data->{'rtt_entries'} = {};
214 ( $devdetails->getSnmpIndices( $dd->oiddef('rttMonCtrlAdminOwner') ) )
216 # we're interested in Active agents only
217 if( $devdetails->snmpVar($dd->oiddef('rttMonCtrlAdminStatus') .
218 '.' . $rttIndex) != 1 )
224 $data->{'rtt_entries'}{$rttIndex} = $ref;
225 $ref->{'param'} = {};
231 ( sort {$adminInterpret{$a}{'order'} <=>
232 $adminInterpret{$b}{'order'}}
233 keys %adminInterpret )
235 my $value = $devdetails->snmpVar( $dd->oiddef( $adminField ) .
237 if( defined( $value ) and length( $value ) > 0 )
239 my $intrp = $adminInterpret{$adminField};
240 if( ref( $intrp->{'translate'} ) )
242 $value = &{$intrp->{'translate'}}( $value );
245 if( ( defined( $intrp->{'ignore-numeric'} ) and
246 $value == $intrp->{'ignore-numeric'} )
248 ( defined( $intrp->{'ignore-text'} ) and
249 $value eq $intrp->{'ignore-text'} ) )
254 if( defined( $intrp->{'param'} ) )
256 $ref->{'param'}{$intrp->{'param'}} = $value;
259 if( defined( $intrp->{'comment'} ) )
261 $comment .= sprintf( $intrp->{'comment'}, $value );
264 if( defined( $intrp->{'legend'} ) )
266 $legend .= sprintf( $intrp->{'legend'}, $value );
271 $ref->{'param'}{'rtt-index'} = $rttIndex;
272 $ref->{'param'}{'comment'} = $comment;
273 $ref->{'param'}{'legend'} = $legend;
282 my $devdetails = shift;
286 my $data = $devdetails->data();
289 $cb->addSubtree( $devNode, 'SAA', undef,
290 ['CiscoIOS_SAA::cisco-saa-subtree']);
292 for my $rttIndex ( sort {$a<=>$b} keys %{$data->{'rtt_entries'}} )
294 my $subtreeName = 'rtt_' . $rttIndex;
295 my $param = $data->{'rtt_entries'}{$rttIndex}{'param'};
296 $param->{'precedence'} = sprintf('%d', 10000 - $rttIndex);
298 # TODO: should really consider rtt-type and rtt-echo-protocol
300 $cb->addSubtree( $subtreeNode, $subtreeName, $param,
301 ['CiscoIOS_SAA::cisco-rtt-echo-subtree']);
327 return $rttType{$value};
331 our %rttEchoProtocol =
333 '1' => 'notApplicable',
335 '3' => 'ipUdpEchoAppl',
337 '5' => 'snaLU0EchoAppl',
338 '6' => 'snaLU2EchoAppl',
339 '7' => 'snaLU62Echo',
340 '8' => 'snaLU62EchoAppl',
341 '9' => 'appleTalkEcho',
342 '10' => 'appleTalkEchoAppl',
343 '11' => 'decNetEcho',
344 '12' => 'decNetEchoAppl',
346 '14' => 'ipxEchoAppl',
347 '15' => 'isoClnsEcho',
348 '16' => 'isoClnsEchoAppl',
350 '18' => 'vinesEchoAppl',
352 '20' => 'xnsEchoAppl',
353 '21' => 'apolloEcho',
354 '22' => 'apolloEchoAppl',
355 '23' => 'netbiosEchoAppl',
359 '27' => 'jitterAppl',
365 sub translateRttEchoProtocol
368 return $rttEchoProtocol{$value};
371 sub translateRttTargetAddr
375 return inet_ntoa
( pack( 'H8', $value ) );
384 # indent-tabs-mode: nil
385 # perl-indent-level: 4