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.

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.

clear_raw

A boolean attribute that defines if the raw data recovered from srvrmgr should be kept or discarded as soon as possibly.

Having a default value of true, it should help reducing memory usage or debugging, if set false.

field_delimiter

This is a single character attribute. It tells the Daemon class to consider a field delimiter, if such options was set in the srvrmgr program. If this option is used but this attribute is not set accordinly, parsing will probably fail.

Since this attribute should be defined during Daemon object instance, it is read-only.

has_lock

Optional parameter.

This is a boolean attribute (in the sense of Perl) that identifies if the Daemon needs to use a lock or not. Default is false.

Using a lock is useful to avoid two instances of the same Daemon running. See also lock_dir attribute.

lock_dir

Optional parameter.

This parameter is used to determine the location in the filesystem to create the lock file.

Expects a string as parameter. The directory must be readable and writable to the user running the Daemon.

It defaults to the "home" directory of the user. The sense of "home" is the following as defined by the platform:

This attribute is lazy and defined by the _define_lock_dir "private" method.

  • Microsoft Windows: $ENV{HOMEDIR}

  • UNIX-like: $ENV{HOME}

cmd_stack

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.

METHODS

get_cmd_stack

Returns the content of the attribute cmd_stack.

get_field_del

Getter for the field_delimiter attribute.

clear_raw

Getter for the clear_raw attribute.

set_clear_raw

Setter for the clear_raw attribute.

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.

check_cmd

This methods expects as parameter a string representing a srvrmgr command.

The command will be checked and if considered insecure, an exception will be raised.

Commands considered secure are:

  • load preferences

  • list <anything>

  • exit

  • set delimiter

This method is also used internally through the _setup_commands method.

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. Subclasses should invoke Moose super to when doing override because this implementation will apply lock control when appropriate.

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.

create_parser

Returns an instance of a Siebel::Srvrmgr::ListParser class.

get_lock_file

Returns the complete path to the lock file as a string.

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.

CONSTANTS

The following constants are available in this class:

LOCK_EX
LOCK_NB

All of them from the Fcntl module.

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