LMS - LAN Management System 1.11-git
Prev |  | Next

# Chapter 6. LMS Daemon

# 6.1. Basics

This C daemon was developed to aid management of your services. It's responsible for starting appropriate modules, each performing specific task. Each module makes configuration files based on its template and data from LMS database and manages (restarting) selected services on a server. Modules can also collect statistics, check hosts activity, account payments or notify debtors about their charges.

## 6.1.1. Requirements

LMS Daemon requires:

- LMS user interface installation

- `libmysqlclient` shared library (included in full MySQL installation or respective "devel" package) or `libpq` shared library in case of PostgreSQL database use.

- `libdl` shared library (present in every modern distribution)

- C compiler (gcc-2.95.x or higher)

- ggnotify module needs `libgadu` library and header files

- parser module needs `flex` and `bison` (version 1.875 or newer).

## 6.1.2. Installation

You have to setup some configure options prior to compilation, that can be listed with --help flag of `./configure` script (default values shown in brackets):

      --help                help
      --enable-debug0       SQL queries logging (disabled)
      --enable-debug1       events logging (disabled)
      --with-pgsql          enables using of PostgreSQL database (disabled)
      --with-mysql          enables using of MySQL database (enabled)
      --prefix=PREFIX       program and modules install directory (/usr/local)
      --lmsbindir=DIR       sets location of target LMS binaries (PREFIX/lms/bin)
      --lmslibdir=DIR       sets location of target LMS modules (PREFIX/lms/lib)
      --libdir=DIR          location of database libraries (/usr/lib)
      --incdir=DIR          location of database header files (/usr/include)
      --inifile=FILE        configuration file - disables online configuration

It's required to choose one database which you will use (--with-mysql or --with-pgsql) and location of libraries supplied with database (--incdir, --libdir). You can use only one database. If you change database, you have to recompile your daemon. It's also possible to force daemon to use configuration files instead of database. It can't use both files and db at the same time, you'll need to choose either before compilation.

    # ./configure --with-pgsql --libdir=/usr/local/pgsql/lib --incdir=/usr/local/pgsql/include

After that you can compile and install (put daemon in directory given with --prefix option):

    # make && make install

Compiled modules (files with `.so` extension), found in directory `modules/module_name` will be moved to directory PREFIX/lms/lib. Main program goes to PREFIX/lms/bin.

## 6.1.3. Configuration

Configuration for daemon and modules configuration can be edited through Configuration -> Daemon menu in LMS-UI. Modules configuration is described later, in separate chapters concerning each module. Basic daemon parameters and data for connection to database should be specified as command line options, according to following listing:

    --dbhost -h host           host database is available (default: localhost)
    --dbname -d db_name        database name (default: lms)
    --dbuser -u user           database username (default: lms)
    --dbpass -p password       database password (default: empty)
    --hostname -H hostname     host name where daemon runs; name returned by hostname command is taken
                               as default but it can be overwritten; that name must correspond to the
                               one specified in hosts configuration in UI
    --pidfile -P pid_file      pidfile where daemon write pid (default: none)
    --ssl -s                   use SSL connection (default: disabled)
    --command -c command       shell command to execute before every database connection (default: empty)
    --instance -i "instance[ ...]" list of instances to reload; other instances will be ignored
    --reload -q                do reload and exit
    --reload-all -r            do reload of all instances (including those with specified crontab) and exit
    --foreground -f            run in foreground (don't fork)
    --version -v               prints version and copyright info

Database connection options can be also read from enviroment variables: LMSDBPASS, LMSDBNAME, LMSDBUSER, LMSDBHOST, LMSDBPORT.

| List of instances should contain instance names separated with spaces. Spaces in instance name should be replaced by '\s' sequence, i.e. `lmsd -i "my\sinstance"`.

Daemon configuration is divided into hosts (which makes possible to configure and reload several different daemons installed on numerous hosts/routers) and configuration sections called as instances.

Instance configuration, besides config modules params, have to contain the following primary options:

- Name

  Instance name, unique for each daemon (host where daemon is running).

  Example: system

- Priority

  Priority number, which defines instances reload sequence.

  Example: 10

- Module

  Module name (with or without .so extension). If path is not specified daemon will search module in PREFIX/lms/lib directory, where modules are being placed after "make install".

  Example: /usr/lib/system.so

- Crontab

  Module execution time specified in crontab style. All data must be numeric. Following example executes instance each 5 minutes between 8 and 18 hour every day. If crontab is empty, instance will be reloaded only with UI reload. Default: empty.

  Example: */5 8-18 * * *

Configuration changes does not require restarting daemon.

## 6.1.4. Starting

By default program runs in daemon mode. In this mode configuration and services reload is performed on demand using 'Reload' menu in LMS-UI. Reload order and configuration checks (especially instances list and configuration of them) is done each minute. When daemon detects reload order, it runs all enabled instances. Instances with crontab specified will be executed at scheduled time.

Other way to run daemon is disposable reload using '-q' command line option. This is useful for tests, and in conjunction with '-i' option allows to run selected instances regardless of crontab entries for the rest of instances.

Prev | Home | Next
Examples of use |  | Modules