line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Siebel::Lbconfig; |
2
|
1
|
|
|
1
|
|
62936
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
3
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
46
|
|
4
|
1
|
|
|
1
|
|
354
|
use Siebel::Srvrmgr::Daemon::Light 0.27; |
|
1
|
|
|
|
|
1387949
|
|
|
1
|
|
|
|
|
49
|
|
5
|
1
|
|
|
1
|
|
8
|
use Siebel::Srvrmgr::Daemon::Command 0.27; |
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
31
|
|
6
|
1
|
|
|
1
|
|
457
|
use Set::Tiny 0.03; |
|
1
|
|
|
|
|
1027
|
|
|
1
|
|
|
|
|
61
|
|
7
|
1
|
|
|
1
|
|
296
|
use Siebel::Srvrmgr::Util::IniDaemon 0.27 qw(create_daemon); |
|
1
|
|
|
|
|
370656
|
|
|
1
|
|
|
|
|
54
|
|
8
|
1
|
|
|
1
|
|
10
|
use Config::IniFiles 2.88; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
18
|
|
9
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
39
|
|
10
|
1
|
|
|
1
|
|
5
|
use Exporter 'import'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
11
|
1
|
|
|
1
|
|
8
|
use File::Spec; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
12
|
1
|
|
|
1
|
|
5
|
use Cwd; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
49
|
|
13
|
1
|
|
|
1
|
|
472
|
use Siebel::Lbconfig::Daemon::Action::ListServers; |
|
1
|
|
|
|
|
352
|
|
|
1
|
|
|
|
|
39
|
|
14
|
1
|
|
|
1
|
|
402
|
use Siebel::Lbconfig::Daemon::Action::AOM; |
|
1
|
|
|
|
|
573
|
|
|
1
|
|
|
|
|
704
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.003'; # VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=pod |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Siebel::Lbconfig - helper to generate an optimized F<lbconfig.txt> file |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
The distribution Siebel-Lbconfig was created based on classes from L<Siebel::Srvrmgr>. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
The command line utility C<lbconfig> will connect to a Siebel Enterprise with C<srvrmgr> and generate a optimized |
29
|
|
|
|
|
|
|
F<lbconfig.txt> file by search all active AOMs that take can take advantage of the native load balancer. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our @EXPORT_OK = qw(recover_info get_daemon create_files); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 FUNCTIONS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 create_daemon |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Creates a L<Siebel::Srvrmgr::Daemon> to connects to the Siebel Enterprise and retrieve the required information to create the F<lbconfig.txt>. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
It expects as parameters: |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=over |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item * |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
A string of the complete path to a configuration file that is understandle by L<Config::Tiny> (a INI file). |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=back |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Check the section "Configuration file" of this Pod for details about how to create and maintain the INI file. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Return two values: |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=over |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item * |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
The daemon instance |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item * |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
A L<Siebel::Srvrmgr::Daemon::ActionStash> instance. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=back |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 get_daemon |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Expects the path to a INI file as parameter. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Returns an instance of L<Siebel::Srvrmgr::Daemon> subclass configured in the INI file. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub get_daemon { |
76
|
0
|
|
|
0
|
1
|
0
|
my $cfg_file = shift; |
77
|
0
|
|
|
|
|
0
|
my $daemon = create_daemon($cfg_file); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# LoadPreferences does not add anything into ActionStash, so it's ok use a second action here |
80
|
0
|
|
|
|
|
0
|
$daemon->push_command( |
81
|
|
|
|
|
|
|
Siebel::Srvrmgr::Daemon::Command->new( |
82
|
|
|
|
|
|
|
{ |
83
|
|
|
|
|
|
|
command => 'list comp', |
84
|
|
|
|
|
|
|
action => 'Siebel::Lbconfig::Daemon::Action::AOM' |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
) |
87
|
|
|
|
|
|
|
); |
88
|
0
|
|
|
|
|
0
|
$daemon->push_command( |
89
|
|
|
|
|
|
|
Siebel::Srvrmgr::Daemon::Command->new( |
90
|
|
|
|
|
|
|
{ |
91
|
|
|
|
|
|
|
command => 'list servers', |
92
|
|
|
|
|
|
|
action => 'Siebel::Lbconfig::Daemon::Action::ListServers' |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
) |
95
|
|
|
|
|
|
|
); |
96
|
0
|
|
|
|
|
0
|
my $stash = Siebel::Srvrmgr::Daemon::ActionStash->instance(); |
97
|
0
|
|
|
|
|
0
|
return $daemon, $stash; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 recover_info |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Expects as parameter the L<Siebel::Srvrmgr::Daemon::ActionStash> instance returned by C<create_daemon> and |
103
|
|
|
|
|
|
|
the Siebel Connection Broker TCP port. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Returns a hash array reference with all the rows data of the F<lbconfig.txt>. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub recover_info { |
110
|
1
|
|
|
1
|
1
|
3231
|
my ( $stash, $scb_port ) = @_; |
111
|
1
|
|
|
|
|
4
|
my @data; |
112
|
1
|
|
|
|
|
7
|
my $comps_ref = $stash->shift_stash(); |
113
|
1
|
|
|
|
|
103
|
my $servers_ref = $stash->shift_stash(); |
114
|
1
|
|
|
|
|
89
|
my $underscore = qr/_/; |
115
|
1
|
|
|
|
|
4
|
my @sorted = sort( keys( %{$comps_ref} ) ); |
|
1
|
|
|
|
|
24
|
|
116
|
|
|
|
|
|
|
|
117
|
1
|
|
|
|
|
6
|
foreach my $comp_alias (@sorted) { |
118
|
29
|
|
|
|
|
61
|
my $virtual; |
119
|
|
|
|
|
|
|
|
120
|
29
|
50
|
|
|
|
132
|
if ( $comp_alias =~ $underscore ) { |
121
|
29
|
|
|
|
|
99
|
my @parts = split( '_', $comp_alias ); |
122
|
29
|
|
|
|
|
105
|
$parts[0] =~ s/ObjMgr//; |
123
|
29
|
|
|
|
|
108
|
$virtual = $parts[0] . uc( $parts[1] ) . '_VS'; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
else { |
126
|
0
|
|
|
|
|
0
|
$virtual = $comp_alias . '_VS'; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
29
|
|
|
|
|
58
|
my @row; |
130
|
|
|
|
|
|
|
|
131
|
29
|
|
|
|
|
56
|
foreach my $server ( @{ $comps_ref->{$comp_alias} } ) { |
|
29
|
|
|
|
|
72
|
|
132
|
|
|
|
|
|
|
|
133
|
75
|
50
|
|
|
|
203
|
if ( exists( $servers_ref->{$server} ) ) { |
134
|
|
|
|
|
|
|
push( |
135
|
|
|
|
|
|
|
@row, |
136
|
|
|
|
|
|
|
( |
137
|
75
|
|
|
|
|
277
|
$servers_ref->{$server} . ':' |
138
|
|
|
|
|
|
|
. $server . ':' |
139
|
|
|
|
|
|
|
. $scb_port |
140
|
|
|
|
|
|
|
) |
141
|
|
|
|
|
|
|
); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
else { |
144
|
0
|
|
|
|
|
0
|
confess |
145
|
|
|
|
|
|
|
"'$server' is not part of the retrieved Sievel Server names!"; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
push( |
150
|
29
|
|
|
|
|
179
|
@data, |
151
|
|
|
|
|
|
|
{ |
152
|
|
|
|
|
|
|
comp_alias => $comp_alias, |
153
|
|
|
|
|
|
|
vs => $virtual, |
154
|
|
|
|
|
|
|
servers => ( join( ';', @row ) . ';' ) |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
1
|
|
|
|
|
19
|
return \@data; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 create_files |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Creates the F<lbconfig.txt> and F<eapps*.cfg> files. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Expects as parameters the directory where the F<eapps*.cfg> file will be located. Those files will be used as templates, they will be copied to a new version of them, |
167
|
|
|
|
|
|
|
with the C<ConnectionString> modified and all other content as is. The copied will have the C<.new> file "extension" attached to them. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Also, espects a data reference passed as the second parameter. The expected format is the same returned by the C<recover_info> sub. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Returns nothing. The F<lbconfig.txt> file will be located at the current directory. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub create_files { |
176
|
1
|
|
|
1
|
1
|
9105
|
my ( $dir, $data_ref ) = @_; |
177
|
1
|
|
|
|
|
29
|
my $lbconfig = File::Spec->catfile( getcwd(), 'lbconfig.txt' ); |
178
|
1
|
50
|
|
|
|
100
|
open( my $out, '>', $lbconfig ) or confess "Cannot create $lbconfig: $!"; |
179
|
1
|
|
|
|
|
5
|
my %aliases; |
180
|
|
|
|
|
|
|
|
181
|
1
|
|
|
|
|
3
|
foreach my $row ( @{$data_ref} ) { |
|
1
|
|
|
|
|
5
|
|
182
|
29
|
|
|
|
|
91
|
print $out $row->{vs}, '=', $row->{servers}, "\n"; |
183
|
29
|
|
|
|
|
91
|
$aliases{ $row->{comp_alias} } = $row->{vs}; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
1
|
|
|
|
|
40
|
close($out); |
187
|
|
|
|
|
|
|
|
188
|
1
|
|
|
|
|
18
|
my $pattern = File::Spec->catfile( $dir, 'eapps*.cfg' ); |
189
|
1
|
|
|
|
|
84
|
my @eapps = glob($pattern); |
190
|
1
|
|
|
|
|
11
|
my $conn_regex = qr#^ConnectString#; |
191
|
1
|
|
|
|
|
7
|
my $replace_regex = |
192
|
|
|
|
|
|
|
qr#^(ConnectString\s?\=\s?siebel\.TCPIP\.\w+\.\w+\://)\w+(/\w+/)(\w+)#; |
193
|
1
|
|
|
|
|
5
|
foreach my $file (@eapps) { |
194
|
2
|
|
|
|
|
12
|
my $new = "$file.new"; |
195
|
2
|
50
|
|
|
|
76
|
open( my $old, '<', $file ) or confess "Cannot read $file: $!"; |
196
|
2
|
50
|
|
|
|
123
|
open( my $out, '>', $new ) or confess "Cannot create $new: $!"; |
197
|
|
|
|
|
|
|
|
198
|
2
|
|
|
|
|
43
|
while (<$old>) { |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
#ConnectString = siebel.TCPIP.None.None://VirtualServer/foobar/ERMObjMgr_chs |
201
|
15897
|
100
|
|
|
|
42812
|
if ( $_ =~ $conn_regex ) { |
202
|
2302
|
|
|
|
|
4345
|
chomp(); |
203
|
|
|
|
|
|
|
|
204
|
2302
|
50
|
|
|
|
10053
|
if ( $_ =~ $replace_regex ) { |
205
|
|
|
|
|
|
|
|
206
|
2302
|
100
|
|
|
|
5916
|
if ( exists( $aliases{$3} ) ) { |
207
|
29
|
|
|
|
|
234
|
print $out $1, $aliases{$3}, $2, $3, "\n"; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
else { |
210
|
2273
|
|
|
|
|
8405
|
print $out $_, "\n"; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
else { |
215
|
0
|
|
|
|
|
0
|
print $out $_, "\n"; |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
else { |
220
|
13595
|
|
|
|
|
32724
|
print $out $_; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
2
|
|
|
|
|
20
|
close($old); |
226
|
2
|
|
|
|
|
89
|
close($out); |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head1 CONFIGURATION FILE |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
The configuration file must have a INI format, which is supported by the L<Config::Tiny> module. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
Here is an example of the required parameters: |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
[GENERAL] |
238
|
|
|
|
|
|
|
gateway=foobar:1055 |
239
|
|
|
|
|
|
|
enterprise=MyEnterprise |
240
|
|
|
|
|
|
|
user=sadmin |
241
|
|
|
|
|
|
|
password=123456 |
242
|
|
|
|
|
|
|
srvrmgr= /foobar/bin/srvrmgr |
243
|
|
|
|
|
|
|
load_prefs = 1 |
244
|
|
|
|
|
|
|
type = light |
245
|
|
|
|
|
|
|
time_zone = America/Sao_Paulo |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
Beware that the commands executed by C<lbconfig> requires that the output has a specific configuration set: setting |
248
|
|
|
|
|
|
|
C<load_prefs> is not optional here, but a requirement! |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
Also make sure to use C<type = light> because this distribution really doesn't need L<Siebel::Srvrmgr::Daemon::Heavy> and is |
251
|
|
|
|
|
|
|
intended to work on MS Windows too. |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=head1 SEE ALSO |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=over |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=item * |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
L<Siebel::Srvrmgr> |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=item * |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
L<Config::Tiny> |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=item * |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
L<Siebel::Srvrmgr::Util::IniDaemon> |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=back |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=head1 AUTHOR |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt> |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
This software is copyright (c) 2016 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt> |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
This file is part of Siebel Monitoring Tools. |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
Siebel Monitoring Tools is free software: you can redistribute it and/or modify |
282
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
283
|
|
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or |
284
|
|
|
|
|
|
|
(at your option) any later version. |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Siebel Monitoring Tools is distributed in the hope that it will be useful, |
287
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
288
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
289
|
|
|
|
|
|
|
GNU General Public License for more details. |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
292
|
|
|
|
|
|
|
along with Siebel Monitoring Tools. If not, see <http://www.gnu.org/licenses/>. |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=cut |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
1; |