Siebel::Srvrmgr::Daemon::Heavy - "heavier' implementation of Siebel::Srvrmgr::Daemon
use Siebel::Srvrmgr::Daemon; my $daemon = Siebel::Srvrmgr::Daemon->new( { server => 'servername', gateway => 'gateway', enterprise => 'enterprise', user => 'user', password => 'password', bin => 'c:\\siebel\\client\\bin\\srvrmgr.exe', is_infinite => 1, 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] ) ] } );
This class is the "heavier" version of Siebel::Srvmrgr::Daemon. By heavier, understand more complex code to be able to deal with a heavier usage of srvrmgr.
This class is indicated to be used in cenarios 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.
This module is based on IPC::Open3::Callback from Lucas Theisen (see SEE ALSO section) implemented in Siebel::Srvrmgr::Daemon::IPC.
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.
A filehandle reference to the srvrmgr STDIN. This is a read-only attribute.
srvrmgr
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 3 seconds.
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 methods calls clear_pid just to have a sane setting on child_pid attribute.
clear_pid
child_pid
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 commands to be executed. It is maintained automatically by the class, so the attribute is read-only.
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.
The an integer value that will raise an ALARM signal generated by alarm. The default value is 30 seconds.
alarm
Besides read_timeout, this will raise an exception and exit the read loop from srvrmgr in cases were an output cannot be retrieved.
read_timeout
This attribute will be reset every time a read can be done from the STDOUT or STDERR from srvrmgr.
A integer describing the size of the buffer used to read output from srvrmgr program by using IPC.
It defaults to 5120 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.
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 is_infinite, returning true or false depending on this value.
is_infinite
Returns the content of the attribute last_cmd as a string.
last_cmd
Returns the content of the attribute cmd_stack.
cmd_stack
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
Beware that Siebel::Srvrmgr::Daemon uses a single instance of a Siebel::Srvrmgr::ListParser class to process the parsing requests, so it is not possible to execute Siebel::Srvrmgr::Daemon::Command instances in parallel.
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 succesfully, this method returns true. If there is no PID associated with the Daemon instance, this method will return false.
Accepts as an optional parameter an instance of a Log::Log4perl for logging messages.
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
Moose
Siebel::Srvrmgr::Daemon::Condition
Siebel::Srvrmgr::Daemon::Command
Siebel::Srvrmgr::Daemon::ActionFactory
Siebel::Srvrmgr::ListParser
Siebel::Srvrmgr::Regexes
POSIX
Siebel::Srvrmgr::Daemon::IPC
https://github.com/lucastheisen/ipc-open3-callback
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.