| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Siebel::Srvrmgr::Daemon; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Siebel::Srvrmgr::Daemon - super class for sessions with Siebel srvrmgr program |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package MyDaemon; |
|
12
|
|
|
|
|
|
|
extends 'Siebel::Srvrmgr::Daemon'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This is a super class, and alone it does not provide any functionaly to use srvrmgr to send commands and process returned data. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
The "private" method C<_setup_commands> must be overrided by subclasses of it or commands will not be sent to C<srvrmgr>. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Logging of this class can be enabled by using L<Siebel::Srvrmgr> logging feature. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
The logic behind this class is easy: you can submit a pair of command/action to the class. It will then connect to the server by executing C<srvrmgr>, submit the command |
|
23
|
|
|
|
|
|
|
to the server and recover the output generated. The action will be executed having this output as parameter. Anything could be considered as an action, from simple |
|
24
|
|
|
|
|
|
|
storing the output to even generating new commands to be executed in the server. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
A command is an instance of L<Siebel::Srvrmgr::Daemon::Command> class. Any "list" command is supported, and also C<load preferences> and C<exit>. Anything else |
|
27
|
|
|
|
|
|
|
is considered dangerous and will generated an exception. Beware that you will need to have an L<Siebel::Srvrmgr::ListParser::Output> class available to be |
|
28
|
|
|
|
|
|
|
able to parse the command output. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
An action can be any class but is obligatory to create a subclass of L<Siebel::Srvrmgr::Daemon::Action> base class. See the <commands> |
|
31
|
|
|
|
|
|
|
attribute for details. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Implementation details are reserved to subclasses of Siebel::Srvrmgr::Daemon: be sure to check them for real usage cenarios. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
5
|
|
|
5
|
|
544808
|
use Moose 2.0401; |
|
|
5
|
|
|
|
|
733461
|
|
|
|
5
|
|
|
|
|
49
|
|
|
38
|
5
|
|
|
5
|
|
42989
|
use Siebel::Srvrmgr::Regexes qw(SIEBEL_ERROR); |
|
|
5
|
|
|
|
|
15
|
|
|
|
5
|
|
|
|
|
344
|
|
|
39
|
5
|
|
|
5
|
|
2079
|
use Siebel::Srvrmgr::ListParser; |
|
|
5
|
|
|
|
|
30
|
|
|
|
5
|
|
|
|
|
258
|
|
|
40
|
5
|
|
|
5
|
|
72
|
use Siebel::Srvrmgr; |
|
|
5
|
|
|
|
|
14
|
|
|
|
5
|
|
|
|
|
177
|
|
|
41
|
5
|
|
|
5
|
|
36
|
use Scalar::Util qw(weaken blessed); |
|
|
5
|
|
|
|
|
15
|
|
|
|
5
|
|
|
|
|
457
|
|
|
42
|
5
|
|
|
5
|
|
40
|
use Siebel::Srvrmgr::Types; |
|
|
5
|
|
|
|
|
18
|
|
|
|
5
|
|
|
|
|
164
|
|
|
43
|
5
|
|
|
5
|
|
45
|
use Fcntl ':flock'; # import LOCK_* constants |
|
|
5
|
|
|
|
|
17
|
|
|
|
5
|
|
|
|
|
777
|
|
|
44
|
5
|
|
|
5
|
|
42
|
use Config; |
|
|
5
|
|
|
|
|
13
|
|
|
|
5
|
|
|
|
|
236
|
|
|
45
|
5
|
|
|
5
|
|
35
|
use Carp; |
|
|
5
|
|
|
|
|
14
|
|
|
|
5
|
|
|
|
|
319
|
|
|
46
|
5
|
|
|
5
|
|
38
|
use File::Spec; |
|
|
5
|
|
|
|
|
14
|
|
|
|
5
|
|
|
|
|
147
|
|
|
47
|
5
|
|
|
5
|
|
97
|
use Data::Dumper; |
|
|
5
|
|
|
|
|
18
|
|
|
|
5
|
|
|
|
|
14379
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
our $VERSION = '0.29'; # VERSION |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $SIG_INT = 0; |
|
52
|
|
|
|
|
|
|
my $SIG_PIPE = 0; |
|
53
|
|
|
|
|
|
|
my $SIG_ALARM = 0; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# :TODO :19/08/2013 16:19:19:: enable Taint Mode |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=pod |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 commands |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
An array reference containing one or more references of L<Siebel::Srvrmgr::Daemon::Commands> class. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
The commands will be executed in the exactly order as given by the indexes in the array reference (as FIFO). |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This is a required attribute during object creation with the C<new> method. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
has commands => ( |
|
72
|
|
|
|
|
|
|
isa => 'ArrayRef[Siebel::Srvrmgr::Daemon::Command]', |
|
73
|
|
|
|
|
|
|
is => 'rw', |
|
74
|
|
|
|
|
|
|
required => 1, |
|
75
|
|
|
|
|
|
|
reader => 'get_commands', |
|
76
|
|
|
|
|
|
|
writer => 'set_commands', |
|
77
|
|
|
|
|
|
|
trigger => sub { my $self = shift; $self->_setup_commands() } |
|
78
|
|
|
|
|
|
|
); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=pod |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 time_zone |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Required attribute. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
A string representing the time zone to be considered for all date/time values recovered from C<srvrmgr>. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
See L<DateTime::TimeZone> C<all_names> methods to list the available time zones that you can use. The on-liner |
|
89
|
|
|
|
|
|
|
below will show you them so you can find a proper value: |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
perl -MDateTime::TimeZone -e 'foreach ( DateTime::TimeZone->all_names ) { print "$_\n" }' |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
has time_zone => |
|
96
|
|
|
|
|
|
|
( isa => 'Str', is => 'ro', required => 1, reader => 'get_time_zone' ); |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=pod |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 alarm_timeout |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
An integer value that will raise an ALARM signal generated by C<alarm>. The default value is 30 seconds. This is avoid leaving |
|
103
|
|
|
|
|
|
|
the daemon blocking forever waiting for something to read. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This attribute will be reset every time a read can be done from the STDOUT or STDERR from srvrmgr. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
has alarm_timeout => ( |
|
110
|
|
|
|
|
|
|
is => 'Int', |
|
111
|
|
|
|
|
|
|
is => 'rw', |
|
112
|
|
|
|
|
|
|
writer => 'set_alarm', |
|
113
|
|
|
|
|
|
|
reader => 'get_alarm', |
|
114
|
|
|
|
|
|
|
default => 30 |
|
115
|
|
|
|
|
|
|
); |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=pod |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 use_perl |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
A boolean attribute used mostly for testing of this class. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
If true, if will prepend the complete path of the Perl interpreter to the parameters before calling the C<srvrmgr> program (of course the "srvrmgr" must |
|
124
|
|
|
|
|
|
|
be itself a Perl script). |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
It defaults to false. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
has use_perl => |
|
131
|
|
|
|
|
|
|
( isa => 'Bool', is => 'ro', reader => 'use_perl', default => 0 ); |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 child_runs |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
An integer representing the number of times the child object was used in C<run> invocations. This is reset to zero if a new child process is created. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
has child_runs => ( |
|
140
|
|
|
|
|
|
|
isa => 'Int', |
|
141
|
|
|
|
|
|
|
is => 'ro', |
|
142
|
|
|
|
|
|
|
reader => 'get_child_runs', |
|
143
|
|
|
|
|
|
|
writer => '_set_child_runs', |
|
144
|
|
|
|
|
|
|
default => 0 |
|
145
|
|
|
|
|
|
|
); |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 clear_raw |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
A boolean attribute that defines if the raw data recovered from C<srvrmgr> should be kept or discarded as soon as possibly. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Having a default value of true, it should help reducing memory usage or debugging, if set false. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
has clear_raw => ( |
|
156
|
|
|
|
|
|
|
is => 'rw', |
|
157
|
|
|
|
|
|
|
isa => 'Bool', |
|
158
|
|
|
|
|
|
|
reader => 'clear_raw', |
|
159
|
|
|
|
|
|
|
writer => 'set_clear_raw', |
|
160
|
|
|
|
|
|
|
default => 1 |
|
161
|
|
|
|
|
|
|
); |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 has_lock |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Optional parameter. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This is a boolean attribute (in the sense of Perl) that identifies if the L<Daemon> needs to use a lock or not. Default is false. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Using a lock is useful to avoid two instances of the same C<Daemon> running. See also C<lock_dir> attribute. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
has has_lock => ( is => 'ro', isa => 'Bool', default => 0 ); |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 lock_dir |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Optional parameter. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
This parameter is used to determine the location in the filesystem to create the lock file. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Expects a string as parameter. The directory must be readable and writable to the user running the C<Daemon>. |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
It defaults to the "home" directory of the user. The sense of "home" is the following as defined by the platform: |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
This attribute is lazy and defined by the C<_define_lock_dir> "private" method. |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=over |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item * |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Microsoft Windows: C<$ENV{HOMEDIR}> |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item * |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
UNIX-like: C<$ENV{HOME}> |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=back |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=cut |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
has lock_dir => ( |
|
202
|
|
|
|
|
|
|
is => 'rw', |
|
203
|
|
|
|
|
|
|
isa => 'Str', |
|
204
|
|
|
|
|
|
|
reader => 'get_lock_dir', |
|
205
|
|
|
|
|
|
|
writer => 'set_lock_dir', |
|
206
|
|
|
|
|
|
|
lazy => 1, |
|
207
|
|
|
|
|
|
|
builder => '_define_lock_dir' |
|
208
|
|
|
|
|
|
|
); |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=pod |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head2 cmd_stack |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
This is an array reference with the stack of commands to be executed. It is maintained automatically by the class, so the attribute is read-only. |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=cut |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
has cmd_stack => ( |
|
219
|
|
|
|
|
|
|
isa => 'ArrayRef', |
|
220
|
|
|
|
|
|
|
is => 'ro', |
|
221
|
|
|
|
|
|
|
writer => '_set_cmd_stack', |
|
222
|
|
|
|
|
|
|
reader => 'get_cmd_stack' |
|
223
|
|
|
|
|
|
|
); |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=pod |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 METHODS |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head2 get_time_zone |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Returns the content of the attribute C<time_zone>. |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head2 get_cmd_stack |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
Returns the content of the attribute C<cmd_stack>. |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head2 clear_raw |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
Getter for the C<clear_raw> attribute. |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head2 set_clear_raw |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Setter for the C<clear_raw> attribute. |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head2 get_alarm |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
Returns the content of the C<alarm_timeout> attribute. |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head2 set_alarm |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
Sets the attribute C<alarm_timeout>. Expects an integer as parameter, in seconds. |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=head2 get_child_runs |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
Returns the value of the attribute C<child_runs>. |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head2 use_perl |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
Returns the content of the attribute C<use_perl>. |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head2 get_buffer_size |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Returns the value of the attribute C<ipc_buffer_size>. |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head2 set_buffer_size |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
Sets the attribute C<ipc_buffer_size>. Expects an integer as parameter, multiple of 1024. |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head2 get_commands |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
Returns the content of the attribute C<commands>. |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head2 set_commands |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
Set the content of the attribute C<commands>. Expects an array reference as parameter. |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=head2 get_pid |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
Returns the content of C<pid> attribute as an integer. |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=head2 BUILD |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
L<Moose> BUILD method is used by this class to install signal handlers for the following signals: |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=over |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=item * |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
INT |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=item * |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
PIPE |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=item * |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
ALRM |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=back |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
Also the method sets the environment variable C<SIEBEL_TZ> if a time zone was set. |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
If the logging is set to C<DEBUG> level all attribute values will be logged. |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=cut |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
sub BUILD { |
|
308
|
6
|
|
|
6
|
1
|
21
|
my $self = shift; |
|
309
|
6
|
|
|
0
|
|
125
|
$SIG{INT} = sub { $SIG_INT = 1 }; |
|
|
0
|
|
|
|
|
0
|
|
|
310
|
6
|
|
|
0
|
|
69
|
$SIG{PIPE} = sub { $SIG_PIPE = 1 }; |
|
|
0
|
|
|
|
|
0
|
|
|
311
|
6
|
|
|
0
|
|
60
|
$SIG{ALRM} = sub { $SIG_ALARM = 1 }; |
|
|
0
|
|
|
|
|
0
|
|
|
312
|
6
|
|
|
|
|
298
|
$ENV{SIEBEL_TZ} = $self->get_time_zone(); |
|
313
|
|
|
|
|
|
|
|
|
314
|
6
|
|
|
|
|
94
|
my $logger = Siebel::Srvrmgr->gimme_logger( blessed($self) ); |
|
315
|
|
|
|
|
|
|
|
|
316
|
6
|
50
|
|
|
|
3335
|
if ( $logger->is_debug() ) { |
|
317
|
0
|
|
|
|
|
0
|
$logger->debug('This instance attributes values:'); |
|
318
|
|
|
|
|
|
|
|
|
319
|
0
|
|
|
|
|
0
|
foreach my $attrib ( $self->meta->get_all_attributes() ) { |
|
320
|
0
|
|
|
|
|
0
|
my $getter = $attrib->get_read_method(); |
|
321
|
0
|
|
|
|
|
0
|
my $value = $self->$getter; |
|
322
|
0
|
0
|
|
|
|
0
|
$value = 'UNDEFINED' unless ( defined($value) ); |
|
323
|
|
|
|
|
|
|
|
|
324
|
0
|
0
|
|
|
|
0
|
if ( ref($value) ne '' ) { |
|
325
|
0
|
|
|
|
|
0
|
$logger->debug( |
|
326
|
|
|
|
|
|
|
'attribute ' . $attrib->name() . ' = ' . Dumper($value) ); |
|
327
|
|
|
|
|
|
|
} |
|
328
|
|
|
|
|
|
|
else { |
|
329
|
0
|
|
|
|
|
0
|
$logger->debug( |
|
330
|
|
|
|
|
|
|
'attribute ' . $attrib->name() . ' = ' . $value ); |
|
331
|
|
|
|
|
|
|
} |
|
332
|
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
} |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
} |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
} |
|
338
|
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=head2 cmds_vs_tree |
|
340
|
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
This method compares the number of C<commands> defined in a instance of this class with the number of nodes passed as parameter. |
|
342
|
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
If their are equal, the number is returned. If their are different (and there is a problem with the parsed output of srvrmgr) this method |
|
344
|
|
|
|
|
|
|
returns C<undef>. |
|
345
|
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
=cut |
|
347
|
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
sub cmds_vs_tree { |
|
349
|
4
|
|
|
4
|
1
|
18
|
my ( $self, $nodes_num ) = @_; |
|
350
|
4
|
|
|
|
|
9
|
my $cmds_num = scalar( @{ $self->get_commands() } ); |
|
|
4
|
|
|
|
|
158
|
|
|
351
|
|
|
|
|
|
|
|
|
352
|
4
|
50
|
|
|
|
16
|
if ( $cmds_num == $nodes_num ) { |
|
353
|
4
|
|
|
|
|
17
|
return $nodes_num; |
|
354
|
|
|
|
|
|
|
} |
|
355
|
|
|
|
|
|
|
else { |
|
356
|
0
|
|
|
|
|
0
|
return; |
|
357
|
|
|
|
|
|
|
} |
|
358
|
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
} |
|
360
|
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
=head2 check_cmd |
|
362
|
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
This methods expects as parameter a string representing a C<srvrmgr> command. |
|
364
|
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
The command will be checked and if considered insecure, an exception will be raised. |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
Commands considered secure are: |
|
368
|
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
=over |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
=item * |
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
load preferences |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
=item * |
|
376
|
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
list <anything> |
|
378
|
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
=item * |
|
380
|
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
exit |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
=item * |
|
384
|
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
set delimiter |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
=back |
|
388
|
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
This method is also used internally through the C<_setup_commands> method. |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
=cut |
|
392
|
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
sub check_cmd { |
|
394
|
71
|
|
|
71
|
1
|
10320418
|
my ( $self, $cmd ) = @_; |
|
395
|
71
|
50
|
|
|
|
205
|
confess( 'Invalid command received for execution: ' |
|
396
|
|
|
|
|
|
|
. Dumper( $self->get_cmd_stack() ) ) |
|
397
|
|
|
|
|
|
|
unless ( defined($cmd) ); |
|
398
|
71
|
50
|
100
|
|
|
698
|
confess("Insecure command from command stack [$cmd]. Execution aborted") |
|
|
|
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
399
|
|
|
|
|
|
|
unless ( ( $cmd =~ /^load/ ) |
|
400
|
|
|
|
|
|
|
or ( $cmd =~ /^list/ ) |
|
401
|
|
|
|
|
|
|
or ( $cmd =~ /^set\sdelimiter\s[[:graph:]]/ ) |
|
402
|
|
|
|
|
|
|
or ( $cmd =~ /^exit/ ) ); |
|
403
|
61
|
|
|
|
|
244
|
return 1; |
|
404
|
|
|
|
|
|
|
} |
|
405
|
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
=pod |
|
407
|
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
=head2 shift_command |
|
409
|
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
Does a C<shift> in the C<commands> attribute. |
|
411
|
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
Does not expects any parameter. Returns the C<shift>ed L<Siebel::Srvrmgr::Daemon::Command> instance or C<undef> if there is only B<one> |
|
413
|
|
|
|
|
|
|
command left (which is not C<shift>ed). |
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
This method is useful specially if the Daemon will keep executing commands, but setup commands (like C<load preferences>) are not necessary to be executed |
|
416
|
|
|
|
|
|
|
again. |
|
417
|
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
=cut |
|
419
|
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
sub shift_command { |
|
421
|
8
|
|
|
8
|
1
|
26
|
my $self = shift; |
|
422
|
8
|
|
|
|
|
303
|
my $cmds_ref = $self->get_commands(); |
|
423
|
|
|
|
|
|
|
|
|
424
|
8
|
100
|
|
|
|
15
|
if ( scalar( @{$cmds_ref} ) > 1 ) { |
|
|
8
|
|
|
|
|
28
|
|
|
425
|
6
|
|
|
|
|
11
|
my $shifted = shift( @{$cmds_ref} ); |
|
|
6
|
|
|
|
|
18
|
|
|
426
|
6
|
|
|
|
|
192
|
$self->set_commands($cmds_ref); # must trigger the attribute |
|
427
|
6
|
|
|
|
|
36
|
return $shifted; |
|
428
|
|
|
|
|
|
|
} |
|
429
|
|
|
|
|
|
|
else { |
|
430
|
2
|
|
|
|
|
92
|
$self->set_commands( [] ); # must trigger the attribute |
|
431
|
2
|
|
|
|
|
14
|
return; |
|
432
|
|
|
|
|
|
|
} |
|
433
|
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
} |
|
435
|
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
=pod |
|
437
|
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
=head2 push_command |
|
439
|
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
Does a C<push> in the C<commands> attribute. |
|
441
|
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
Expects as parameter a L<Siebel::Srvrmgr::Daemon::Command> instance. |
|
443
|
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
=cut |
|
445
|
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
sub push_command { |
|
447
|
8
|
|
|
8
|
1
|
24
|
my ( $self, $command ) = @_; |
|
448
|
8
|
50
|
|
|
|
41
|
confess 'must received a Siebel::Srvrmgr::Daemon::Command as parameter' |
|
449
|
|
|
|
|
|
|
unless ( blessed($command) eq 'Siebel::Srvrmgr::Daemon::Command' ); |
|
450
|
8
|
|
|
|
|
314
|
my $cmds_ref = $self->get_commands(); |
|
451
|
8
|
|
|
|
|
19
|
push( @{$cmds_ref}, $command ); |
|
|
8
|
|
|
|
|
18
|
|
|
452
|
8
|
|
|
|
|
270
|
$self->set_commands($cmds_ref); # must trigger the attribute |
|
453
|
|
|
|
|
|
|
} |
|
454
|
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
=pod |
|
456
|
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
=head2 run |
|
458
|
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
This is the method used to execute commands in srvrmgr program and must be overrided by subclasses of Siebel::Srvrmgr::Daemon. |
|
460
|
|
|
|
|
|
|
Subclasses should invoke L<Moose> C<super> to when doing override because this implementation will apply lock control when appropriate. |
|
461
|
|
|
|
|
|
|
Expects as parameters a L<Siebel::Srvrmgr::Connection>, or it will C<confess> with an exception. |
|
462
|
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=cut |
|
464
|
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
sub run { |
|
466
|
20
|
|
|
20
|
1
|
873
|
my ( $self ) = @_; |
|
467
|
|
|
|
|
|
|
# :TODO:11-12-2016 20:43:19:: wtf is this? |
|
468
|
|
|
|
|
|
|
# my $class = blessed($self); |
|
469
|
|
|
|
|
|
|
# |
|
470
|
|
|
|
|
|
|
# if ( defined($class) ) { |
|
471
|
|
|
|
|
|
|
# confess |
|
472
|
|
|
|
|
|
|
#"Only subclasses of Siebel::Srvrmgr::Daemon can executed this method (received '$class')" |
|
473
|
|
|
|
|
|
|
# unless ( $self->isa('Siebel::Srvrmgr::Daemon') ); |
|
474
|
|
|
|
|
|
|
# } |
|
475
|
|
|
|
|
|
|
# else { |
|
476
|
|
|
|
|
|
|
# confess |
|
477
|
|
|
|
|
|
|
#"Only subclasses of Siebel::Srvrmgr::Daemon can executed this method (received unblessed '$self')"; |
|
478
|
|
|
|
|
|
|
# } |
|
479
|
|
|
|
|
|
|
|
|
480
|
20
|
100
|
|
|
|
1132
|
if ( $self->has_lock ) { |
|
481
|
8
|
|
|
|
|
111
|
$self->_create_lock; |
|
482
|
|
|
|
|
|
|
} |
|
483
|
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
} |
|
485
|
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
=pod |
|
487
|
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
=head2 normalize_eol |
|
489
|
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
Expects an array reference as parameter. |
|
491
|
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
Changes any EOL character to LF from each index value. |
|
493
|
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
See perlport -> Issues -> Newlines for details on this. |
|
495
|
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
=cut |
|
497
|
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
sub normalize_eol { |
|
499
|
34
|
|
|
34
|
1
|
140
|
my ( $self, $data_ref ) = @_; |
|
500
|
34
|
|
|
|
|
386
|
my $ref_type = ref($data_ref); |
|
501
|
34
|
50
|
66
|
|
|
297
|
confess 'data parameter must be an array or scalar reference' |
|
502
|
|
|
|
|
|
|
unless ( ( $ref_type eq 'ARRAY' ) or ( $ref_type eq 'SCALAR' ) ); |
|
503
|
34
|
|
|
|
|
264
|
my $c_regex = qr/\o{15}?\o{12}/; |
|
504
|
|
|
|
|
|
|
|
|
505
|
34
|
100
|
|
|
|
162
|
if ( $ref_type eq 'ARRAY' ) { |
|
506
|
4
|
|
|
|
|
35
|
local $/ = "\o{12}"; |
|
507
|
|
|
|
|
|
|
|
|
508
|
4
|
|
|
|
|
11
|
foreach ( @{$data_ref} ) { |
|
|
4
|
|
|
|
|
19
|
|
|
509
|
1704
|
|
|
|
|
15720
|
s/$c_regex/\n/g; |
|
510
|
|
|
|
|
|
|
} |
|
511
|
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
} |
|
513
|
|
|
|
|
|
|
else { |
|
514
|
30
|
|
|
|
|
2973
|
$$data_ref =~ s/$c_regex/\n/g; |
|
515
|
|
|
|
|
|
|
} |
|
516
|
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
} |
|
518
|
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
=pod |
|
520
|
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
=head2 create_parser |
|
522
|
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
Returns an instance of a L<Siebel::Srvrmgr::ListParser> class. |
|
524
|
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
Optionally, it can receive as parameter a string representing the field delimiter that is expected. If received, |
|
526
|
|
|
|
|
|
|
the parameter will be used to create the instance. |
|
527
|
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
=cut |
|
529
|
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
sub create_parser { |
|
531
|
21
|
|
|
21
|
1
|
80
|
my ( $self, $delimiter ) = @_; |
|
532
|
|
|
|
|
|
|
|
|
533
|
21
|
100
|
|
|
|
86
|
if ( defined($delimiter) ) { |
|
534
|
1
|
|
|
|
|
48
|
return Siebel::Srvrmgr::ListParser->new( |
|
535
|
|
|
|
|
|
|
{ |
|
536
|
|
|
|
|
|
|
clear_raw => $self->clear_raw(), |
|
537
|
|
|
|
|
|
|
field_delimiter => $delimiter |
|
538
|
|
|
|
|
|
|
} |
|
539
|
|
|
|
|
|
|
); |
|
540
|
|
|
|
|
|
|
} |
|
541
|
|
|
|
|
|
|
else { |
|
542
|
20
|
|
|
|
|
800
|
return Siebel::Srvrmgr::ListParser->new( |
|
543
|
|
|
|
|
|
|
{ clear_raw => $self->clear_raw() } ); |
|
544
|
|
|
|
|
|
|
} |
|
545
|
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
} |
|
547
|
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
# :WORKAROUND:06/08/2013 21:05:32:: if a perl script will be executed (like for automated testing of this distribution) |
|
549
|
|
|
|
|
|
|
# then the perl interpreter must be part of the command path to avoid calling cmd.exe in Microsoft Windows |
|
550
|
|
|
|
|
|
|
sub _define_params { |
|
551
|
5
|
|
|
5
|
|
88
|
my ( $self, $params_ref ) = @_; |
|
552
|
5
|
50
|
|
|
|
170
|
unshift( @{$params_ref}, $Config{perlpath} ) if ( $self->use_perl() ); |
|
|
5
|
|
|
|
|
259
|
|
|
553
|
5
|
|
|
|
|
23
|
return $params_ref; |
|
554
|
|
|
|
|
|
|
} |
|
555
|
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
=head2 get_lock_file |
|
557
|
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
Returns the complete path to the lock file as a string. |
|
559
|
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
=cut |
|
561
|
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
sub get_lock_file { |
|
563
|
12
|
|
|
12
|
1
|
31
|
my $self = shift; |
|
564
|
12
|
|
|
|
|
58
|
my $filename = blessed($self); |
|
565
|
12
|
|
|
|
|
74
|
$filename =~ s/\:{2}/_/g; |
|
566
|
12
|
|
|
|
|
687
|
return File::Spec->catfile( $self->get_lock_dir, ( $filename . '.lock' ) ); |
|
567
|
|
|
|
|
|
|
} |
|
568
|
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
our $adm_60070 = qr/^SBL-ADM-60070.*/; |
|
570
|
|
|
|
|
|
|
our $adm_02043 = qr/^SBL-ADM-02043.*/; |
|
571
|
|
|
|
|
|
|
our $adm_02071 = qr/^SBL-ADM-02071.*/; |
|
572
|
|
|
|
|
|
|
our $adm_02049 = qr/^SBL-ADM-02049.*/; |
|
573
|
|
|
|
|
|
|
our $adm_02751 = qr/^SBL-ADM-02751.*/; |
|
574
|
|
|
|
|
|
|
our $siebel_error = SIEBEL_ERROR; |
|
575
|
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
# Fatal error (2555922): (null), exiting... |
|
577
|
|
|
|
|
|
|
our $fatal_error = qr/Fatal error.*exiting\.\.\./; |
|
578
|
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
# this method will check for errors and warnings, specially if read from STDERR. |
|
580
|
|
|
|
|
|
|
# the first parameter is the data to be check, which can be an array reference or scalar, both will be checked the same way |
|
581
|
|
|
|
|
|
|
# the seconds parameter tells if the data was read from STDERR or not. If read from STDERR, data will be logged as warnings |
|
582
|
|
|
|
|
|
|
# if no critical error was detected |
|
583
|
|
|
|
|
|
|
sub _check_error { |
|
584
|
|
|
|
|
|
|
|
|
585
|
1469
|
|
|
1469
|
|
3317
|
my $self = shift; |
|
586
|
1469
|
|
|
|
|
11266
|
my $content = shift; |
|
587
|
1469
|
|
|
|
|
2856
|
my $is_error = shift; #boolean |
|
588
|
|
|
|
|
|
|
|
|
589
|
1469
|
|
|
|
|
10272
|
my $logger = Siebel::Srvrmgr->gimme_logger( blessed($self) ); |
|
590
|
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
# :WORKAROUND: to enable the code to process both scalar and array reference data |
|
592
|
|
|
|
|
|
|
# without duplicating code |
|
593
|
|
|
|
|
|
|
|
|
594
|
1469
|
100
|
|
|
|
77663
|
unless ( ref($content) eq 'ARRAY' ) { |
|
595
|
|
|
|
|
|
|
|
|
596
|
1438
|
|
|
|
|
3477
|
my $temp = $content; |
|
597
|
1438
|
|
|
|
|
6240
|
$content = [$temp]; |
|
598
|
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
} |
|
600
|
|
|
|
|
|
|
|
|
601
|
1469
|
|
|
|
|
3158
|
foreach my $line ( @{$content} ) { |
|
|
1469
|
|
|
|
|
4462
|
|
|
602
|
|
|
|
|
|
|
|
|
603
|
1469
|
50
|
|
|
|
10454
|
if ( $line =~ $fatal_error ) { |
|
604
|
|
|
|
|
|
|
|
|
605
|
0
|
|
|
|
|
0
|
$logger->logdie("Failed to connect to: [$line]"); |
|
606
|
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
} |
|
608
|
|
|
|
|
|
|
|
|
609
|
1469
|
100
|
|
|
|
10240
|
if ( $line =~ $siebel_error ) { |
|
610
|
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
SWITCH: { |
|
612
|
|
|
|
|
|
|
|
|
613
|
1
|
50
|
|
|
|
5
|
if ( $line =~ $adm_60070 ) { |
|
|
1
|
|
|
|
|
9
|
|
|
614
|
|
|
|
|
|
|
|
|
615
|
0
|
0
|
|
|
|
0
|
if ( $logger->is_warn() ) { |
|
616
|
|
|
|
|
|
|
|
|
617
|
0
|
|
|
|
|
0
|
$logger->warn( |
|
618
|
|
|
|
|
|
|
"Found [$line]. Trying to get additional information from next line" |
|
619
|
|
|
|
|
|
|
); |
|
620
|
0
|
|
|
|
|
0
|
return 1; |
|
621
|
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
} |
|
623
|
|
|
|
|
|
|
} |
|
624
|
|
|
|
|
|
|
|
|
625
|
1
|
50
|
|
|
|
14
|
if ( $line =~ $adm_02043 ) { |
|
626
|
1
|
|
|
|
|
9
|
$logger->logdie('Could not find the Siebel Server'); |
|
627
|
|
|
|
|
|
|
} |
|
628
|
|
|
|
|
|
|
|
|
629
|
0
|
0
|
|
|
|
0
|
if ( $line =~ $adm_02071 ) { |
|
630
|
0
|
|
|
|
|
0
|
$logger->logdie('Could not find the Siebel Enterprise'); |
|
631
|
|
|
|
|
|
|
} |
|
632
|
|
|
|
|
|
|
|
|
633
|
0
|
0
|
|
|
|
0
|
if ( $line =~ $adm_02049 ) { |
|
634
|
0
|
|
|
|
|
0
|
$logger->logdie('Generic error'); |
|
635
|
|
|
|
|
|
|
} |
|
636
|
|
|
|
|
|
|
|
|
637
|
0
|
0
|
|
|
|
0
|
if ( $line =~ $adm_02751 ) { |
|
638
|
0
|
|
|
|
|
0
|
$logger->logdie('Unable to open file'); |
|
639
|
|
|
|
|
|
|
} |
|
640
|
|
|
|
|
|
|
else { |
|
641
|
0
|
|
|
|
|
0
|
$logger->logdie( |
|
642
|
|
|
|
|
|
|
"Unknown error [$line], aborting execution"); |
|
643
|
|
|
|
|
|
|
} |
|
644
|
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
} |
|
646
|
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
} |
|
648
|
|
|
|
|
|
|
else { |
|
649
|
|
|
|
|
|
|
|
|
650
|
1468
|
50
|
|
|
|
5543
|
$logger->debug( |
|
651
|
|
|
|
|
|
|
"Got $line. Since it doesn't look like a Siebel error, I will try to keep running" |
|
652
|
|
|
|
|
|
|
) if ( $logger->is_debug ); |
|
653
|
|
|
|
|
|
|
|
|
654
|
1468
|
100
|
100
|
|
|
17475
|
$logger->warn($line) if ( $logger->is_warn() and $is_error ); |
|
655
|
|
|
|
|
|
|
|
|
656
|
1468
|
|
|
|
|
19664
|
return 1; |
|
657
|
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
} |
|
659
|
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
} |
|
661
|
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
} |
|
663
|
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
=pod |
|
665
|
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
=head2 DEMOLISH |
|
667
|
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
This method is invoked before the object instance is destroyed. It does really few things like writting messages to the define configuration of |
|
669
|
|
|
|
|
|
|
L<Log::Log4perl> logger. It will also log if ALRM, INT or PIPE signals were received. |
|
670
|
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
Subclasses may want to C<override> the method "private" C<_my_cleanup> to do their properly laundry since the definition of C<_my_cleanup> for this class |
|
672
|
|
|
|
|
|
|
is just to C<return> true. C<_my_cleanup> is called with a reference of a L<Log::Log4perl::Logger> instance for usage. |
|
673
|
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
=cut |
|
675
|
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
sub DEMOLISH { |
|
677
|
6
|
|
|
6
|
1
|
24
|
my $self = shift; |
|
678
|
6
|
|
|
|
|
70
|
my $logger = Siebel::Srvrmgr->gimme_logger( blessed($self) ); |
|
679
|
6
|
|
|
|
|
272
|
$logger->info('Terminating daemon: preparing cleanup'); |
|
680
|
6
|
|
|
|
|
94
|
$self->_my_cleanup(); |
|
681
|
|
|
|
|
|
|
|
|
682
|
6
|
100
|
|
|
|
216
|
if ( $self->has_lock() ) { |
|
683
|
2
|
|
|
|
|
25
|
$self->_del_lock(); |
|
684
|
|
|
|
|
|
|
} |
|
685
|
|
|
|
|
|
|
|
|
686
|
6
|
|
|
|
|
36
|
$logger->info('Cleanup is finished'); |
|
687
|
|
|
|
|
|
|
|
|
688
|
6
|
100
|
|
|
|
67
|
if ( $logger->is_warn() ) { |
|
689
|
3
|
50
|
|
|
|
36
|
$logger->warn('Program termination was forced by ALRM signal') |
|
690
|
|
|
|
|
|
|
if ($SIG_ALARM); |
|
691
|
3
|
50
|
|
|
|
14
|
$logger->warn('Program termination was forced by INT signal') |
|
692
|
|
|
|
|
|
|
if ($SIG_INT); |
|
693
|
3
|
50
|
|
|
|
14
|
$logger->warn('Program termination was forced by PIPE signal') |
|
694
|
|
|
|
|
|
|
if ($SIG_PIPE); |
|
695
|
|
|
|
|
|
|
} |
|
696
|
|
|
|
|
|
|
|
|
697
|
6
|
50
|
|
|
|
45
|
$logger->info( ref($self) . ' says bye-bye' ) if ( $logger->is_info() ); |
|
698
|
6
|
|
|
|
|
67
|
Log::Log4perl->remove_logger($logger); |
|
699
|
|
|
|
|
|
|
} |
|
700
|
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
=head1 CONSTANTS |
|
702
|
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
The following constants are available in this class: |
|
704
|
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
=over |
|
706
|
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
=item LOCK_EX |
|
708
|
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
=item LOCK_NB |
|
710
|
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
=back |
|
712
|
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
All of them from the L<Fcntl> module. |
|
714
|
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
=cut |
|
716
|
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
sub _create_lock { |
|
718
|
8
|
|
|
8
|
|
25
|
my $self = shift; |
|
719
|
8
|
|
|
|
|
97
|
my $logger = Siebel::Srvrmgr->gimme_logger( blessed($self) ); |
|
720
|
8
|
|
|
|
|
420
|
my $lock_file = $self->get_lock_file; |
|
721
|
|
|
|
|
|
|
|
|
722
|
8
|
100
|
|
|
|
226
|
if ( -e $lock_file ) { |
|
723
|
6
|
50
|
|
|
|
216
|
open( my $in, '<', $lock_file ) |
|
724
|
|
|
|
|
|
|
or $logger->logdie("Cannot read $lock_file: $!"); |
|
725
|
6
|
50
|
|
|
|
78
|
flock( $in, LOCK_EX | LOCK_NB ) |
|
726
|
|
|
|
|
|
|
or $logger->logdie("Could not get exclusive lock on $lock_file: $!"); |
|
727
|
6
|
|
|
|
|
41
|
local $/ = undef; |
|
728
|
6
|
|
|
|
|
210
|
my $pid = <$in>; |
|
729
|
6
|
|
|
|
|
55
|
close($in); |
|
730
|
|
|
|
|
|
|
|
|
731
|
6
|
50
|
|
|
|
80
|
$logger->logdie( |
|
732
|
|
|
|
|
|
|
"Previous executing is still running (PID $pid), cannot execute") |
|
733
|
|
|
|
|
|
|
if ( $pid != $$ ); |
|
734
|
|
|
|
|
|
|
|
|
735
|
|
|
|
|
|
|
} |
|
736
|
|
|
|
|
|
|
else { |
|
737
|
2
|
50
|
|
|
|
144
|
open( my $out, '>', $lock_file ) |
|
738
|
|
|
|
|
|
|
or $logger->logdie("Cannot create $lock_file: $!"); |
|
739
|
2
|
50
|
|
|
|
34
|
flock( $out, LOCK_EX | LOCK_NB ) |
|
740
|
|
|
|
|
|
|
or $logger->logdie("Could not get exclusive lock on $lock_file: $!"); |
|
741
|
2
|
|
|
|
|
18
|
print $out $$; |
|
742
|
2
|
|
|
|
|
86
|
close($out); |
|
743
|
|
|
|
|
|
|
} |
|
744
|
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
} |
|
746
|
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
sub _del_lock { |
|
748
|
2
|
|
|
2
|
|
7
|
my $self = shift; |
|
749
|
2
|
|
|
|
|
12
|
my $lock_file = $self->get_lock_file; |
|
750
|
2
|
|
|
|
|
25
|
my $logger = Siebel::Srvrmgr->gimme_logger( blessed($self) ); |
|
751
|
|
|
|
|
|
|
|
|
752
|
2
|
50
|
|
|
|
217
|
if ( -e $lock_file ) { |
|
753
|
2
|
50
|
|
|
|
161
|
unlink($lock_file) |
|
754
|
|
|
|
|
|
|
or $logger->logdie("Could not remove $lock_file: $!"); |
|
755
|
|
|
|
|
|
|
} |
|
756
|
|
|
|
|
|
|
else { |
|
757
|
0
|
|
|
|
|
0
|
$logger->warn( |
|
758
|
|
|
|
|
|
|
'Could not find lock file to remove before program termination'); |
|
759
|
|
|
|
|
|
|
} |
|
760
|
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
} |
|
762
|
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
sub _my_cleanup { |
|
764
|
|
|
|
|
|
|
|
|
765
|
0
|
|
|
0
|
|
0
|
return 1; |
|
766
|
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
} |
|
768
|
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
sub _define_lock_dir { |
|
770
|
|
|
|
|
|
|
|
|
771
|
0
|
|
|
0
|
|
0
|
my $lock_dir = undef; |
|
772
|
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
CASE: { |
|
774
|
|
|
|
|
|
|
|
|
775
|
0
|
0
|
|
|
|
0
|
if ( $Config{osname} =~ /^linux$/i ) { |
|
|
0
|
|
|
|
|
0
|
|
|
776
|
|
|
|
|
|
|
|
|
777
|
0
|
|
|
|
|
0
|
$lock_dir = $ENV{HOME}; |
|
778
|
0
|
|
|
|
|
0
|
last CASE; |
|
779
|
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
} |
|
781
|
|
|
|
|
|
|
|
|
782
|
0
|
0
|
|
|
|
0
|
if ( $Config{osname} =~ /^aix$/i ) { |
|
783
|
|
|
|
|
|
|
|
|
784
|
0
|
|
|
|
|
0
|
$lock_dir = $ENV{HOME}; |
|
785
|
0
|
|
|
|
|
0
|
last CASE; |
|
786
|
|
|
|
|
|
|
|
|
787
|
|
|
|
|
|
|
} |
|
788
|
|
|
|
|
|
|
|
|
789
|
0
|
0
|
|
|
|
0
|
if ( $Config{osname} =~ /^hpux$/i ) { |
|
790
|
|
|
|
|
|
|
|
|
791
|
0
|
|
|
|
|
0
|
$lock_dir = $ENV{HOME}; |
|
792
|
0
|
|
|
|
|
0
|
last CASE; |
|
793
|
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
} |
|
795
|
|
|
|
|
|
|
|
|
796
|
0
|
0
|
|
|
|
0
|
if ( $Config{osname} =~ /^mswin32$/i ) { |
|
797
|
|
|
|
|
|
|
|
|
798
|
0
|
0
|
|
|
|
0
|
if ( defined( $ENV{HOMEDIR} ) ) { |
|
799
|
|
|
|
|
|
|
|
|
800
|
0
|
|
|
|
|
0
|
$lock_dir = $ENV{HOMEDIR}; |
|
801
|
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
} |
|
803
|
|
|
|
|
|
|
else { |
|
804
|
|
|
|
|
|
|
|
|
805
|
0
|
|
|
|
|
0
|
$lock_dir = $ENV{USERPROFILE}; |
|
806
|
|
|
|
|
|
|
|
|
807
|
|
|
|
|
|
|
} |
|
808
|
|
|
|
|
|
|
|
|
809
|
0
|
|
|
|
|
0
|
last CASE; |
|
810
|
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
} |
|
812
|
|
|
|
|
|
|
|
|
813
|
0
|
0
|
|
|
|
0
|
if ( $Config{osname} =~ /^solaris$/i ) { |
|
814
|
|
|
|
|
|
|
|
|
815
|
0
|
|
|
|
|
0
|
$lock_dir = $ENV{HOME}; |
|
816
|
0
|
|
|
|
|
0
|
last CASE; |
|
817
|
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
} |
|
819
|
|
|
|
|
|
|
else { |
|
820
|
|
|
|
|
|
|
|
|
821
|
0
|
|
|
|
|
0
|
confess "don't know what to do with $Config{osname}"; |
|
822
|
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
} |
|
824
|
|
|
|
|
|
|
|
|
825
|
|
|
|
|
|
|
} |
|
826
|
|
|
|
|
|
|
|
|
827
|
0
|
0
|
|
|
|
0
|
confess "could not defined a lock_dir for $Config{osname}" |
|
828
|
|
|
|
|
|
|
unless ( defined($lock_dir) ); |
|
829
|
|
|
|
|
|
|
|
|
830
|
0
|
|
|
|
|
0
|
return $lock_dir; |
|
831
|
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
} |
|
833
|
|
|
|
|
|
|
|
|
834
|
|
|
|
|
|
|
sub _setup_commands { |
|
835
|
26
|
|
|
26
|
|
790
|
my $self = shift; |
|
836
|
|
|
|
|
|
|
|
|
837
|
26
|
|
|
|
|
54
|
foreach my $cmd ( @{ $self->get_commands } ) { |
|
|
26
|
|
|
|
|
1074
|
|
|
838
|
61
|
|
|
|
|
2470
|
$self->check_cmd( $cmd->get_command() ); |
|
839
|
|
|
|
|
|
|
} |
|
840
|
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
} |
|
842
|
|
|
|
|
|
|
|
|
843
|
|
|
|
|
|
|
=pod |
|
844
|
|
|
|
|
|
|
|
|
845
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
846
|
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
=over |
|
848
|
|
|
|
|
|
|
|
|
849
|
|
|
|
|
|
|
=item * |
|
850
|
|
|
|
|
|
|
|
|
851
|
|
|
|
|
|
|
L<Moose> |
|
852
|
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
=item * |
|
854
|
|
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
L<Siebel::Srvrmgr::Daemon::ActionFactory> |
|
856
|
|
|
|
|
|
|
|
|
857
|
|
|
|
|
|
|
=item * |
|
858
|
|
|
|
|
|
|
|
|
859
|
|
|
|
|
|
|
L<Siebel::Srvrmgr::ListParser> |
|
860
|
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
=item * |
|
862
|
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
L<Siebel::Srvrmgr::Regexes> |
|
864
|
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
=item * |
|
866
|
|
|
|
|
|
|
|
|
867
|
|
|
|
|
|
|
L<POSIX> |
|
868
|
|
|
|
|
|
|
|
|
869
|
|
|
|
|
|
|
=item * |
|
870
|
|
|
|
|
|
|
|
|
871
|
|
|
|
|
|
|
L<Siebel::Srvrmgr::Daemon::Command> |
|
872
|
|
|
|
|
|
|
|
|
873
|
|
|
|
|
|
|
=item * |
|
874
|
|
|
|
|
|
|
|
|
875
|
|
|
|
|
|
|
L<Fcntl> |
|
876
|
|
|
|
|
|
|
|
|
877
|
|
|
|
|
|
|
=back |
|
878
|
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
=head1 AUTHOR |
|
880
|
|
|
|
|
|
|
|
|
881
|
|
|
|
|
|
|
Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt> |
|
882
|
|
|
|
|
|
|
|
|
883
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
884
|
|
|
|
|
|
|
|
|
885
|
|
|
|
|
|
|
This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt> |
|
886
|
|
|
|
|
|
|
|
|
887
|
|
|
|
|
|
|
This file is part of Siebel Monitoring Tools. |
|
888
|
|
|
|
|
|
|
|
|
889
|
|
|
|
|
|
|
Siebel Monitoring Tools is free software: you can redistribute it and/or modify |
|
890
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
|
891
|
|
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or |
|
892
|
|
|
|
|
|
|
(at your option) any later version. |
|
893
|
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
Siebel Monitoring Tools is distributed in the hope that it will be useful, |
|
895
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
896
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
897
|
|
|
|
|
|
|
GNU General Public License for more details. |
|
898
|
|
|
|
|
|
|
|
|
899
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
|
900
|
|
|
|
|
|
|
along with Siebel Monitoring Tools. If not, see <http://www.gnu.org/licenses/>. |
|
901
|
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
=cut |
|
903
|
|
|
|
|
|
|
|
|
904
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
905
|
|
|
|
|
|
|
|
|
906
|
|
|
|
|
|
|
1; |
|
907
|
|
|
|
|
|
|
|