View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Alceu Rodrigues de Freitas Junior > Siebel-Srvrmgr > Siebel::Srvrmgr::Daemon



Annotate this POD


View/Report Bugs
Module Version: 0.29   Source  


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


    package MyDaemon;
    extends 'Siebel::Srvrmgr::Daemon';


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.



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.


Required attribute.

A string representing the time zone to be considered for all date/time values recovered from srvrmgr.

See DateTime::TimeZone all_names methods to list the available time zones that you can use. The on-liner below will show you them so you can find a proper value:

    perl -MDateTime::TimeZone -e 'foreach ( DateTime::TimeZone->all_names ) { print "$_\n" }'


An integer value that will raise an ALARM signal generated by alarm. The default value is 30 seconds. This is avoid leaving the daemon blocking forever waiting for something to read.

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


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.


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.


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.


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.


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.


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.



Returns the content of the attribute time_zone.


Returns the content of the attribute cmd_stack.


Getter for the clear_raw attribute.


Setter for the clear_raw attribute.


Returns the content of the alarm_timeout attribute.


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


Returns the value of the attribute child_runs.


Returns the content of the attribute use_perl.


Returns the value of the attribute ipc_buffer_size.


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


Returns the content of the attribute commands.


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


Returns the content of pid attribute as an integer.


Moose BUILD method is used by this class to install signal handlers for the following signals:

Also the method sets the environment variable SIEBEL_TZ if a time zone was set.

If the logging is set to DEBUG level all attribute values will be logged.


This method compares the number of commands defined in a instance of this class with the number of nodes passed as parameter.

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 returns undef.


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:

This method is also used internally through the _setup_commands method.


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.


Does a push in the commands attribute.

Expects as parameter a Siebel::Srvrmgr::Daemon::Command instance.


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. Expects as parameters a Siebel::Srvrmgr::Connection, or it will confess with an exception.


Expects an array reference as parameter.

Changes any EOL character to LF from each index value.

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


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

Optionally, it can receive as parameter a string representing the field delimiter that is expected. If received, the parameter will be used to create the instance.


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


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.


The following constants are available in this class:


All of them from the Fcntl module.



Alceu Rodrigues de Freitas Junior, <>


This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, <>

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

syntax highlighting: