Info/Layer3/Lantronix.pm untested

filter: Statementstmt 0.0% 0 / 59 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 113 CC 11 SCAR 21.3
CC
11
Cov
0%
model
20.0
_eds_descr_fields
12.0
os
6.0
CRAP 8.5
1 # SNMP::Info::Layer3::Lantronix
2 #
3 # Copyright (c) 2012 J R Binks
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are met:
7 #
8 # * Redistributions of source code must retain the above copyright notice,
9 # this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # * Neither the name of the University of California, Santa Cruz nor the
14 # names of its contributors may be used to endorse or promote products
15 # derived from this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 # LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
28  
29 package SNMP::Info::Layer3::Lantronix;
30  
31 use strict;
32 use warnings;
33 use Exporter;
34 use SNMP::Info::Layer3;
35  
36 @SNMP::Info::Layer3::Lantronix::ISA = qw/
37 SNMP::Info::Layer3
38 Exporter
39 /;
40 @SNMP::Info::Layer3::Lantronix::EXPORT_OK = qw//;
41  
42 our ($VERSION, %FUNCS, %GLOBALS, %MIBS, %MUNGE);
43  
44 $VERSION = '3.985003';
45  
46 %MIBS = (
47 %SNMP::Info::Layer3::MIBS,
48 'LANTRONIX-MIB' => 'products',
49 'LANTRONIX-SLC-MIB' => 'slcNetwork',
50 );
51  
52 %GLOBALS = (
53 %SNMP::Info::Layer3::GLOBALS,
54 'slc_os_ver' => 'slcSystemFWRev',
55 'slc_serial' => 'slcSystemSerialNo',
56 'slc_model' => 'slcSystemModel',
57 'slc_psu_a_status' => 'slcDevPowerSupplyA',
58 'slc_psu_b_status' => 'slcDevPowerSupplyB',
59 );
60  
61 %FUNCS = ( %SNMP::Info::Layer3::FUNCS, );
62  
63 %MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
64  
65 # General notes:
66 #
67 # Products like the EDS have very minimal MIB support for the basics.
68 # Much information has to be derived from sysDescr string.
69 #
70 sub vendor {
71 return 'lantronix';
72 }
73  
74 sub os {
75 my $device = shift;
76 my $descr = $device->description() || '';
77 my $id = $device->id() || '';
78  
79 # On EDS, it is called the "Evolution OS"
80 # Not sure what, if any, name it has a name on other products
81 if ( $id =~ m/^\.?1\.3\.6\.1\.4\.1\.244\.1\.13(?:\.|$)/
82 or $descr =~ m/Lantronix EDS\w+ V?([\d\.R]+)/ ) {
83 return 'EvolutionOS';
84 } else {
85 return 'LantronixOS';
86 }
87 }
88  
89 # EDS sysDescr ends "<version> (<serial>)", with or without a V before the
90 # version. Match the end: a configured device name can replace the leading
91 # "Lantronix <model>".
92 # EDS: "Lantronix EDS16PR V4.0.0.0R15 (1307.....X)"
93 # EDS5000: "Lantronix EDS5016 2.1.0.0R3 (00C0F2.....)"
94 # Renamed: "My Name V5.2.0.0R24 (0310.....D)"
95 sub _eds_descr_fields {
96 my $device = shift;
97 my $descr = $device->description();
98  
99 return unless defined $descr;
100 return ( $1, $2 )
101 if $descr =~ m/\sV?(\d+(?:\.\d+)+(?:R\d+)?)\s+\((\w+)\)\s*$/;
102 return;
103 }
104  
105 sub os_ver {
106 my $device = shift;
107 my $slc_os_ver = $device->slc_os_ver;
108  
109 return $slc_os_ver if defined $slc_os_ver;
110  
111 my ($os_ver) = $device->_eds_descr_fields();
112 return $os_ver;
113 }
114  
115 sub serial {
116 my $device = shift;
117 my $slc_serial = $device->slc_serial;
118  
119 return $slc_serial if defined $slc_serial;
120  
121 my ( undef, $serial ) = $device->_eds_descr_fields();
122 return $serial;
123 }
124  
125 sub model {
126 my $device = shift;
127 my $descr = $device->description() || '';
128 my $slc_model = $device->slc_model;
129 my $model;
130  
131 return $slc_model if defined $slc_model;
132  
133 return unless defined $descr;
134  
135 # EDS: "Lantronix EDS16PR V4.0.0.0R15 (1307.....X)"
136 $model = $1 if ( $descr =~ m/Lantronix (EDS\w+)/ );
137  
138 return $model;
139 }
140  
141 sub ps1_status {
142 my $device = shift;
143 my $slc_psu_a_status = $device->slc_psu_a_status;
144  
145 return $slc_psu_a_status if defined $slc_psu_a_status;
146  
147 return;
148 }
149  
150 sub ps2_status {
151 my $device = shift;
152 my $slc_psu_b_status = $device->slc_psu_b_status;
153  
154 return $slc_psu_b_status if defined $slc_psu_b_status;
155  
156 return;
157 }
158  
159 1;
160 __END__