import torrus 1.0.9
[freeside.git] / torrus / perllib / Torrus / DevDiscover / NetApp.pm
1 #  Copyright (C) 2004  Shawn Ferry
2 #
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.
7 #
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.
12 #
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.
16
17 # $Id: NetApp.pm,v 1.1 2010-12-27 00:03:55 ivan Exp $
18 # Shawn Ferry <sferry at sevenspace dot com> <lalartu at obscure dot org>
19
20 # NetApp.com storage products
21
22 package Torrus::DevDiscover::NetApp;
23
24 use strict;
25 use Torrus::Log;
26
27
28 $Torrus::DevDiscover::registry{'NetApp'} = {
29     'sequence'     => 500,
30     'checkdevtype' => \&checkdevtype,
31     'discover'     => \&discover,
32     'buildConfig'  => \&buildConfig
33     };
34
35 our %oiddef =
36     (
37      'netapp'                               => '1.3.6.1.4.1.789',
38      'netapp1'                              => '1.3.6.1.4.1.789.1',
39      'netappProducts'                       => '1.3.6.1.4.1.789.2',
40
41      # netapp product 
42      'netapp_product'                       => '1.3.6.1.4.1.789.1.1',
43      'netapp_productVersion'                => '1.3.6.1.4.1.789.1.1.2.0',
44      'netapp_productId'                     => '1.3.6.1.4.1.789.1.1.3.0',
45      'netapp_productModel'                  => '1.3.6.1.4.1.789.1.1.5.0',
46      'netapp_productFirmwareVersion'        => '1.3.6.1.4.1.789.1.1.6.0',
47      
48      # netapp sysstat
49      'netapp_sysStat'                       => '1.3.6.1.4.1.789.1.2',
50      'netapp_sysStat_cpuCount'              => '1.3.6.1.4.1.789.1.2.1.6.0',
51      
52      # netapp nfs
53      'netapp_nfs'                           => '1.3.6.1.4.1.789.1.3',
54      'netapp_nfsIsLicensed'                 => '1.3.6.1.4.1.789.1.3.3.1.0',
55      
56      # At a glance Lookup values seem to be the most common as opposed to
57      # collecting NFS stats for v2 and v3 (and eventually v4 ) if No lookups
58      # have been performed at discovery time we assume that vX is not in use.
59      'netapp_tv2cLookups'              => '1.3.6.1.4.1.789.1.3.2.2.3.1.5.0',
60      'netapp_tv3cLookups'              => '1.3.6.1.4.1.789.1.3.2.2.4.1.4.0',
61      
62      # netapp CIFS
63      'netapp_cifs'                     => '1.3.6.1.4.1.789.1.7',
64      'netapp_cifsIsLicensed'           => '1.3.6.1.4.1.789.1.7.21.0',
65      
66      # 4 - 19 should also be interesting
67      # particularly cluster netcache stats
68      );
69
70 #       netappFiler     OBJECT IDENTIFIER ::= { netappProducts 1 }
71 #       netappNetCache  OBJECT IDENTIFIER ::= { netappProducts 2 }
72 #       netappClusteredFiler    OBJECT IDENTIFIER ::= { netappProducts 3 }
73
74 sub checkdevtype
75 {
76     my $dd = shift;
77     my $devdetails = shift;
78
79     return $dd->checkSnmpTable( 'netapp' );
80 }
81
82
83 sub discover
84 {
85     my $dd = shift;
86     my $devdetails = shift;
87
88     my $session = $dd->session();
89     my $data = $devdetails->data();
90
91     my $result = $dd->retrieveSnmpOIDs
92         ( 'netapp_productModel',  'netapp_productId',
93           'netapp_productVersion', 'netapp_productFirmwareVersion',
94           'netapp_nfsIsLicensed', 'netapp_cifsIsLicensed',
95           'netapp_tv2cLookups', 'netapp_tv3cLookups' );
96     
97     $data->{'param'}->{'comment'} =
98         sprintf('%s %s: %s %s',
99                 $result->{'netapp_productModel'},
100                 $result->{'netapp_productId'},
101                 $result->{'netapp_productVersion'},
102                 $result->{'netapp_productFirmwareVersion'});
103     
104     # At a glance Lookup values seem to be the most common as opposed to
105     # collecting NFS stats for v2 and v3 (and eventually v4 ) if No lookups
106     # have been performed at discovery time we assume that nfsvX is not in use.
107     
108     if( $result->{'netapp_nfsIsLicensed'} == 2 )
109     {
110         if( $result->{'netapp_tv2cLookups'} > 0 )
111         {
112             $devdetails->setCap('NetApp::nfsv2');
113         }
114
115         if( $result->{'netapp_tv3cLookups'} > 0 )
116         {
117             $devdetails->setCap('NetApp::nfsv3');
118         }
119     }
120
121     if( $result->{'netapp_cifsIsLicensed'} == 2 )
122     {
123         $devdetails->setCap('NetApp::cifs');
124     }
125     
126     return 1;
127 }
128
129
130 sub buildConfig
131 {
132     my $devdetails = shift;
133     my $cb = shift;
134     my $devNode = shift;
135     my $data = $devdetails->data();
136
137     $cb->addParams( $devNode, $data->{'params'} );
138
139     # Add CPU Template
140     $cb->addTemplateApplication( $devNode, 'NetApp::CPU');
141     
142     # Add Misc Stats
143     $cb->addTemplateApplication( $devNode, 'NetApp::misc');
144
145     if( $devdetails->hasCap('NetApp::nfsv2') )
146     {
147         $cb->addTemplateApplication( $devNode, 'NetApp::nfsv2');
148     }
149
150     if( $devdetails->hasCap('NetApp::nfsv3') )
151     {
152         $cb->addTemplateApplication( $devNode, 'NetApp::nfsv3');
153     }
154
155     if( $devdetails->hasCap('NetApp::cifs') )
156     {
157         Debug("Would add cifs here\n");
158         #$cb->addTemplateApplication( $devNode, 'NetApp::cifs');
159     }
160 }
161
162
163 1;
164
165
166 # Local Variables:
167 # mode: perl
168 # indent-tabs-mode: nil
169 # perl-indent-level: 4
170 # End: