blib/lib/BlueCoat/SGOS.pm

filter: Statementstmt 71.8% 270 / 376 Branchbran 51.9% 109 / 210 Conditioncond 52.7% 19 / 36 MC/DCmcdc 35.0% 7 / 20 Subroutinesub 79.3% 23 / 29 Podpod 100% 8 / 8 totaltotal 64.2% 436 / 679 CC 127 SCAR 31.4
CC
127
Cov
64%
_parse_route_table
105.4
get_sysinfo
42.0
_parse_network
30.3
CRAP 23.1
↑ Summary
1 package BlueCoat::SGOS;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Date::Parse;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 require HTTP::Request;
8 2 ▶use HTTP::Request::Common qw/POST/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our %_URL = (
11 'archconf_expanded' => '/archconf_expanded.txt',
12 'contentfilter_status' => '/ContentFilter/Status',
13 'sysinfo' => '/SYSINFO',
14 'send_command' =>
15 '/Secure/Local/console/install_upload_action/cli_post_setup.txt'
16 );
17  
18 2 our %defaults = (
19 'appliancehost' => 'proxy',
20 'applianceport' => 8082,
21 'applianceusername' => 'admin',
22 'appliancepassword' => 'password',
23 'applianceconnectmode' => 'https',
24 'debuglevel' => 0,
25 );
26  
27 =head1 NAME
28  
29 BlueCoat::SGOS - A module to interact with Blue Coat SGOS-based devices.
30  
31 =head1 VERSION
32  
33 Version 1.05
34  
35 =cut
36  
37 2 our $VERSION = '1.05';
38  
39 =head1 SYNOPSIS
40  
41 This module interacts with Blue Coat SGOS-based devices. Right
42 now, this is limited to parsing of the 'sysinfo' data from the
43 device.
44  
45 use strict; #always!
46 use BlueCoat::SGOS;
47 my $bc = BlueCoat::SGOS->new(
48 'appliancehost' => 'swg.example.com',
49 'applianceport' => 8082,
50 'applianceuser' => 'admin',
51 'appliancepassword' => 'password'
52 );
53 $bc->get_sysinfo();
54 $bc->parse_sysinfo();
55  
56 # or from a file
57 my $bc = BlueCoat::SGOS->new();
58 $bc->get_sysinfo_from_file('/path/to/file.sysinfo');
59 $bc->parse_sysinfo();
60  
61 # or from a data structure
62 # in this case, $sysinfodata already contains sysinfo data
63 my $bc = BlueCoat::SGOS->new();
64 $bc->get_sysinfo_from_data($sysinfodata);
65 $bc->parse_sysinfo();
66  
67 my $sysinfodata = $bc->{'sgos_sysinfo'};
68 my $sgosversion = $bc->{'sgosversion'};
69 my $sgosreleaseid = $bc->{'sgosreleaseid'};
70 my $serialnumber = $bc->{'serialnumber'};
71 my $modelnumber = $bc->{'modelnumber'};
72 my $sysinfotime = $bc->{'sysinfotime'};
73  
74 # Hardware section of the sysinfo file
75 my $hwinfo = $bc->{'sgos_sysinfo_sect'}{'Hardware Information'};
76  
77 # Software configuration (i.e. show configuration)
78 my $swconfig = $bc->{'sgos_sysinfo_sect'}{'Software Configuration'};
79  
80  
81 =head1 SUBROUTINES/METHODS
82  
83 Below are methods for BlueCoat::SGOS.
84 =cut
85  
86 =head2 new
87  
88 Creates a new BlueCoat::SGOS object. Can be passed one of the following:
89  
90 appliancehost
91 applianceport
92 applianceusername
93 appliancepassword
94 applianceconnectmode (one of http or https)
95 debuglevel
96  
97 =cut
98  
99 1 ▶sub new {
Subroutine new: called CC=8 SCAR=24.8
Pod documented
100 1 my $class = shift;
101 1 my $self = {};
102 1 bless($self, $class);
103 1 my %args = (%defaults, @_);
104  
105 1 $self->{'_appliancehost'} = $args{'appliancehost'};
106 1 $self->{'_applianceport'} = $args{'applianceport'};
107 1 $self->{'_applianceusername'} = $args{'applianceusername'};
108 1 $self->{'_appliancepassword'} = $args{'appliancepassword'};
109 1 $self->{'_applianceconnectmode'} = $args{'applianceconnectmode'};
110 1 $self->{'_debuglevel'} = $args{'debuglevel'};
111 1 ▶ if ( $self->{'_appliancehost'}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_appliancehost"} and $self->{"_applianceport"} and $self->{"_applianceconnectmode"} and $self->{"_applianceusername"} and $self->{"_appliancepassword"}) 1 0 1
Condition33%4/12
$self->{"_appliancehost"} and $self->{"_applianceport"} and $self->{"_applianceconnectmode"} and $self->{"_applianceusername"} and $self->{"_appliancepassword"}
!ll&&!rl&&r
001
$self->{"_appliancehost"} and $self->{"_applianceport"} and $self->{"_applianceconnectmode"} and $self->{"_applianceusername"}
!ll&&!rl&&r
001
$self->{"_appliancehost"} and $self->{"_applianceport"} and $self->{"_applianceconnectmode"}
!ll&&!rl&&r
001
$self->{"_appliancehost"} and $self->{"_applianceport"}
!ll&&!rl&&r
001
MC/DC0%0/5
$self->{"_appliancehost"} and $self->{"_applianceport"} and $self->{"_applianceconnectmode"} and $self->{"_applianceusername"} and $self->{"_appliancepassword"}
$self->{"_appliancehost"} $self->{"_applianceport"} $self->{"_applianceconnectmode"} $self->{"_applianceusername"} $self->{"_appliancepassword"}
Truth table16%1/6
A and B and C and D and E
A= $self->{"_appliancehost"}B= $self->{"_applianceport"}C= $self->{"_applianceconnectmode"}D= $self->{"_applianceusername"}E= $self->{"_appliancepassword"}
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
112 && $self->{'_applianceport'}
113 && $self->{'_applianceconnectmode'}
114 && $self->{'_applianceusername'}
115 && $self->{'_appliancepassword'}) {
116  
117 1 ▶ if ($self->{'_applianceconnectmode'} eq 'https') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_applianceconnectmode'} eq 'https') { } 1 0 1
elsif ($self->{'_applianceconnectmode'} eq 'http') { } 0 0 0
118 $self->{'_applianceurlbase'} =
119 q#https://#
120 . $self->{'_appliancehost'} . q#:#
121 1 . $self->{'_applianceport'};
122 }
123 elsif ($self->{'_applianceconnectmode'} eq 'http') {
124 $self->{'_applianceurlbase'} =
125 q#http://#
126 . $self->{'_appliancehost'} . q#:#
127 0 . $self->{'_applianceport'};
128 }
129 }
130  
131 1 return $self;
132 }
133  
134 0 ▶sub _create_ua {
Subroutine _create_ua: not called CC=1 SCAR=6.9
135 0 my $self = shift;
136 0 $self->{'_lwpua'} = LWP::UserAgent->new();
137 0 $self->{'_lwpua'}->agent("BlueCoat-SGOS/$VERSION");
138 0 $self->{'_lwpua'}->ssl_opts(
139 'SSL_verify_mode' => 0,
140 'verify_hostname' => 0,
141 );
142  
143 }
144  
145 =head2 get_sysinfo
146  
147 Takes no parameters, but instead fetches the sysinfo from the
148 appliance specified in the constructor.
149  
150 $bc->get_sysinfo();
151  
152 =cut
153  
154 0 ▶sub get_sysinfo {
Subroutine get_sysinfo: not called CC=6 SCAR=37.4
Pod documented
155 0 my $self = shift;
156  
157 0 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 0 0
158 0 print 'URLBASE=' . $self->{'_applianceurlbase'} . "\n";
159 print 'Getting '
160 . $self->{'_applianceurlbase'}
161 0 . $_URL{'sysinfo'} . "\n";
162 }
163 0 ▶ if (!defined($self->{'_lwpua'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_lwpua"}) 0 0 0
164 0 $self->_create_ua();
165 }
166 my $request =
167 HTTP::Request->new('GET',
168 0 $self->{'_applianceurlbase'} . $_URL{'sysinfo'});
169 $request->authorization_basic($self->{'_applianceusername'},
170 0 $self->{'_appliancepassword'});
171 0 my $response = $self->{'_lwpua'}->request($request);
172  
173 0 ▶ if ($response->is_error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->is_error) { } 0 0 0
174 0 return 0;
175 }
176 else {
177 0 $self->{'sgos_sysinfo'} = $response->content;
178 0 $self->{'sgos_sysinfo'} =~ s/\r\n/\n/gi;
179 0 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 0 0
180 0 print 'status=' . $response->status_line . "\n";
181 }
182 }
183 0 ▶ if ($self->{'sgos_sysinfo'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'sgos_sysinfo'}) { } 0 0 0
184 0 return 1;
185 }
186 else {
187 0 return 0;
188 }
189 }
190  
191 =head2 get_sysinfo_from_file
192  
193 Takes one parameter: the filename of a sysinfo file on the disk. Use this
194 instead of logging in over the network.
195  
196 $bc->get_sysinfo_from_file('sysinfo.filename.here');
197  
198 =cut
199  
200 1 ▶sub get_sysinfo_from_file {
Subroutine get_sysinfo_from_file: called CC=4 SCAR=14.8
Pod documented
201 1 my $self = shift;
202 1 my $filename = shift;
203 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
204 0 print "sub:get_sysinfo_from_file, filename=$filename\n";
205 }
206 1 ▶ if (-f $filename) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $filename) { } 1 0 1
207 1 open my $FSDFLKFJ, q{<} , $filename;
208  
209 # slurp
210 {
211 1 local $/ = undef;
212 1 $self->{'sgos_sysinfo'} = <$FSDFLKFJ>;
213 1 $self->{'sgos_sysinfo'} =~ s/\r\n/\n/gi;
214 }
215 1 close $FSDFLKFJ;
216  
217 1 ▶ if ($self->{'sgos_sysinfo'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'sgos_sysinfo'}) { } 1 0 1
218 1 return 1;
219 }
220 else {
221 0 return 0;
222 }
223 }
224 else {
225  
226 # no filename specified
227 0 return 0;
228 }
229 }
230  
231 =head2 get_sysinfo_from_data
232  
233 Takes one parameter: a scalar that contains sysinfo data.
234 Use this instead of logging in over the network.
235  
236 $bc->get_sysinfo_from_data($sysinfodata);
237  
238 =cut
239  
240 0 ▶sub get_sysinfo_from_data {
Subroutine get_sysinfo_from_data: not called CC=3 SCAR=24.8
Pod documented
241 0 my $self = shift;
242 0 my $data = shift;
243 0 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 0 0
244 0 print "sub:get_sysinfo_from_data\n";
245 }
246 0 $self->{'sgos_sysinfo'} = $data;
247 0 $self->{'sgos_sysinfo'} =~ s/\r\n/\n/gi;
248 0 ▶ if ($self->{'sgos_sysinfo'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'sgos_sysinfo'}) { } 0 0 0
249 0 return 1;
250 }
251 else {
252 0 return 0;
253 }
254 }
255  
256 =head2 parse_sysinfo
257  
258 Takes no parameters. Tells the object to parse the sysinfo
259 data and populate the object variables.
260  
261 =cut
262  
263 1 ▶sub parse_sysinfo {
Subroutine parse_sysinfo: called CC=6 SCAR=17.9
Pod documented
264 1 my $self = shift;
265 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
266 0 print "parse_sysinfo\n";
267 }
268 my @split_sysinfo =
269 split(
270 /__________________________________________________________________________/,
271 1 $self->{'sgos_sysinfo'}
272 );
273 1 $self->{'_sgos_sysinfo_split_count'} = $#split_sysinfo;
274  
275 # init the % var
276 1 $self->{'sgos_sysinfo_sect'}{'_ReportInfo'} = $split_sysinfo[0];
277  
278 # Populate the sysinfo version
279 # As of 6.2.2011, these are the known versions:
280 # Version 4.6
281 # Version 5.0
282 # Version 6.0
283 # Version 6.1
284 # Version 7.0
285 ($self->{'_sysinfoversion'}) =
286 1 $self->{'sgos_sysinfo_sect'}{'_ReportInfo'} =~ m/Version (\d+\.\d+)/;
287  
288 # Loop through each section of the split sysinfo
289 1 foreach (1 .. $#split_sysinfo) {
290 113 my $chunk = $split_sysinfo[$_];
291 113 my @section = split(/\n/, $chunk);
292 113 chomp @section;
293  
294 # the first 2 lines are junk
295 113 shift @section;
296 113 shift @section;
297 113 my $sectionname = shift @section;
298  
299 113 ▶ if ($sectionname eq 'Software Configuration') {
Branch: 1 branch
BranchTrueFalseTotal
if ($sectionname eq "Software Configuration") 1 112 113
300  
301 # get rid of 3 lines from top and 1 from bottom
302 1 shift @section;
303 1 shift @section;
304 1 shift @section;
305 1 pop @section;
306 }
307 113 ▶ if ($sectionname eq 'TCP/IP Routing Table') {
Branch: 1 branch
BranchTrueFalseTotal
if ($sectionname eq "TCP/IP Routing Table") 1 112 113
308 1 shift @section;
309 1 shift @section;
310 1 shift @section;
311 1 shift @section;
312 1 shift @section;
313 }
314  
315 # throw away the next line, it contains the URL for the source data
316 113 shift @section;
317 113 my $data = join("\n", @section);
318 113 $self->{'sgos_sysinfo_sect'}{$sectionname} = $data;
319 }
320  
321 # parse version
322 1 $self->_parse_sgos_version();
323  
324 # parse releaseid
325 1 $self->_parse_sgos_releaseid();
326  
327 # parse serial number
328 1 $self->_parse_serial_number();
329  
330 # parse sysinfo time
331 1 $self->_parse_sysinfo_time();
332  
333 # parse last reboot time
334 1 $self->_parse_reboot_time();
335  
336 # parse model
337 1 $self->_parse_model_number();
338  
339 # parse the configuration
340 1 ▶ if ($self->{'sgos_sysinfo_sect'}{'Software Configuration'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'sgos_sysinfo_sect'}{'Software Configuration'}) { } 1 0 1
341 1 $self->_parse_swconfig;
342 1 $self->{'sysinfo_type'} = 'sysinfo';
343 }
344 else {
345 0 $self->{'sysinfo_type'} = 'sysinfo_snapshot';
346 }
347  
348 # parse VPM-CPL and VPM-XML
349 1 $self->_parse_vpm();
350  
351 # parse the static bypass list
352 1 $self->_parse_static_bypass();
353  
354 # parse the appliance name
355 1 $self->_parse_appliance_name();
356  
357 # parse the network information
358 1 $self->_parse_network();
359  
360 # parse the ssl accelerator info
361 1 $self->_parse_ssl_accelerator();
362  
363 # parse the default gateway
364 1 $self->_parse_default_gateway();
365  
366 # parse the route table
367 1 $self->_parse_route_table();
368  
369 1 return 1;
370 }
371  
372 # Find appliance-name
373 # located in the Software Configuration
374 # looks like:
375 # appliance-name "ProxySG 210 4609077777"
376 # limited to 127 characters
377 # e.g.: % String exceeds allowed length (127)
378 #
379 1 ▶sub _parse_appliance_name {
Subroutine _parse_appliance_name: called CC=4 SCAR=15.2
380 1 my $self = shift;
381 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
382 0 print "_parse_swconfig\n";
383 }
384 1 ▶ if (defined($self->{'sgos_sysinfo_sect'}{'Software Configuration'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_sysinfo_sect"}{"Software Configuration"}) 1 0 1
385 (undef, $self->{'appliance-name'}) =
386 1 $self->{'sgos_sysinfo_sect'}{'Software Configuration'} =~
387 m/(appliance-name|hostname) (.+)$/im;
388 1 $self->{'appliance-name'} =~ s/^\"//;
389 1 $self->{'appliance-name'} =~ s/\"$//;
390  
391 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
392 0 print "appliancename=$self->{'appliance-name'}\n";
393 }
394 }
395 }
396  
397 # model
398 # Model: 200-B
399 1 ▶sub _parse_model_number {
Subroutine _parse_model_number: called CC=4 SCAR=16.1
400 1 my $self = shift;
401 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
402 0 print "_parse_model_number\n";
403 }
404  
405 #210-5 (unsupported configuration)
406 #
407 1 ▶ if (defined($self->{'sgos_sysinfo_sect'}{'Hardware Information'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_sysinfo_sect"}{"Hardware Information"}) 1 0 1
408 ($self->{'modelnumber'}) =
409 1 $self->{'sgos_sysinfo_sect'}{'Hardware Information'} =~
410 m/Model:\s(.+)/im;
411 1 ▶ if ($self->{'modelnumber'} =~ m/unsupported configuration/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'modelnumber'} =~ /unsupported configuration/i) { } 0 1 1
412 0 $self->{'modelnumber'} =~ s/\s*\(unsupported configuration\)\s*//ig;
413 0 $self->{'supported_configuration'} = 0;
414 }
415 else {
416 1 $self->{'supported_configuration'} = 1;
417 }
418 }
419 }
420  
421 # get network
422 # Network:
423 # Interface 0:0: Bypass 10/100 with no link (MAC 00:d0:83:04:ae:fc)
424 # Interface 0:1: Bypass 10/100 running at 100 Mbps full duplex (MAC 00:d0:83:04:ae:fd)
425 1 ▶sub _parse_network {
Subroutine _parse_network: called CC=28 SCAR=34.1
426 1 my $self = shift;
427 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
428 0 print "_parse_network\n";
429 }
430 1 ▶ if (defined($self->{'sgos_sysinfo_sect'}{'Hardware Information'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_sysinfo_sect"}{"Hardware Information"}) 1 0 1
431 my ($netinfo) =
432 1 $self->{'sgos_sysinfo_sect'}{'Hardware Information'} =~
433 m/Network:(.+)Accelerators/ism;
434 1 my @s = split(/\n/, $netinfo);
435 1 chomp @s;
436 1 foreach (@s) {
437 3 my $line = $_;
438 3 my ($interface) = $line =~ m/Interface\s+(.+)\:\s/im;
439 3 my ($mac) = $line =~ m/\(MAC\s(.+)\)/im;
440 3 my ($running) = $line =~ m/running\sat\s(.+)\s\(MAC/im;
441 3 my $capabilities;
442  
443 #Interface 0:0: Intel Gigabit running at 1 Gbps full duplex (MAC 00:e0:81:79:a5:1a)
444 #Interface 2:0: Bypass 10/100/1000 with no link (MAC 00:e0:ed:0b:67:e6)
445 3 ▶ if ($line =~ m/running at/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /running at/) 1 2 3
446 1 ($capabilities) =
447 $line =~ m/Interface\s$interface\:\s\w+(.+)\s+running at/;
448 }
449 3 ▶ if ($line =~ m/with no link/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /with no link/) 1 2 3
450 1 ($capabilities) =
451 $line =~ m/Interface\s$interface\:\s\w+(.+)\s+with no link/;
452 }
453 3 ▶ if ($capabilities) {
Branch: 1 branch
BranchTrueFalseTotal
if ($capabilities) 2 1 3
454 2 $capabilities =~ s/\s+//ig;
455 }
456 3 ▶ if ($interface && $capabilities) {
Branch: 1 branch
BranchTrueFalseTotal
if ($interface and $capabilities) 2 1 3
Condition66%2/3
$interface and $capabilities
!ll&&!rl&&r
102
MC/DC50%1/2
$interface and $capabilities
$interface $capabilities
Truth table66%2/3
A and B
A= $interfaceB= $capabilities
ABresult
0X0
100
111
457 2 $self->{'interface'}{$interface}{'capabilities'} =
458 $capabilities;
459 }
460  
461 #print "Running=$running\n";
462 3 ▶ if ($interface && $mac) {
Branch: 1 branch
BranchTrueFalseTotal
if ($interface and $mac) 2 1 3
Condition66%2/3
$interface and $mac
!ll&&!rl&&r
102
MC/DC50%1/2
$interface and $mac
$interface $mac
Truth table66%2/3
A and B
A= $interfaceB= $mac
ABresult
0X0
100
111
463 2 $self->{'interface'}{$interface}{'mac'} = $mac;
464 }
465 3 ▶ if ($interface && $running) {
Branch: 1 branch
BranchTrueFalseTotal
if ($interface and $running) 1 2 3
Condition100%3/3
$interface and $running
!ll&&!rl&&r
111
MC/DC100%2/2
$interface and $running
$interface $running
Truth table100%3/3
A and B
A= $interfaceB= $running
ABresult
0X0
100
111
466 1 $self->{'interface'}{$interface}{'linkstatus'} = $running;
467 }
468 3 ▶ if ($interface && !$running) {
Branch: 1 branch
BranchTrueFalseTotal
if ($interface and not $running) 1 2 3
Condition100%3/3
$interface and not $running
!ll&&!rl&&r
111
MC/DC100%2/2
$interface and not $running
$interface not $running
Truth table100%3/3
A and not(B)
A= $interfaceB= not $running
ABresult
0X0
100
111
469 1 $self->{'interface'}{$interface}{'linkstatus'} = 'no link';
470 }
471  
472 #print "interface=$interface, mac=$mac\n";
473 }
474 }
475  
476 # supplement from swconfig/networking
477 #print "getting supplemental networking info\n";
478 1 my @t;
479  
480 #if (defined($self->{'sgos_swconfig_section'}{'networking'} ) ) {
481 1 ▶ if (defined($self->{'sgos_swconfig_section'}{'networking'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_swconfig_section"}{"networking"}) 1 0 1
482 1 @t = split(/\n/, $self->{'sgos_swconfig_section'}{'networking'});
483 1 chomp @t;
484 }
485  
486 1 ▶ if (defined($self->{'sgos_sysinfo_sect'}{'Software Configuration'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_sysinfo_sect"}{"Software Configuration"}) 1 0 1
487 1 ▶ if ($#t < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#t < 2) 0 1 1
488 @t =
489 split(/\n/,
490 0 $self->{'sgos_sysinfo_sect'}{'Software Configuration'});
491 }
492 }
493  
494 #}
495  
496 1 my $interface;
497 1 my ($ip, $netmask);
498 1 foreach (@t) {
499 29 my $line = $_;
500  
501 29 ▶ if ($line =~ m/interface (.+)\;/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /interface (.+)\;/i) 2 27 29
502 2 ($interface) = $line =~ m/^interface (\d+\:?\d*\.*\d*)/i;
503 }
504  
505 # sgos5, ip address and subnet mask are on SAME line
506 29 ▶ if ($line =~ m/ip-address/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /ip-address/) 1 28 29
507  
508 1 ($ip, $netmask) =
509 $line =~
510 m/^ip-address\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) *(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})*/i;
511 1 ▶ if (defined($ip)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ip) 1 0 1
512 1 $ip =~ s/\s+//gi;
513 }
514 1 ▶ if (defined($netmask)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $netmask) 1 0 1
515 1 $netmask =~ s/\s+//gi;
516 }
517 }
518 29 ▶ if ($line =~ m/subnet-mask/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /subnet-mask/) 0 29 29
519 0 ($netmask) =
520 $line =~ m/^subnet-mask *(.{1,3}\..{1,3}\..{1,3}\..{1,3})/i;
521 0 $netmask =~ s/\s+//gi;
522 }
523  
524 29 ▶ if (defined($interface)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $interface) 6 23 29
525 6 ▶ if (length($interface) > 1 && $ip && $netmask) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $interface > 1 and $ip and $netmask) 1 5 6
Condition66%4/6
length $interface > 1 and $ip and $netmask
!ll&&!rl&&r
501
length $interface > 1 and $ip
!ll&&!rl&&r
051
MC/DC33%1/3
length $interface > 1 and $ip and $netmask
length $interface > 1 $ip $netmask
Truth table50%2/4
A and B and C
A= length $interface > 1B= $ipC= $netmask
ABCresult
0XX0
10X0
1100
1111
526 1 $self->{'interface'}{$interface}{'ip'} = $ip;
527 1 $self->{'interface'}{$interface}{'netmask'} = $netmask;
528 1 $interface = undef;
529 1 $ip = undef;
530 }
531 }
532  
533 }
534 }
535  
536 1 ▶sub _parse_swconfig {
Subroutine _parse_swconfig: called CC=6 SCAR=18.0
537 1 my $self = shift;
538 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
539 0 print "_parse_swconfig\n";
540 }
541 my @split_swconfig =
542 1 split(/\n/, $self->{'sgos_sysinfo_sect'}{'Software Configuration'});
543  
544 # only applies to SGOS >5
545 1 my $sectionname = '';
546 1 foreach (1 .. $#split_swconfig) {
547 2181 my $line = $split_swconfig[$_];
548 2181 chomp $line;
549 2181 ▶ if ($line =~ m/!- BEGIN/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($line =~ /!- BEGIN/) { } 25 2156 2181
elsif ($line =~ /!- END/) { } 25 2131 2156
550 25 ($sectionname) = $line =~ m/!- BEGIN (.+)/;
551 }
552 elsif ($line =~ m/!- END/) {
553 25 next;
554 }
555 else {
556 2131 ▶ if (defined($self->{'sgos_swconfig_section'}{$sectionname})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'sgos_swconfig_section'}{$sectionname}) { } 2116 15 2131
557 $self->{'sgos_swconfig_section'}{$sectionname} =
558 2116 $self->{'sgos_swconfig_section'}{$sectionname} . $line . "\n";
559 }
560 else {
561 15 $self->{'sgos_swconfig_section'}{$sectionname} = $line . "\n";
562 }
563 }
564  
565 }
566  
567 }
568  
569 1 ▶sub _parse_static_bypass {
Subroutine _parse_static_bypass: called CC=7 SCAR=28.9
570 1 my $self = shift;
571 1 ▶ if (defined($self->{'sgos_sysinfo_sect'}{'Software Configuration'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_sysinfo_sect"}{"Software Configuration"}) 1 0 1
572 my @lines =
573 1 split(/\n/, $self->{'sgos_sysinfo_sect'}{'Software Configuration'});
574 1 my $have_static_bypass;
575 1 foreach my $line (@lines) {
576 2182 ▶ if ($line =~ m/static-bypass/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($line =~ /static-bypass/) { } 0 2182 2182
elsif ($have_static_bypass) { } 0 2182 2182
577 0 $have_static_bypass = 1;
578 }
579 elsif ($have_static_bypass) {
580 0 ▶ if ($line =~ m/exit/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /exit/) { } 0 0 0
581 0 last;
582 }
583 else {
584 0 $line =~ s/^add //i;
585 0 ▶ if (defined($self->{'static-bypass'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'static-bypass'}) { } 0 0 0
586 $self->{'static-bypass'} =
587 0 $self->{'static-bypass'} . $line . "\n";
588 }
589 else {
590 0 $self->{'static-bypass'} = $line . "\n";
591 }
592 }
593 }
594 }
595 }
596 }
597  
598 1 ▶sub _parse_vpm {
Subroutine _parse_vpm: called CC=14 SCAR=26.5
599 1 my $self = shift;
600 1 ▶ if (defined($self->{'sgos_sysinfo_sect'}{'Software Configuration'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_sysinfo_sect"}{"Software Configuration"}) 1 0 1
601 my @lines =
602 1 split(/\n/, $self->{'sgos_sysinfo_sect'}{'Software Configuration'});
603 1 my $have_vpm_cpl;
604 my $have_vpm_xml;
605  
606 1 foreach my $line (@lines) {
607 1440 ▶ if ($line =~ m/^inline policy vpm-cpl \"*end-(\d+)-inline\"*/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($line =~ /^inline policy vpm-cpl \"*end-(\d+)-inline\"*/) { } 1 1439 1440
elsif ($have_vpm_cpl) { } 93 1346 1439
608 1 ($have_vpm_cpl) =
609 $line =~ m/^inline policy vpm-cpl \"*end-(\d+)-inline\"*/;
610 }
611 elsif ($have_vpm_cpl) {
612 93 ▶ if ($line =~ m/end-$have_vpm_cpl-inline/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /end-$have_vpm_cpl-inline/i) { } 1 92 93
613 1 last;
614 }
615 else {
616 92 ▶ if (defined($self->{'vpm-cpl'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'vpm-cpl'}) { } 91 1 92
617 91 $self->{'vpm-cpl'} = $self->{'vpm-cpl'} . $line . "\n";
618 }
619 else {
620 1 $self->{'vpm-cpl'} = $line . "\n";
621 }
622 }
623 }
624  
625 }
626  
627 1 foreach my $line (@lines) {
628 2181 ▶ if ($line =~ m/^inline policy vpm-xml \"*end-(\d+)-inline\"*/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($line =~ /^inline policy vpm-xml \"*end-(\d+)-inline\"*/) { } 1 2180 2181
elsif ($have_vpm_xml) { } 740 1440 2180
629 1 ($have_vpm_xml) =
630 $line =~ m/^inline policy vpm-xml \"*end-(\d+)-inline\"*/;
631 }
632 elsif ($have_vpm_xml) {
633 740 ▶ if ($line =~ m/end-$have_vpm_xml-inline/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /end-$have_vpm_xml-inline/i) { } 1 739 740
634 1 last;
635 }
636 else {
637 739 ▶ if (defined($self->{'vpm-xml'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'vpm-xml'}) { } 738 1 739
638 738 $self->{'vpm-xml'} = $self->{'vpm-xml'} . $line . "\n";
639 }
640 else {
641 1 $self->{'vpm-xml'} = $line . "\n";
642 }
643 }
644 }
645  
646 }
647 }
648  
649 1 ▶ return 1 if ($self->{'vpm-cpl'} && $self->{'vpm-xml'});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"vpm-cpl"} and $self->{"vpm-xml"} 1 0 1
Condition33%1/3
$self->{"vpm-cpl"} and $self->{"vpm-xml"}
!ll&&!rl&&r
001
MC/DC0%0/2
$self->{"vpm-cpl"} and $self->{"vpm-xml"}
$self->{"vpm-cpl"} $self->{"vpm-xml"}
Truth table33%1/3
A and B
A= $self->{"vpm-cpl"}B= $self->{"vpm-xml"}
ABresult
0X0
100
111
650 }
651  
652 =head2 vpmcpl
653  
654 Displays the VPM-CPL data. Note that this does not currently return the
655 local, central, or forwarding policies.
656  
657 =cut
658  
659 0 ▶sub vpmcpl {
Subroutine vpmcpl: not called CC=1 SCAR=6.9
Pod documented
660 0 my $self = shift;
661 0 return $self->{'vpm-cpl'};
662 }
663  
664 =head2 vpmxml
665  
666 Displays the VPM-XML data.
667  
668 =cut
669  
670 0 ▶sub vpmxml {
Subroutine vpmxml: not called CC=1 SCAR=6.9
Pod documented
671 0 my $self = shift;
672 0 return $self->{'vpm-xml'};
673 }
674  
675 1 ▶sub _parse_default_gateway {
Subroutine _parse_default_gateway: called CC=8 SCAR=21.4
676 1 my $self = shift;
677 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
678 }
679  
680 1 my @s;
681 1 ▶ if (defined($self->{'sgos_swconfig_section'}{'networking'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_swconfig_section"}{"networking"}) 1 0 1
682 1 my @s = split(/\n/, $self->{'sgos_swconfig_section'}{'networking'});
683 1 chomp @s;
684 }
685 1 ▶ if (defined($self->{'sgos_sysinfo_sect'}{'Software Configuration'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_sysinfo_sect"}{"Software Configuration"}) 1 0 1
686 1 ▶ if ($#s < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#s < 2) 1 0 1
687 @s =
688 split(/\n/,
689 1 $self->{'sgos_sysinfo_sect'}{'Software Configuration'});
690 }
691 }
692 1 ▶ if ($#s > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#s > 0) 1 0 1
693 1 foreach my $line (@s) {
694 2182 ▶ if ($line =~ m/ip-default-gateway/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /ip-default-gateway/) 1 2181 2182
695 1 ($self->{'ip-default-gateway'}) = $line =~
696 m/^ip-default-gateway +(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
697 }
698 }
699 }
700  
701 }
702  
703 1 ▶sub _parse_route_table {
Subroutine _parse_route_table: called CC=14 SCAR=46.6
704 1 my $self = shift;
705 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
706 0 print "_parse_route_table: begin\n";
707 }
708  
709 #inline static-route-table "end-398382495-inline"
710 #; IP-Address Subnet Mask Gateway
711 #172.16.0.0 255.240.0.0 172.20.144.1
712 #end-398382495-inline
713 1 ▶ if (defined($self->{'sgos_sysinfo_sect'}{'TCP/IP Routing Table'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_sysinfo_sect"}{"TCP/IP Routing Table"}) 1 0 1
714 1 my @r;
715 1 ▶ if ($self->{'sgos_sysinfo_sect'}{'TCP/IP Routing Table'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'sgos_sysinfo_sect'}{'TCP/IP Routing Table'}) { } 1 0 1
716 $self->{'routetable'} =
717 1 $self->{'sgos_sysinfo_sect'}{'TCP/IP Routing Table'};
718 }
719 else {
720 @r =
721 split(/\n/,
722 0 $self->{'sgos_sysinfo_sect'}{'Software Configuration'});
723 }
724 1 my $marker;
725 1 foreach my $line (@r) {
726 0 ▶ if ($line =~ m/inline static-route-table \"end-\d+-inline\"/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /inline static-route-table \"end-\d+-inline\"/i) 0 0 0
727 0 ($marker) =
728 $line =~ m/inline static-route-table \"end-(\d+)-inline\"/i;
729 }
730 0 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 0 0
731 0 print "_parse_route_table: marker=$marker\n";
732 }
733 0 ▶ if (defined($marker)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $marker) 0 0 0
734 0 ▶ if ($line =~ m/end-$marker-inline/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /end-$marker-inline/o) 0 0 0
735 0 $marker = undef;
736 }
737 }
738 0 ▶ if ($marker && $line !~ /$marker/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($marker and not $line =~ /$marker/i) 0 0 0
Condition0%0/3
$marker and not $line =~ /$marker/i
!ll&&!rl&&r
000
MC/DC0%0/2
$marker and not $line =~ /$marker/i
$marker not $line =~ /$marker/i
Truth table0%0/3
A and not(B)
A= $markerB= not $line =~ /$marker/i
ABresult
0X0
100
111
739 0 ▶ if ($line =~ m/^\s*?\;/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s*?\;/) 0 0 0
740 0 next;
741 }
742 0 ▶ if ($line =~
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/) 0 0 0
743 m/\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
744 ) {
745 0 ▶ if (defined($self->{'static-route-table'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'static-route-table'}) { } 0 0 0
746 $self->{'static-route-table'} =
747 0 $self->{'static-route-table'} . $line . "\n";
748 }
749 else {
750 0 $self->{'static-route-table'} = $line . "\n";
751 }
752  
753 }
754 }
755 }
756 }
757  
758 }
759  
760 1 ▶sub _parse_serial_number {
Subroutine _parse_serial_number: called CC=3 SCAR=12.0
761 1 my $self = shift;
762 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
763 0 print "_parse_sgos_serial_number\n";
764 }
765 1 ▶ if (defined($self->{'sgos_sysinfo_sect'}{'Version Information'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_sysinfo_sect"}{"Version Information"}) 1 0 1
766 ($self->{'serialnumber'}) =
767 1 $self->{'sgos_sysinfo_sect'}{'Version Information'} =~
768 m/Serial\snumber\sis\s(\d+)/isx;
769 }
770 }
771  
772 1 ▶sub _parse_ssl_accelerator {
Subroutine _parse_ssl_accelerator: called CC=5 SCAR=17.8
773 1 my $self = shift;
774 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
775 0 print "_parse_ssl_accelerator\n";
776 }
777  
778 # SSL Accelerators
779 # looks like:
780 # Accelerators: none
781 # or
782 # Accelerators:
783 # Internal: Cavium CN1010 Security Processor
784 # Internal: Cavium CN501 Security Processor
785 # Internal: Broadcom 5825 Security Processor
786 #
787 1 ▶ if (defined($self->{'sgos_sysinfo_sect'}{'Hardware Information'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_sysinfo_sect"}{"Hardware Information"}) 1 0 1
788 my ($acceleratorinfo) =
789 1 $self->{'sgos_sysinfo_sect'}{'Hardware Information'} =~
790 m/(Accelerators\:.+)/ism;
791 1 my @a = split(/\n/, $acceleratorinfo);
792  
793 #print "There are $#a lines\n";
794 # if 1 line, then no SSL accelerator
795 1 ▶ if ($#a == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#a == 0) 1 0 1
796 1 $self->{'ssl-accelerator'} = 'none';
797 }
798 1 ▶ if ($#a > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#a > 0) 0 1 1
799 0 ($self->{'ssl-accelerator'}) = $a[1] =~ m/\s+(.+)/;
800 }
801 }
802  
803 # print "DEBUG: acceleratorinfo=$acceleratorinfo\n";
804 #print "DEBUG: ssl-accelerator=$self->{'ssl-accelerator'}\n";
805 }
806  
807 # sysinfo time
808 # time on this file
809 # The current time is Mon Nov 23, 2009 18:48:38 GMT (SystemTime 438547718)
810 # The current time is Sat Mar 7, 2009 16:57:30 GMT (SystemTime 415990650)
811 1 ▶sub _parse_sysinfo_time {
Subroutine _parse_sysinfo_time: called CC=3 SCAR=11.8
812 1 my $self = shift;
813 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
814 0 print "_parse_sysinfo_time\n";
815 }
816 1 ▶ if (defined($self->{'sgos_sysinfo_sect'}{'Version Information'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_sysinfo_sect"}{"Version Information"}) 1 0 1
817 ($self->{'sysinfotime'}) =
818 1 $self->{'sgos_sysinfo_sect'}{'Version Information'} =~
819 m/^The current time is (.+) \(/im;
820 1 $self->{'sysinfotime_epoch'} = str2time($self->{'sysinfotime'});
821 }
822 }
823  
824 1 ▶sub _parse_reboot_time {
Subroutine _parse_reboot_time: called CC=11 SCAR=27.2
825 1 my $self = shift;
826 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
827 0 print "_parse_reboot_time\n";
828 }
829  
830 # Calculate hardware reboot time
831 # The ProxySG Appliance was last hardware rebooted 1 days, 5 hours, 55 minutes, and 0 seconds ago.
832 1 ▶ if (defined($self->{'sgos_sysinfo_sect'}{'Version Information'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_sysinfo_sect"}{"Version Information"}) 1 0 1
833 ($self->{'hardware_reboot'}) =
834 1 $self->{'sgos_sysinfo_sect'}{'Version Information'} =~
835 m/The ProxySG Appliance was last hardware rebooted (.*)$/m;
836 ($self->{'hardware_reboot_day'}) =
837 1 $self->{'hardware_reboot'} =~ m/(\d+) day/;
838 1 ▶ if (!defined($self->{'hardware_reboot_day'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"hardware_reboot_day"}) 1 0 1
839 1 $self->{'hardware_reboot_day'} = 0;
840 }
841 ($self->{'hardware_reboot_hour'}) =
842 1 $self->{'hardware_reboot'} =~ m/(\d+) hour/;
843 1 ▶ if (!defined($self->{'hardware_reboot_hour'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"hardware_reboot_hour"}) 0 1 1
844 0 $self->{'hardware_reboot_hour'} = 0;
845 }
846 ($self->{'hardware_reboot_minute'}) =
847 1 $self->{'hardware_reboot'} =~ m/(\d+) minute/;
848 1 ▶ if (!defined($self->{'hardware_reboot_minute'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"hardware_reboot_minute"}) 0 1 1
849 0 $self->{'hardware_reboot_minute'} = 0;
850 }
851 ($self->{'hardware_reboot_second'}) =
852 1 $self->{'hardware_reboot'} =~ m/(\d+) second/;
853 1 ▶ if (!defined($self->{'hardware_reboot_second'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"hardware_reboot_second"}) 0 1 1
854 0 $self->{'hardware_reboot_second'} = 0;
855 }
856 $self->{'hardware_reboot_seconds_total'} =
857 ($self->{'hardware_reboot_day'} * 24 * 3600) +
858 ($self->{'hardware_reboot_hour'} * 3600) +
859 ($self->{'hardware_reboot_minute'} * 60) +
860 1 $self->{'hardware_reboot_second'};
861  
862 # The ProxySG Appliance was last software rebooted 1 days, 5 hours, 55 minutes, and 1 seconds ago.
863  
864 ($self->{'software_reboot'}) =
865 1 $self->{'sgos_sysinfo_sect'}{'Version Information'} =~
866 m/The ProxySG Appliance was last software rebooted (.*)$/m;
867 ($self->{'software_reboot_day'}) =
868 1 $self->{'software_reboot'} =~ m/(\d+) day/;
869 1 ▶ if (!defined($self->{'software_reboot_day'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"software_reboot_day"}) 1 0 1
870 1 $self->{'software_reboot_day'} = 0;
871 }
872 ($self->{'software_reboot_hour'}) =
873 1 $self->{'software_reboot'} =~ m/(\d+) hour/;
874 1 ▶ if (!defined($self->{'software_reboot_hour'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"software_reboot_hour"}) 0 1 1
875 0 $self->{'software_reboot_hour'} = 0;
876 }
877 ($self->{'software_reboot_minute'}) =
878 1 $self->{'software_reboot'} =~ m/(\d+) minute/;
879 1 ▶ if (!defined($self->{'software_reboot_minute'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"software_reboot_minute"}) 0 1 1
880 0 $self->{'software_reboot_minute'} = 0;
881 }
882 ($self->{'software_reboot_second'}) =
883 1 $self->{'software_reboot'} =~ m/(\d+) second/;
884 1 ▶ if (!defined($self->{'software_reboot_second'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"software_reboot_second"}) 0 1 1
885 0 $self->{'software_reboot_second'} = 0;
886 }
887 $self->{'software_reboot_seconds_total'} =
888 ($self->{'software_reboot_day'} * 24 * 3600) +
889 ($self->{'software_reboot_hour'} * 3600) +
890 ($self->{'software_reboot_minute'} * 60) +
891 1 $self->{'software_reboot_second'};
892 }
893 }
894  
895 1 ▶sub _parse_sgos_releaseid {
Subroutine _parse_sgos_releaseid: called CC=3 SCAR=12.0
896 1 my $self = shift;
897 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
898 0 print "_parse_sgos_releaseid\n";
899 }
900  
901 # parse SGOS version, SGOS releaseid, and serial number
902 # SGOS release ID
903 1 ▶ if (defined($self->{'sgos_sysinfo_sect'}{'Version Information'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_sysinfo_sect"}{"Version Information"}) 1 0 1
904 ($self->{'sgosreleaseid'}) =
905 1 $self->{'sgos_sysinfo_sect'}{'Version Information'} =~
906 m/Release\sid:\s(\d+)/isx;
907 }
908 }
909  
910 1 ▶sub _parse_sgos_version {
Subroutine _parse_sgos_version: called CC=5 SCAR=19.7
911 1 my $self = shift;
912 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
913 0 print "_parse_sgos_version\n";
914 }
915  
916 # parse SGOS version, SGOS releaseid, and serial number
917 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
918 0 print "VERSION INFO SECTION:\n";
919 0 print $self->{'sgos_sysinfo_sect'}{'Version Information'} . "\n";
920 }
921  
922 # SGOS version
923 # #Version Information
924 # URL_Path /SYSINFO/Version
925 # Blue Coat Systems, Inc., ProxySG Appliance Version Information
926 # Version: SGOS 4.2.10.1
927 #
928 1 ▶ if (defined($self->{'sgos_sysinfo_sect'}{'Version Information'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"sgos_sysinfo_sect"}{"Version Information"}) 1 0 1
929 ($self->{'sgosversion'}) =
930 1 $self->{'sgos_sysinfo_sect'}{'Version Information'} =~
931 m/Version:\sSGOS\s(\d+\.\d+\.\d+\.\d+)/im;
932 1 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 1 1
933 0 print "SGOS version = $self->{'sgosversion'}\n";
934 }
935 }
936 }
937  
938 =head2 send_command
939  
940 Takes one parameter: a scalar that contains configuration commands to send to the appliance.
941 This command is executed in configuration mode.
942  
943 my $output = $bc->send_command('show version');
944 # or
945 my $commands =qq{
946 int 0:0
947 speed 100
948 };
949 my $output = $bc->send_command($commands);
950  
951 =cut
952  
953 0 ▶sub send_command {
Subroutine send_command: not called CC=4 SCAR=30.0
Pod documented
954 0 my $self = shift;
955 0 my $command = shift;
956 0 ▶ if ($self->{'_debuglevel'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debuglevel"} > 0) 0 0 0
957 0 print "begin sub:send_command\n";
958 0 print "command=$command\n";
959 }
960 0 ▶ if (!defined($self->{'_lwpua'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_lwpua"}) 0 0 0
961 0 $self->_create_ua();
962 }
963 0 my $request = POST $self->{'_applianceurlbase'} . $_URL{'send_command'},
964 Content_Type => 'form-data',
965 'Content' => ['file' => $command];
966 $request->authorization_basic($self->{'_applianceusername'},
967 0 $self->{'_appliancepassword'});
968 0 my $response = $self->{'_lwpua'}->request($request);
969 0 my $content;
970 0 ▶ if ($response->is_success) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->is_success) { } 0 0 0
971 0 $content = $response->content;
972 }
973 else {
974 0 die 'error';
975 }
976 0 $content =~ s/\r//ig;
977 0 return $content;
978 }
979  
980 =head2 Other Data
981  
982 Other data that is directly accessible in the object:
983  
984 Appliance Name: $bc->{'appliance-name'}
985 Model Number: $bc->{'modelnumber'}
986 Serial Number: $bc->{'serialnumber'}
987 SGOS Version: $bc->{'sgosversion'}
988 Release ID: $bc->{'sgosreleaseid'}
989 Default Gateway: $bc->{'ip-default-gateway'}
990 Sysinfo Time: $bc->{'sysinfotime'}
991 Accelerator Info: $bc->{'ssl-accelerator'}
992  
993 The software configuration can be retrieved as follows:
994 $bc->{'sgos_sysinfo_sect'}{'Software Configuration'}
995  
996 Other sections that can be retrieved:
997 $bc->{'sgos_sysinfo_sect'}{'Software Configuration'}
998 $bc->{'sgos_sysinfo_sect'}{'ADN Compression Statistics'}
999 $bc->{'sgos_sysinfo_sect'}{'ADN Configuration'}
1000 $bc->{'sgos_sysinfo_sect'}{'ADN Node Info'}
1001 $bc->{'sgos_sysinfo_sect'}{'ADN Sizing Peers'}
1002 $bc->{'sgos_sysinfo_sect'}{'ADN Sizing Statistics'}
1003 $bc->{'sgos_sysinfo_sect'}{'ADN Tunnel Statistics'}
1004 $bc->{'sgos_sysinfo_sect'}{'AOL IM Statistics'}
1005 $bc->{'sgos_sysinfo_sect'}{'Access Log Objects'}
1006 $bc->{'sgos_sysinfo_sect'}{'Access Log Statistics'}
1007 $bc->{'sgos_sysinfo_sect'}{'Authenticator Memory Statistics'}
1008 $bc->{'sgos_sysinfo_sect'}{'Authenticator Realm Statistics'}
1009 $bc->{'sgos_sysinfo_sect'}{'Authenticator Total Realm Statistics'}
1010 $bc->{'sgos_sysinfo_sect'}{'CCM Configuration'}
1011 $bc->{'sgos_sysinfo_sect'}{'CCM Statistics'}
1012 $bc->{'sgos_sysinfo_sect'}{'CIFS Memory Usage'}
1013 $bc->{'sgos_sysinfo_sect'}{'CIFS Statistics'}
1014 $bc->{'sgos_sysinfo_sect'}{'CPU Monitor'}
1015 $bc->{'sgos_sysinfo_sect'}{'CacheEngine Main'}
1016 $bc->{'sgos_sysinfo_sect'}{'Configuration Change Events'}
1017 $bc->{'sgos_sysinfo_sect'}{'Content Filter Status'}
1018 $bc->{'sgos_sysinfo_sect'}{'Core Image'}
1019 $bc->{'sgos_sysinfo_sect'}{'Crypto Statistics'}
1020 $bc->{'sgos_sysinfo_sect'}{'DNS Cache Statistics'}
1021 $bc->{'sgos_sysinfo_sect'}{'DNS Query Statistics'}
1022 $bc->{'sgos_sysinfo_sect'}{'Disk 1'}
1023 ... and up to Disk 10, in some cases
1024 $bc->{'sgos_sysinfo_sect'}{'Endpoint Mapper Internal Statistics'}
1025 $bc->{'sgos_sysinfo_sect'}{'Endpoint Mapper Statistics'}
1026 $bc->{'sgos_sysinfo_sect'}{'Endpoint Mapper database contents'}
1027 $bc->{'sgos_sysinfo_sect'}{'FTP Statistics'}
1028 $bc->{'sgos_sysinfo_sect'}{'Forwarding Settings'}
1029 $bc->{'sgos_sysinfo_sect'}{'Forwarding Statistics Per IP'}
1030 $bc->{'sgos_sysinfo_sect'}{'Forwarding Summary Statistics'}
1031 $bc->{'sgos_sysinfo_sect'}{'Forwarding health check settings'}
1032 $bc->{'sgos_sysinfo_sect'}{'Forwarding health check statistics'}
1033 $bc->{'sgos_sysinfo_sect'}{'HTTP Configuration'}
1034 $bc->{'sgos_sysinfo_sect'}{'HTTP Main'}
1035 $bc->{'sgos_sysinfo_sect'}{'HTTP Requests'}
1036 $bc->{'sgos_sysinfo_sect'}{'HTTP Responses'}
1037 $bc->{'sgos_sysinfo_sect'}{'Hardware Information'}
1038 $bc->{'sgos_sysinfo_sect'}{'Hardware sensors'}
1039 $bc->{'sgos_sysinfo_sect'}{'Health Monitor'}
1040 $bc->{'sgos_sysinfo_sect'}{'Health check entries'}
1041 $bc->{'sgos_sysinfo_sect'}{'Health check statistics'}
1042 $bc->{'sgos_sysinfo_sect'}{'ICP Hosts'}
1043 $bc->{'sgos_sysinfo_sect'}{'ICP Settings'}
1044 $bc->{'sgos_sysinfo_sect'}{'ICP Statistics'}
1045 $bc->{'sgos_sysinfo_sect'}{'IM Configuration'}
1046 $bc->{'sgos_sysinfo_sect'}{'Kernel Statistics'}
1047 $bc->{'sgos_sysinfo_sect'}{'Licensing Statistics'}
1048 $bc->{'sgos_sysinfo_sect'}{'MAPI Client Statistics'}
1049 $bc->{'sgos_sysinfo_sect'}{'MAPI Conversation Client Errors'}
1050 $bc->{'sgos_sysinfo_sect'}{'MAPI Conversation Other Errors'}
1051 $bc->{'sgos_sysinfo_sect'}{'MAPI Conversation Server Errors'}
1052 $bc->{'sgos_sysinfo_sect'}{'MAPI Errors'}
1053 $bc->{'sgos_sysinfo_sect'}{'MAPI Internal Statistics'}
1054 $bc->{'sgos_sysinfo_sect'}{'MAPI Server Statistics'}
1055 $bc->{'sgos_sysinfo_sect'}{'MAPI Statistics'}
1056 $bc->{'sgos_sysinfo_sect'}{'MMS Configuration'}
1057 $bc->{'sgos_sysinfo_sect'}{'MMS General'}
1058 $bc->{'sgos_sysinfo_sect'}{'MMS Statistics'}
1059 $bc->{'sgos_sysinfo_sect'}{'MMS Streaming Statistics'}
1060 $bc->{'sgos_sysinfo_sect'}{'MSN IM Statistics'}
1061 $bc->{'sgos_sysinfo_sect'}{'OPP Services'}
1062 $bc->{'sgos_sysinfo_sect'}{'OPP Statistics'}
1063 $bc->{'sgos_sysinfo_sect'}{'P2P Statistics'}
1064 $bc->{'sgos_sysinfo_sect'}{'Persistent Statistics'}
1065 $bc->{'sgos_sysinfo_sect'}{'Policy Statistics'}
1066 $bc->{'sgos_sysinfo_sect'}{'Policy'}
1067 $bc->{'sgos_sysinfo_sect'}{'Priority 1 Events'}
1068 $bc->{'sgos_sysinfo_sect'}{'Quicktime Configuration'}
1069 $bc->{'sgos_sysinfo_sect'}{'Quicktime Statistics'}
1070 $bc->{'sgos_sysinfo_sect'}{'RIP Statistics'}
1071 $bc->{'sgos_sysinfo_sect'}{'Real Configuration'}
1072 $bc->{'sgos_sysinfo_sect'}{'Real Statistics'}
1073 $bc->{'sgos_sysinfo_sect'}{'Refresh Statistics'}
1074 $bc->{'sgos_sysinfo_sect'}{'SCSI Disk Statistics'}
1075 $bc->{'sgos_sysinfo_sect'}{'SOCKS Gateways Settings'}
1076 $bc->{'sgos_sysinfo_sect'}{'SOCKS Gateways Statistics'}
1077 $bc->{'sgos_sysinfo_sect'}{'SOCKS Proxy Statistics'}
1078 $bc->{'sgos_sysinfo_sect'}{'SSL Proxy Certificate Cache'}
1079 $bc->{'sgos_sysinfo_sect'}{'SSL Statistics'}
1080 $bc->{'sgos_sysinfo_sect'}{'Security processor Statistics'}
1081 $bc->{'sgos_sysinfo_sect'}{'Server Side persistent connections'}
1082 $bc->{'sgos_sysinfo_sect'}{'Services Management Statistics'}
1083 $bc->{'sgos_sysinfo_sect'}{'Services Per-service Statistics'}
1084 $bc->{'sgos_sysinfo_sect'}{'Services Proxy Statistics'}
1085 $bc->{'sgos_sysinfo_sect'}{'Software Configuration'}
1086 $bc->{'sgos_sysinfo_sect'}{'System Memory Statistics'}
1087 $bc->{'sgos_sysinfo_sect'}{'TCP/IP ARP Information'}
1088 $bc->{'sgos_sysinfo_sect'}{'TCP/IP Listening list'}
1089 $bc->{'sgos_sysinfo_sect'}{'TCP/IP Malloc Information'}
1090 $bc->{'sgos_sysinfo_sect'}{'TCP/IP Routing Table'}
1091 $bc->{'sgos_sysinfo_sect'}{'TCP/IP Statistics'}
1092 $bc->{'sgos_sysinfo_sect'}{'Threshold Monitor Statistics'}
1093 $bc->{'sgos_sysinfo_sect'}{'Version Information'}
1094 $bc->{'sgos_sysinfo_sect'}{'WCCP Configuration'}
1095 $bc->{'sgos_sysinfo_sect'}{'WCCP Statistics'}
1096 $bc->{'sgos_sysinfo_sect'}{'Yahoo IM Statistics'}
1097
1098  
1099 The details for interface 0:0 are stored here:
1100 IP address: $bc->{'interface'}{'0:0'}{'ip'}
1101 Netmask: $bc->{'interface'}{'0:0'}{'netmask'}
1102 MAC address: $bc->{'interface'}{'0:0'}{'mac'}
1103 Link status: $bc->{'interface'}{'0:0'}{'linkstatus'}
1104 Capabilities: $bc->{'interface'}{'0:0'}{'capabilities'}
1105  
1106 You can retrieve the interface names like this:
1107 my @interfaces = keys %{$bc->{'interface'}};
1108  
1109 The route table can be retrieved as follows:
1110 $bc->{'sgos_sysinfo_sect'}{'TCP/IP Routing Table'}
1111  
1112 The static route table can be retrieved as follows:
1113 $bc->{'static-route-table'}
1114  
1115 The WCCP configuration can be retrieved as follows:
1116 $bc->{'sgos_sysinfo_sect'}{'WCCP Configuration'}
1117  
1118  
1119 =cut
1120  
1121 =head1 AUTHOR
1122  
1123 Matthew Lange <mmlange@cpan.org>
1124  
1125 =head1 BUGS
1126  
1127 Please report any bugs or feature requests through
1128 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=BlueCoat-SGOS>. I will be notified, and then you'll
1129 automatically be notified of progress on your bug as I make changes.
1130  
1131  
1132  
1133  
1134 =head1 SUPPORT
1135  
1136 You can find documentation for this module with the perldoc command.
1137  
1138 perldoc BlueCoat::SGOS
1139  
1140  
1141 You can also look for information at:
1142  
1143 =over 4
1144  
1145 =item * RT: CPAN's request tracker
1146  
1147 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=BlueCoat-SGOS>
1148  
1149 =item * AnnoCPAN: Annotated CPAN documentation
1150  
1151 L<http://annocpan.org/dist/BlueCoat-SGOS>
1152  
1153 =item * CPAN Ratings
1154  
1155 L<http://cpanratings.perl.org/d/BlueCoat-SGOS>
1156  
1157 =item * Search CPAN
1158  
1159 L<http://search.cpan.org/dist/BlueCoat-SGOS/>
1160  
1161 =back
1162  
1163  
1164 =head1 LICENSE
1165  
1166 Copyright (C) 2008-2012 Matthew Lange
1167  
1168 This program is free software; you can redistribute it and/or modify it
1169 under the terms of the GNU General Public License version 2 as
1170 published by the Free Software Foundation.
1171  
1172 =cut
1173  
1174 2 1; # End of BlueCoat::SGOS
1175  
1176 __DATA__
↑ Summary