Chapter 6. LMS Daemon

Table of Contents
6.1. Basics
6.1.1. Requirements
6.1.2. Installation
6.1.3. Configuration
6.1.4. Starting
6.2. Modules
6.2.1. Modules list
6.2.2. System
6.2.3. Payments
6.2.4. Notify
6.2.5. Ggnotify
6.2.6. Cutoff
6.2.7. DHCP
6.2.8. Hostfile
6.2.9. Traffic
6.2.10. Tc (HTB)
6.2.11. Dns
6.2.12. Ethers
6.2.13. Oident
6.2.14. Pinger

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 or sqlite shared library

  • libdl shared library (present in every modern distribution)

  • C compiler (gcc)

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)
  --with-sqlite         enables using of SQLite database (disabled)
  --prefix=PREFIX       program and modules install directory (/usr)
  --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 or --with-sqlite) and location of libraries supplied with database (--incdir, --libdir). You can use only one database. If you will change database, you have to recompile your daemon. It's also possible to force daemon to use configuration files instead of database. He can't use both of them in the same time, you'll need to choose that before compilation.
# ./configure --with-pgsql --libdir=/usr/pgsql/lib --incdir=/usr/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

For daemon and modules configuration is destined menu Reload -> Configuration 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:

-h host           host where is instaled database (default: localhost)
-d db_name        database name (default: lms)
-u user           database user name (default: lms)
-p password       database password (default: empty)
-H hostname       name of host where daemon runs. By default is assumed name returned by
                  hostname command, but it can be overwrited. That name must according
                  with name specified in hosts configuration
- c command       shell command to run before every database connection (default: empty)
-i "instance[ ...]" list of instances for reload. Other instances will be ignored
-q                do reload and exit
-f                run in foreground (don't fork)
-v                prints version and copyright info
Database connection options are readed also from shell variables: LMSDBPASS, LMSDBNAME, LMSDBUSER, LMSDBHOST, LMSDBPORT.
Note

List of instances contains instances names separated with spaces.

Daemon configuration is composed of hosts (that makes possible to configure and reload of daemons installed on different hosts/routers) and configuration sections called as instances.

Instance, beside config modules params, must contain primary options as:

  • Name

    Instance name unique within each host.

    Example: system

  • Priority

    Priority number, that define instances reload sequence.

    Example: 10

  • Module

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

    Example: /usr/lib/system.so

  • Crontab

    Module execution time specified in crontab style. All data must be numeric. Following example cause instance execution at 5 minutes interval between 8 and 18 hour every day. If crontab is empty instance will be reloaded only while reload. Default: empty.

    Example: */5 8-18 * * *

Any configuration change do not require daemon restart.

6.1.4. Starting

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

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