Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
wsrtinfo:sensoralarmdescription [2008/07/03 12:08] – arnoschoenmakers | wsrtinfo:sensoralarmdescription [2009/08/24 07:11] (current) – arnoschoenmakers | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Description of sensorAlarm ====== | ====== Description of sensorAlarm ====== | ||
- | SensorAlarm pools the database filled by '' | + | Program '' |
===== Location of the code ===== | ===== Location of the code ===== | ||
- | The code for sensorAlarm can be found in CVS, in the module '' | + | The code for '' |
* '' | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
- | * '' | + | * '' |
* '' | * '' | ||
- | ===== Class layout | + | The program can be started by executing '' |
+ | |||
+ | ===== Component description | ||
==== alarmActions class ==== | ==== alarmActions class ==== | ||
Line 21: | Line 23: | ||
Logmessages are written to a logfile (see class '' | Logmessages are written to a logfile (see class '' | ||
+ | |||
+ | ==== sensorAlarm class ==== | ||
+ | |||
+ | This class is described in the file '' | ||
+ | |||
+ | The class reads the file holding the alarmconditions. At predefined intervals (to be set at startup of the main program) it will go through the list of alarmconditions and evaluate each condition to be true or false. In case a condition is true, an alarm must be raised. That involves: | ||
+ | * Executing the action that is described in the alarmconditions file | ||
+ | * Setting the alarmstatus of all the associated sensors to '' | ||
+ | |||
+ | Before obtaining the values, we first check if the sensor database values are recent enough to trust. This limit is set at 10 minutes, i.e., only if the database contains values less than 10 minutes old, the alarmconditions will be evaluated. All values are taken from the local MySQL database (the one running on wop10, that is). | ||
+ | |||
+ | In the '' | ||
+ | * In case of 1 or 2 measurements, | ||
+ | * in case of more than 2 samples: we determine the time interval between the latest two samples, and allow only values that are younger than this time interval multiplied by the amount of samples to take into account. This is done so that when the database is not filled for a while (e.g., due to maintenance, | ||
+ | * Of all the ' | ||
+ | |||
+ | ==== DBConnection class ==== | ||
+ | |||
+ | This class is the interface with a MySQL table. A default constructor connects to the local MySQL server and the database '' | ||
+ | |||
+ | |||
+ | ==== sensorAlarm main program ==== | ||
+ | |||
+ | The main program can be found in file '' | ||
+ | |||
+ | It handles the following things: | ||
+ | * Interpret commandline options. | ||
+ | * Creation of a logfile with a unique name in directory ''/ | ||
+ | * Daemonize itself so the user can close the shell after starting the program. | ||
+ | * Run a never-ending loop in which alarmconditions are checked at regular intervals. | ||
+ | |||
+ | === Command-line options === | ||
+ | |||
+ | To handle the commandline options we use the module [[http:// | ||
+ | -h, --help | ||
+ | -iINTERVAL, --interval=INTERVAL | ||
+ | Check interval time in seconds (prefer multiples of 60) | ||
+ | -fFILE, --inputfile=FILE | ||
+ | Name of input alarmconditions config file | ||
+ | -n, --nodaemonize | ||
+ | </ | ||
+ | The default interval is 120 seconds. The default alarmconditions config file is ''/ | ||
+ | |||
+ | === Logfile === | ||
+ | |||
+ | The logfile is written when the process is daemonized, only. Otherwise the log messages are written to to terminal. The logfile ends up in directory ''/ | ||
+ | |||
+ | Also, there is a file called '' | ||
+ | |||
+ | === The main loop === | ||
+ | |||
+ | Before we start the loop, we read the alarmconditions file, set up the database connection handlers for two databases (two, as the alarm flag needs to be updated both locally and on the WSRT MySQL server), and reset all alarms in these two databases. | ||
+ | |||
+ | In the main loop, we do the following things: | ||
+ | * Check if the local database can still be reached. If not, raise an alarm by sensing a email/SMS to observer. | ||
+ | * Check if there is recent (less than 10 minutes old) data in the database. If not, raise an alarm by sensing a email/SMS to observer. | ||
+ | * Check all alarmconditions. If an alarmcondition is met, it will be reported and acted upon only once. If the alarmcondition is over, this will be reported as well (and the alarm flag in the database will be retracted). | ||
+ | * Wait until the next requested checktime. | ||
+ | |||
+ | ==== Used Python modules ==== | ||
+ | |||
+ | For '' | ||
+ | * For string handling: '' | ||
+ | * For date and time issues: '' | ||
+ | * For system calls and such : '' | ||
+ | * For signal handling (timeouts): '' | ||
+ | * For parsing commandline options: '' | ||
+ | * For MySQL connections: | ||
+ | |||
+ | |||
+ | ==== The configuration file ==== | ||
+ | |||
+ | The '' | ||
+ | |||
+ | ... | ||
+ | CONSwarm > 27.0 # 5 # sendMail obs ' | ||
+ | CONSwarm > 30.0 # 5 # sendMail obs ' | ||
+ | CONSwarm < 15.0 # 5 # sendMail obs ' | ||
+ | ... | ||
+ | Sup-He-RT0 + Ret-He-RT0 < 15 # 5 # sendMail stiepel ' | ||
+ | Sup-He-RT1 + Ret-He-RT1 < 15 # 5 # sendMail stiepel ' | ||
+ | Sup-He-RT2 + Ret-He-RT2 < 15 # 5 # sendMail stiepel ' | ||
+ | ... | ||
+ | </ | ||
+ | \\ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
Line 33: | Line 127: | ||
===== Alarmconditions ===== | ===== Alarmconditions ===== | ||
- | This is the Alarm conditions table that is used in the software. It originates from the file ''/ | + | This is the Alarm conditions table that is used in the software. It originates from the file ''/ |
^ Sensor ^ Type/Unit^ Alarm Condition(s) ^ Nr. of samples ^ Mail/SMS who ^ (Software) Action ^ | ^ Sensor ^ Type/Unit^ Alarm Condition(s) ^ Nr. of samples ^ Mail/SMS who ^ (Software) Action ^ |