Siebel::Srvrmgr::Daemon::Heavy - subclass that reuses srvrmgr program instance for long periods
use Siebel::Srvrmgr::Daemon::Heavy; my $daemon = Siebel::Srvrmgr::Daemon::Heavy->new( { time_zone => 'America/Sao_Paulo', commands => [ Siebel::Srvrmgr::Daemon::Command->new( command => 'load preferences', action => 'LoadPreferences' ), Siebel::Srvrmgr::Daemon::Command->new( command => 'list comp type', action => 'ListCompTypes', params => [$comp_types_file] ), Siebel::Srvrmgr::Daemon::Command->new( command => 'list comp', action => 'ListComps', params => [$comps_file] ), Siebel::Srvrmgr::Daemon::Command->new( command => 'list comp def', action => 'ListCompDef', params => [$comps_defs_file] ) ] } ); $daemon->run($connection);
This class extends Siebel::Srvmrgr::Daemon. By "Heavy" you should understand as more complex code to be able to deal with a large number of commands of srvrmgr that will be submitted to a Siebel Enterprise with a short time between them.
srvrmgr
This class is indicated to be used in scenarios where several commands need to be executed in a short time interval: it will connect to srvrmgr by using IPC for communication between the processes and once connected, the srvrmgr session will be reused as many times as desired instead of following the sequence of connect -> run commands -> disconnect.
The sessions are not "interactive" from the user point of view but the usage of this class enable the adoption of some logic to change how the commands will be executed or even generate commands on the fly.
Since it uses Perl IPC, this class may suffer from good support in OS plataforms that are not UNIX-like. Be sure to check out tests results of the distribution before trying to use it.
This class has additional attributes besides those from parent class.
The maximum times this class wil retry to launch a new process of srvrmgr if the previous one failed for any reason. This is intented to implement robustness to the process.
The number of retries of launching a new srvrmgr process. If this value reaches the value defined for maximum_retries, the instance of Siebel::Srvrmgr::Daemon will quit execution returning an error code.
maximum_retries
A filehandle reference to the srvrmgr STDIN. This is a read-only attribute.
A filehandle reference to the srvrmgr STDOUT.
This is a read-only attribute.
A filehandle reference to the srvrmgr STDERR.
The timeout for trying to read from child process handlers in seconds. It defaults to 0.5 second.
Changing this value may help improving performance, but should be used with care.
An integer presenting the process id (PID) of the process created by the OS when the srvrmgr program is executed.
This is a string representing the last command submitted to the srvrmgr program. The default value for it is an empty string (meaning that no command was submitted yet).
This is an array reference with the stack of params passed to the respective class. It is maintained automatically by the class so the attribute is read-only.
This is an array reference with the stack of actions to be taken. It is maintained automatically by the class, so the attribute is read-only.
A integer describing the size of the buffer used to read output from srvrmgr program by using IPC.
It defaults to 32768 bytes, but it can be adjusted to improve performance (lowering CPU usage by increasing memory utilization).
Increase of this attribute should be considered experimental.
An string representing the prompt recovered from srvrmgr program. The value of this attribute is set automatically during srvrmgr execution.
This methods calls clear_pid just to have a sane setting on child_pid attribute.
clear_pid
child_pid
Getter for the retries attribute.
retries
Getter for the max_retries attribute.
max_retries
Clears the defined PID associated with the child process that executes srvrmgr. This is usually associated with calling close_child.
close_child
Beware that this is different then removing the child process or even undef the attribute. This just controls a flag that the attribute child_pid is defined or not. See Moose attributes for details.
undef
Returns true or false if the child_pid is defined. Beware that this is different then checking if there is an integer associated with child_pid attribute: this method might return false even though the old PID associated with child_pid is still available. See Moose attributes for details.
Returns the content of the attribute srvrmgr_prompt.
srvrmgr_prompt
Returns the value of the attribute ipc_buffer_size.
ipc_buffer_size
Sets the attribute ipc_buffer_size. Expects an integer as parameter, multiple of 1024.
Returns the file handle of STDIN from the process executing the srvrmgr program based on the value of the attribute write_fh.
write_fh
Returns the file handle of STDOUT from the process executing the srvrmgr program based on the value of the attribute read_fh.
read_fh
Returns the file handle of STDERR from the process executing the srvrmgr program based on the value of the attribute error_fh.
error_fh
Returns the content of pid attribute as an integer.
pid
Returns the content of the attribute last_cmd as a string.
last_cmd
Returns the content of the attribute params_stack.
params_stack
This method will try to connect to a Siebel Enterprise through srvrmgr program (if it is the first time the method is invoke) or reuse an already open connection to submit the commands and respective actions defined during object creation. The path to the program is check and if it does not exists the method will issue an warning message and immediatly returns false.
Those operations will be executed in a loop as long the check method from the class Siebel::Srvrmgr::Daemon::Condition returns true.
check
Finishes the child process associated with the execution of srvrmgr program, if the child's PID is available. Besides, this automatically calls clear_pid.
First this methods tries to submit the exit command to srvrmgr, hoping to terminate the connection with the Siebel Enterprise. After that, the handles associated with the child will be closed. If after that the PID is still running, the method will call waitpid in non-blocking mode.
exit
waitpid
For MS Windows OS, this might not be sufficient: the PID will be checked again after waitpid, and if it is still running, this method will try to use kill 9 to eliminate the process.
kill 9
If the child process is terminated successfully, this method returns true. If there is no PID associated with the Daemon instance, this method will return false.
If you're in a UNIX-like OS, you might want to execute some code with this class as a background process. This can be easily done with:
nohup ~/perl5/perlbrew/perls/perl-5.16.3/bin/perl ~/my_script.pl CRTL+Z bg 1
In this example, the Perl interpreter was located in ~/perl5/perlbrew/perls/perl-5.16.3/bin/perl but of course you location might be different.
~/perl5/perlbrew/perls/perl-5.16.3/bin/perl
This class is still considered experimental and should be used with care. Tests with MS Windows (and the nature of doing IPC within the plataform) makes it difficult do use this class in Microsoft OS's.
The srvrmgr program uses buffering, which makes difficult to read the generated output as expected.
IPC::Open3
Siebel::Srvrmgr:::Daemon
Siebel::Srvrmgr::Daemon::Condition
Siebel::Srvrmgr::Daemon::Command
Siebel::Srvrmgr::Daemon::ActionFactory
Siebel::Srvrmgr::Regexes
POSIX
Siebel::Srvrmgr::Daemon::IPC
Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>.
This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>
This file is part of Siebel Monitoring Tools.
Siebel Monitoring Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Siebel Monitoring Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Siebel Monitoring Tools. If not, see http://www.gnu.org/licenses/.
To install Siebel::Srvrmgr, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Siebel::Srvrmgr
CPAN shell
perl -MCPAN -e shell install Siebel::Srvrmgr
For more information on module installation, please visit the detailed CPAN module installation guide.