Alarm Logging with TAlh

Home
The -l Command Line Switch
Alarm Logging to Log-Files - the FileAlarmLogger Plugin
    Log File Names
Alarm Logging to a Postgresql Database - the PsqlAlarmLogger Plugin

TAlh uses Qt plugins to log alarms. See the section Installing and Running TAlh for plugin location.

The Logging Command Line Switch

The command line switch -l specifies which plugin is loaded and which parameters are passed to the plugin.

If no -l switch is given alarm logging is not available. A warning message is displayed.

The value of the -l switch may contain a list of comma-separated items or white-space separated items enclosed in double-quotes. The first item is taken as a plugin name prefix. The other list items must be name/value pairs of the format <name>=<value>. They are comma-catenated and the resulting parameter string is passed to the plugin.

If the value of the -l switch contains neither comma nor white space the value is taken as a plugin name prefix.

TAlh  searches for a logging plug-in with the name <prefix>AlarmLogger in the operating system specific plugin directory.

The TAlh Instance Name

Each running instance of TAlh has an "instance name". By default, the instance name is the base name of the configuration file name, i.e. the sub-string of the configuration file name before the first dot.
The TAlh instance name can be overridden with the command line switch --instance.

Alarm Logging to Log-Files

The TAlh distribution contains a plugin "FileAlarmLogger" which logs to files in a format very similar to alh. Both an alarm log file and an operator actions log file are written.

The value of the -l switch contains one or two items:
  1. "File"   - the plugin name prefix
  2. optional log path info of the form "path=<info>".    The "path=" part is optional.
If no log path info is given, the log files will be written to the directory which contains the TAlh configuration file.

At midnight (local time) the FileAlarmLogger plugin will close the log file set and open a new one with updated date in the name.

Log File Names and Log Directories

The alarm log file has the form:
    <prefix>.log.<date>.
The operator actions log file has the form:
   <prefix>.opmod.<date>.

The <prefix> is set to the TAlh instance name (see above).

Examples for TAlh instance name talh3:
The switch
-l File,default   or -l File
on Dec 10, 2016 will result in logfiles
talh3.log.2016-12-10  and talh3.opmod.2016-12-10.
The log files will be created in the directory which contains the configuration file.

The switch
-l File,/usr1/project/talh/log/
on Dec 11, 2016 will result in log files
talh3.log.2016-12-11  and talh3.opmod.2016-12-11
The log files will be created in the directory /usr1/project/talh/log/


Alarm Logging to a Postgresql Database


The TAlh distribution contains a plugin "PsqlAlarmLogger" which logs to a relational PostgreSQL database.

The value of the -l switch must contain "Psql" as the first item.
This is followed by the database parameters which can be provided

a) either explicitly as a  set of  name/value pairs:

server=<database server>
port=<tcp/ip port>
dbname=<database name>
schema=<database schema>
table=<database table>
user=<database login name>
user2=<database login password>
cash=<list limit>*

or

b) by specifying a file which contains the name/value pairs:

cfg=<file path>

* The cash parameter sets a limit for the length of logging sets which are transferred to the logger several times per second. If the logging set has more than <list limit> alarms, the alarms are cashed, i.e. the list is analyzed and alarms originating from the same PV are dropped with the exception of the last one. The number of dropped alarms is logged.
This reduces the susceptilbility of TAlh to alarm storms.

Command line examples:
-l Psql,server=dbs.triumf.ca,dbname=operations,schema=alarmlog,table=cyclotron,user=rolf,user2=......,cash=100.
-l Psql,cfg=/usr1/project/talh/psql.cfg

The plugin logs both alarms and operator actions into a database table which is created with the following SQL statement:
CREATE TABLE alarmlog.test
(
    alarmtime timestamp NOT NULL,
    logtype_id integer NOT NULL,
    pv varchar(100),
    sevr varchar(10),
    acks varchar(10),
    state varchar(50),
    ackt varchar (10),
    val varchar (50),
    ioctime bigint,
    msg varchar(500),
    instance varchar(100),
    CONSTRAINT fk_logtype_id FOREIGN KEY (logtype_id) REFERENCES alarmlog.logtype (logtype_id)
) with OIDS;

The logtype_id column in this table is a foreign key which is provided by a database table which is created by the following SQL statement
CREATE TABLE alarmlog.logtype
(
    logtype_id integer NOT NULL,
    logtype varchar(100) NOT NULL,
    CONSTRAINT pk_logtype_id PRIMARY KEY (logtype_id)
) with OIDS;

The  PsqlAlarmLogger plugin uses the following content of the logtype table:
# select * from logtype order by logtype_id;
 logtype_id |       logtype
------------+---------------------
          1 | alarm data
          2 | operator actions
          3 | alarm handler admin
(3 rows)




back to Table of Contents