NAME

ngeneric - LCFG new generic component.

DESCRIPTION

This component is intended for inclusion by other LCFG components. It provides a supporting framework including default methods and utility functions.

The components should include /usr/lib/lcfg/components/ngeneric and call the Dispatch function with the command line arguments. The lcfg component example shows how this is used in practice.

FUNCTIONS

Components can override the following functions:

Configure

This routine is called when the configure method, is invoked, as well as start and restart. ngeneric will have placed the values of all resources into the environment with variable names of the form LCFG_resource.

This routine should (re)create any necessary configuration files, and restart or signal any affected daemons. It is up to the component to determine which (if any) individual resources have changed and to minimize the reconfiguration appropriately (the template processor can help with this).

The component should call Fail() if the reconfiguration fails.

Start

This routine gets called when the start or restart methods are invoked, either manually, or at boot time. Configure will be called before Start leaving the resources available in the environment.

The component should override this routine to start any necessary daemoms.

Stop

This routine gets called when a component is stopped, either manually, or at shutdown time (or for a restart). The component should override this routine to stop any necessary daemons. When the routine is called, ngeneric will have placed the configuration (as saved at the last configure) into the environment.

Run

This routine gets called when the run method is invoked. The component should override this routine to perform any necessary operations. When the routine is called, ngeneric will have placed the configuration (as saved at the last configure) into the environment.

LogRotate

This routine gets called when the logrotate method is invoked, normally by the logrotate script when the logfile has been rotated. The component should override this routine to arrange for any running daemons to release the logfile. The environment contains the configuration saved at the last configure/start.

Suspend

Take any APM suspend action. The environment contains the configuration saved at the last configure/start. This routine is not protected by the normal semaphore.

Resume

Take any APM suspend action. The environment contains the configuration saved at the last configure/start. This routine is not protected by the normal semaphore.

Reset

Reset the error and warning status files. The existence of these files determines the status of the error and warning icons on the server status page. These files are deleted when the component starts.

Status

Display status information. The environment contains the configuration saved at the last configure/start. The default routine displays the values of the resources at the last configuration.

Log

Display log information. The environment contains the configuration saved at the last configure/start. The default routine displays the current logfile.

Monitor

Report monitoring information (by calling Notify) for the tag specified by the first argument. The environment contains the configuration saved at the last configure/start. The default routine reports an error.

GetSysInfo

Takes a single argument which is the sysinfo resource name. It sets an environment variable containing the resource value. e.g.

GetSysInfo "OS_NAME"
Debug "OS name is $LCFG_sysinfo_os_name"
GetSysPath

Takes a single argument which is the identifier name of the path and sets an environment variable which holds the path. e.g.

GetSysPath "LCFGBIN"
Debug "lcfgbin path is $LCFGBIN"

INPUT/OUTPUT

Components should avoid writing to STDOUT/STDERR since this may be lost, or may clutter the startup screen. The functions Debug(), Info(), Warn() and Fail() should be used to output short messages. By default, STDERR and STDOUT are redirected to the component logfile. The file descriptors 11 and 12 are opened on the original STDOUT and STDERR respectively for those cases where a method absolutely needs to write to these channels - for example to print a console prompt, or to perform a Log() or Status() method.

RESOURCES

LOCKING

ngeneric uses lcfglock to create a semaphore on all method calls (with the exception of those noted above). The method unlock can be used to force the removal of the lockfile.

LOG ROTATING

When the configure method is called, ngeneric will look for a logrotate configuration file in /usr/lib/lcfg/conf/component/logrotate. This is passed through the template proprocessor sxprof to allow per-machine configuration.

If the component does not provide a logrotate file, the ngeneric logrotate file is used. This rotates the component logfile at some default interval and calls the component logrotate method in the postrotate script. The default logrotate file allows extra parameters to be added directly from component resources using the logrotate resource. Eg:

foo.logrotate a b
foo.logrotate_a    daily
foo.logrotate_b    rotate 7

VARIABLES

ngeneric creates local shell variables beginning with "_". The following variables may be of general use:

_COMP

The name of the current component.

_DEBUG

Enables debugging information. Set by a -D option.

_DUMMY

Normally used to perform a dummy execution of the method call for testing. Set by a -d option.

_LOGFILE

The name of the log file.

_NOSTRICT

Method specific flag, normally used to force a less strict interpretation of method semantics. For example, the start method will exit silently if the component is already running, rather than fail.

_OKMSG

The message to be displayed when the method completes sucessfully. Components may append a string of the form {\tt (}{\em message}{\tt )} to this variable, to display additional status information when the method exits.

_QUIET

Disables unnecessary messages, including the "OK" message. This is useful when calling components from cron. Set by a -q option.

_STATUSFILE

The name of the status file.

_TIMEOUT

The lock timeout (in seconds). Set by a -t option.

_VERBOSE

Enables additional informational messages. Set by -v option.

AD-HOC METHODS

It is possible to create additional ad-hoc methods. These should be exported with names of the form Method_methodname, and they will be automatically called by the Dispatch function. Ad-hoc methods should arrange to call the Lock function if appropriate to prevent simultaneous method calls.

SEE ALSO

lcfg-example

An example component.

sxprof

The template processor.

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 137:

You can't have =items (as at line 144) unless the first thing after the =over is an =item