per-agent configuration of batch processors, #71837
[freeside.git] / torrus / perllib / Torrus / DevDiscover / CiscoFirewall.pm
1 #  Copyright (C) 2003  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: CiscoFirewall.pm,v 1.1 2010-12-27 00:03:56 ivan Exp $
18 # Shawn Ferry <lalartu at obscure dot org> <sferry at sevenspace dot com>
19
20 # Cisco Firewall devices discovery
21
22 package Torrus::DevDiscover::CiscoFirewall;
23
24 use strict;
25 use Torrus::Log;
26
27
28 $Torrus::DevDiscover::registry{'CiscoFirewall'} = {
29     'sequence'     => 510,
30     'checkdevtype' => \&checkdevtype,
31     'discover'     => \&discover,
32     'buildConfig'  => \&buildConfig
33     };
34
35
36 our %oiddef =
37     (
38      # CISCO-FIREWALL
39      'ciscoFirewallMIB'            => '1.3.6.1.4.1.9.9.147',
40      'cfwBasicEventsTableLastRow'  => '1.3.6.1.4.1.9.9.147.1.1.4',
41      'cfwConnectionStatTable'      => '1.3.6.1.4.1.9.9.147.1.2.2.2.1',
42      'cfwConnectionStatMax'        => '1.3.6.1.4.1.9.9.147.1.2.2.2.1.5.40.7',
43      );
44
45
46
47 sub checkdevtype
48 {
49     my $dd = shift;
50     my $devdetails = shift;
51
52     my $session = $dd->session();
53     my $data = $devdetails->data();
54
55     if( $devdetails->isDevType('CiscoGeneric') and
56         $dd->checkSnmpTable('ciscoFirewallMIB') )
57     {
58         $devdetails->setCap('interfaceIndexingManaged');
59         return 1;
60     }
61
62     return 0;
63 }
64
65
66 sub discover
67 {
68     my $dd = shift;
69     my $devdetails = shift;
70
71     my $data = $devdetails->data();
72     my $session = $dd->session();
73
74     $data->{'nameref'}{'ifReferenceName'} = 'ifName';
75     $data->{'nameref'}{'ifSubtreeName'} = 'ifNameT';
76     $data->{'param'}{'ifindex-table'} = '$ifName';
77
78     if( not defined( $data->{'param'}{'snmp-oids-per-pdu'} ) )
79     {
80         my $oidsPerPDU =
81             $devdetails->param('CiscoFirewall::snmp-oids-per-pdu');
82         if( $oidsPerPDU == 0 )
83         {
84             $oidsPerPDU = 10;
85         }
86         $data->{'param'}{'snmp-oids-per-pdu'} = $oidsPerPDU;
87     }
88
89     if( $dd->checkSnmpOID('cfwConnectionStatMax') )
90     {
91         $devdetails->setCap('CiscoFirewall::connections');
92     }
93     
94     # I have not seen a system that supports this.
95     if( $dd->checkSnmpOID('cfwBasicEventsTableLastRow') )
96     {
97         $devdetails->setCap('CiscoFirewall::events');
98     }
99
100     return 1;
101 }
102
103
104 sub buildConfig
105 {
106     my $devdetails = shift;
107     my $cb = shift;
108     my $devNode = shift;
109     my $data = $devdetails->data();
110
111     my $fwStatsTree = "Firewall_Stats";
112     my $fwStatsParam = {
113         'precedence' => '-1000',
114         'comment'    => 'Firewall Stats',
115     };
116
117     my @templates = ('CiscoFirewall::cisco-firewall-subtree');
118     
119     if( $devdetails->hasCap('CiscoFirewall::connections') )
120     {
121         push( @templates, 'CiscoFirewall::connections');
122     }
123
124     if( $devdetails->hasCap('CiscoFirewall::events') )
125     {
126         push( @templates, 'CiscoFirewall::events');
127     }
128
129     $cb->addSubtree( $devNode, $fwStatsTree, $fwStatsParam, \@templates );
130 }
131
132
133
134
135 1;
136
137
138 # Local Variables:
139 # mode: perl
140 # indent-tabs-mode: nil
141 # perl-indent-level: 4
142 # End: