line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Siebel::Srvrmgr::Util::IniDaemon; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
135136
|
use strict; |
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
19
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
46
|
|
5
|
1
|
|
|
1
|
|
544
|
use Siebel::Srvrmgr::Daemon::Heavy; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
36
|
|
6
|
1
|
|
|
1
|
|
453
|
use Siebel::Srvrmgr::Daemon::Light; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
49
|
|
7
|
1
|
|
|
1
|
|
12
|
use Siebel::Srvrmgr::Daemon::Command; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
37
|
|
8
|
1
|
|
|
1
|
|
473
|
use Siebel::Srvrmgr::Connection; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
59
|
|
9
|
1
|
|
|
1
|
|
587
|
use Config::IniFiles 2.88; |
|
1
|
|
|
|
|
9464
|
|
|
1
|
|
|
|
|
48
|
|
10
|
1
|
|
|
1
|
|
13
|
use Exporter qw(import); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
11
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
350
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.29'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=pod |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Siebel::Srvrmgr::Util::IniDaemon - creates a Siebel::Srvrmgr::Daemon from a INI configuration file |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
By using a INI file, you can pass all necessary information to have a instance of L<Siebel::Srvrmgr::Daemon> subclasses. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Since it's common to need to fine tune parameters for them, this module will help to achieve proper configuration without touching code. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 EXPORTS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
The C<recover_info> function is the only one exported by default. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our @EXPORT_OK = qw(create_daemon); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 FUNCTIONS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 create_daemon |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Creates a instance of L<Siebel::Srvrmgr::Daemon> subclass and returns it. |
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::IniFile>. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=back |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub create_daemon { |
54
|
|
|
|
|
|
|
|
55
|
5
|
|
|
5
|
1
|
7072
|
my ($cfg_file) = @_; |
56
|
5
|
100
|
66
|
|
|
174
|
confess "$cfg_file does not exist or is not readable" |
57
|
|
|
|
|
|
|
unless ( ( -e $cfg_file ) and ( -r _ ) ); |
58
|
4
|
|
|
|
|
46
|
my $cfg = Config::IniFiles->new( -file => $cfg_file ); |
59
|
|
|
|
|
|
|
|
60
|
4
|
|
|
|
|
22734
|
my @required = |
61
|
|
|
|
|
|
|
( qw(type gateway enterprise user password srvrmgr time_zone read_timeout) |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
4
|
|
|
|
|
16
|
foreach my $param (@required) { |
65
|
26
|
100
|
|
|
|
606
|
confess "$param is missing in the $cfg_file" |
66
|
|
|
|
|
|
|
unless ( defined( $cfg->val( 'GENERAL', $param ) ) ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
3
|
|
|
|
|
71
|
my $class; |
70
|
3
|
100
|
|
|
|
10
|
if ( $cfg->val( 'GENERAL', 'type' ) eq 'heavy' ) { |
|
|
100
|
|
|
|
|
|
71
|
1
|
|
|
|
|
20
|
$class = 'Siebel::Srvrmgr::Daemon::Heavy'; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
elsif ( $cfg->val( 'GENERAL', 'type' ) eq 'light' ) { |
74
|
1
|
|
|
|
|
68
|
$class = 'Siebel::Srvrmgr::Daemon::Light'; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
else { |
77
|
1
|
|
|
|
|
72
|
confess 'Invalid value "' |
78
|
|
|
|
|
|
|
. $cfg->val( 'GENERAL', 'type' ) |
79
|
|
|
|
|
|
|
. '" for daemon type'; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
2
|
|
|
|
|
11
|
my $params = { |
83
|
|
|
|
|
|
|
connection => Siebel::Srvrmgr::Connection->new( |
84
|
|
|
|
|
|
|
{ |
85
|
|
|
|
|
|
|
gateway => $cfg->val( 'GENERAL', 'gateway' ), |
86
|
|
|
|
|
|
|
enterprise => $cfg->val( 'GENERAL', 'enterprise' ), |
87
|
|
|
|
|
|
|
user => $cfg->val( 'GENERAL', 'user' ), |
88
|
|
|
|
|
|
|
password => $cfg->val( 'GENERAL', 'password' ), |
89
|
|
|
|
|
|
|
bin => $cfg->val( 'GENERAL', 'srvrmgr' ) |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
), |
92
|
|
|
|
|
|
|
time_zone => $cfg->val( 'GENERAL', 'time_zone' ), |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# optional |
96
|
2
|
|
|
|
|
54
|
foreach my $attr (qw(field_delimiter read_timeout)) { |
97
|
4
|
50
|
|
|
|
43
|
if ( $cfg->exists( 'GENERAL', $attr ) ) { |
98
|
4
|
|
|
|
|
55
|
$params->{$attr} = $cfg->val( 'GENERAL', $attr ); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
2
|
50
|
33
|
|
|
39
|
if ( ( $cfg->exists( 'GENERAL', 'load_prefs' ) ) |
103
|
|
|
|
|
|
|
and ( $cfg->val( 'GENERAL', 'load_prefs' ) ) ) |
104
|
|
|
|
|
|
|
{ |
105
|
|
|
|
|
|
|
$params->{commands} = [ |
106
|
2
|
|
|
|
|
129
|
Siebel::Srvrmgr::Daemon::Command->new( |
107
|
|
|
|
|
|
|
{ |
108
|
|
|
|
|
|
|
command => 'load preferences', |
109
|
|
|
|
|
|
|
action => 'LoadPreferences', |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
) |
112
|
|
|
|
|
|
|
]; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
2
|
|
|
|
|
65
|
return $class->new($params); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 CONFIGURATION FILE |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
The configuration file must have a INI format, which is supported by the L<Config::IniFile> module. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Here is an example of the required parameters with a description: |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
[GENERAL] |
126
|
|
|
|
|
|
|
# the Siebel Gateway hostname and port, for example |
127
|
|
|
|
|
|
|
gateway=foobar:1055 |
128
|
|
|
|
|
|
|
# the Siebel Enterprise name |
129
|
|
|
|
|
|
|
enterprise=MyEnterprise |
130
|
|
|
|
|
|
|
# the Siebel user with administrative privileges |
131
|
|
|
|
|
|
|
user=sadmin |
132
|
|
|
|
|
|
|
# the password from the user with administrative privileges |
133
|
|
|
|
|
|
|
password=123456 |
134
|
|
|
|
|
|
|
# the field delimiter used to separate the output fields of srvrmgr |
135
|
|
|
|
|
|
|
field_delimiter=| |
136
|
|
|
|
|
|
|
# the complete pathname to the program srvrmgr |
137
|
|
|
|
|
|
|
srvrmgr= /foobar/bin/srvrmgr |
138
|
|
|
|
|
|
|
# if true, will add a "load preferences" command with "LoadPreferences" action automatically |
139
|
|
|
|
|
|
|
load_prefs = 1 |
140
|
|
|
|
|
|
|
# type defines which subclass of Siebel::Srvrmgr::Daemon to use. The acceptable value is "heavy" |
141
|
|
|
|
|
|
|
# for Siebel::Srvrmgr::Daemon::Heavy and "light" for Siebel::Srvrmgr::Daemon::Light |
142
|
|
|
|
|
|
|
type = heavy |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Whatever other parameters or sections available on the same INI will be ignored by this class, but you can subclass it and use |
145
|
|
|
|
|
|
|
any other parameters/section you may want to. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Please refer to the Pod of L<Siebel::Srvrmgr::Daemon> and corresponding subclasses to understand what parameters are optional or not. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 SEE ALSO |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=over |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L<Siebel::Srvrmgr> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L<Config::IniFile> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=back |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 AUTHOR |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This software is copyright (c) 2015 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This file is part of Siebel Monitoring Tools. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Siebel Monitoring Tools is free software: you can redistribute it and/or modify |
174
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
175
|
|
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or |
176
|
|
|
|
|
|
|
(at your option) any later version. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Siebel Monitoring Tools is distributed in the hope that it will be useful, |
179
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
180
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
181
|
|
|
|
|
|
|
GNU General Public License for more details. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
184
|
|
|
|
|
|
|
along with Siebel Monitoring Tools. If not, see <http://www.gnu.org/licenses/>. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=cut |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
1; |