The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Siebel::Srvrmgr::Daemon - super class for sessions with Siebel srvrmgr program

SYNOPSIS

    package MyDaemon;

        extends 'Siebel::Srvrmgr::Daemon';

DESCRIPTION

This is a super class, and alone it does not provide any functionaly to use srvrmgr to send commands and process returned data.

The "private" method _setup_commands must be overrided by subclasses of it or commands will not be sent to srvrmgr (the currently implementation warns about that).

Logging of this class can be enabled by using Siebel::Srvrmgr logging feature.

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 srvrmgr, submit the command 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 storing the output to even generating new commands to be executed in the server.

A command is an instance of Siebel::Srvrmgr::Daemon::Command class. Any "list" command is supported, and also load preferences and exit. Anything else is considered dangerous and will generated an exception. Beware that you will need to have an Siebel::Srvrmgr::ListParser::Output class available to be able to parse the command output.

An action can be any class but is obligatory to create a subclass of Siebel::Srvrmgr::Daemon::Action base class. See the <commands> attribute for details.

Implementation details are reserved to subclasses of Siebel::Srvrmgr::Daemon: be sure to check them for real usage cenarios.

ATTRIBUTES

server

This is a string representing the servername where the instance should connect. This is a optional attribute during object creation with the new method.

Beware that the run method will verify if the server attribute has a defined value or not: if it has, the run method will try to connect to the Siebel Enterprise specifying the given Siebel Server. If not, the method will try to connect to the Enterprise only, not specifying which Siebel Server to connect.

gateway

This is a string representing the gateway where the instance should connect. This is a required attribute during object creation with the new method.

enterprise

This is a string representing the enterprise where the instance should connect. This is a required attribute during object creation with the new method.

user

This is a string representing the login for authentication. This is a required attribute during object creation with the new method.

password

This is a string representing the password for authentication. This is a required attribute during object creation with the new method.

commands

An array reference containing one or more references of Siebel::Srvrmgr::Daemon::Commands class.

The commands will be executed in the exactly order as given by the indexes in the array reference (as FIFO).

This is a required attribute during object creation with the new method.

bin

An string representing the full path to the srvrmgr program in the filesystem.

This is a required attribute during object creation with the new method.

is_infinite

An boolean defining if the interaction loop should be infinite or not.

alarm_timeout

The an integer value that will raise an ALARM signal generated by alarm. The default value is 30 seconds.

Besides read_timeout, this will raise an exception and exit the read loop from srvrmgr in cases were an output cannot be retrieved.

This attribute will be reset every time a read can be done from the STDOUT or STDERR from srvrmgr.

use_perl

A boolean attribute used mostly for testing of this class.

If true, if will prepend the complete path of the Perl interpreter to the parameters before calling the srvrmgr program (of course the "srvrmgr" must be itself a Perl script).

It defaults to false.

lang_id

A string representing the LANG_ID parameter to connect to srvrmgr. If defaults to "ENU";

child_runs

An integer representing the number of times the child object was used in run invocations. This is reset to zero if a new child process is created.

maximum_retries

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.

retries

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.

METHODS

get_alarm

Returns the content of the alarm_timeout attribute.

set_alarm

Sets the attribute alarm_timeout. Expects an integer as parameter, in seconds.

get_child_runs

Returns the value of the attribute child_runs.

use_perl

Returns the content of the attribute use_perl.

get_buffer_size

Returns the value of the attribute ipc_buffer_size.

set_buffer_size

Sets the attribute ipc_buffer_size. Expects an integer as parameter, multiple of 1024.

get_lang_id

Returns the value of the attribute lang_id.

set_lang_id

Sets the attribute lang_id. Expects a string as parameter.

get_server

Returns the content of server attribute as a string.

set_server

Sets the attribute server. Expects an string as parameter.

get_gateway

Returns the content of gateway attribute as a string.

set_gateway

Sets the attribute gateway. Expects a string as parameter.

get_enterprise

Returns the content of enterprise attribute as a string.

set_enterprise

Sets the enterprise attribute. Expects a string as parameter.

get_user

Returns the content of user attribute as a string.

set_user

Sets the user attribute. Expects a string as parameter.

get_password

Returns the content of password attribute as a string.

set_password

Sets the password attribute. Expects a string as parameter.

get_commands

Returns the content of the attribute commands.

set_commands

Set the content of the attribute commands. Expects an array reference as parameter.

get_bin

Returns the content of the bin attribute.

set_bin

Sets the content of the bin attribute. Expects a string as parameter.

get_pid

Returns the content of pid attribute as an integer.

is_infinite

Returns the content of the attribute is_infinite, returning true or false depending on this value.

reset_retries

Reset the retries of creating a new process of srvrmgr program, setting the attribute retries to zero.

shift_commands

Does a shift in the commands attribute.

Does not expects any parameter. Returns the shifted Siebel::Srvrmgr::Daemon::Command instance or undef if there is only one command left (which is not shifted).

This method is useful specially if the Daemon will keep executing commands, but setup commands (like load preferences) are not necessary to be executed again.

run

This is the method used to execute commands in srvrmgr program and must be overrided by subclasses of Siebel::Srvrmgr::Daemon or an exception will be generated.

normalize_eol

Expects an array reference as parameter.

Changes any EOL character to LF from each index value.

See perlport -> Issues -> Newlines for details on this.

DEMOLISH

This method is invoked before the object instance is destroyed. It does really few things like writting messages to the define configuration of Log::Log4perl logger. It will also log if ALRM, INT or PIPE signals were received.

Subclasses may want to override the method "private" _my_cleanup to do their properly laundry since the definition of _my_cleanup for this class is just to return true. _my_cleanup is called with a reference of a Log::Log4perl::Logger instance for usage.

SEE ALSO

AUTHOR

Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org<>

COPYRIGHT AND LICENSE

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/>.