# How to install and configure an alarm server for SSH Monitor

A comprehensive guide/documentation about alarm servers is far beyond the scope of this project.
Especially since there are several ways of doing so with {{EPICS}} ("Alarm
Handler", "CSS BEAST", "Phoebus Alarm Server", etc).

But here are some useful links about the major ways of doing alarm servers with
{{EPICS}}:

* [Phoebus readthedocs alarm
  search](https://control-system-studio.readthedocs.io/en/latest/search.html?q=alarm&check_keywords=yes&area=default)
  * [Phoebus GitHub](https://github.com/ControlSystemStudio/phoebus)
  * [Phoebus readthedocs](https://control-system-studio.readthedocs.io/en/latest/)
  * [Phoebus readthedocs alarm
    server](https://control-system-studio.readthedocs.io/en/latest/services/alarm-server/doc/)

* [CSS Alarm System](http://cs-studio.sourceforge.net/docbook/ch14.html)
  * [CSS homepage](http://controlsystemstudio.org/)
  * [CSS GitHub](https://github.com/ControlSystemStudio/cs-studio)
  * [CSS Guide](http://cs-studio.sourceforge.net/docbook/)

* [Alarm Handler](https://epics.anl.gov/extensions/alh/index.php)
  * [Alarm Handler user
    guide](https://epics.anl.gov/EpicsDocumentation/ExtensionsManuals/AlarmHandler/alhUserGuide-1.2.35/ALHUserGuide.html)

* [EPICS trainings](https://epics-controls.org/resources-and-support/documents/training/)

<!--
### monitor-reactor

🚧 **WIP**/**TODO** 🚧

However, a simple and minimalist tool can be used to set up a very straightforward alarm server:
[monitor-reactor](https://gitlab.com/sshmonitor/monitor-reactor#monitor-reactor-example-as-an-alarm-server)
-->

<!--
NOT UP TO DATE with {{SSH_Monitor}} v2

THIS SECTION NEEDS TO BE UPDATED

**Note**: I **strongly** suggest you to modify the monitor-reactor e-mail script example, e.g. with
[this one](../../examples/mailto_admin_in_charge.sh) in order for it to be adapted with the goals of
this project.

**Note**: As suggested in
[monitor-reactor](https://gitlab.com/sshmonitor/monitor-reactor#for-all-the-pvs-of-an-ioc), you
can generate a ["monitoring file"](https://gitlab.com/sshmonitor/monitor-reactor#monitoring-file)
(for `monitor-reactor.sh` to parse it). In this project, you don't need to monitor *all* the {{PV}}s of
your {{IOC_program}}, just a sub-set. In order to monitor only the relevant
{{PV}}s of this project, instead of following the procedure described in
[monitor-reactor](https://gitlab.com/sshmonitor/monitor-reactor#for-all-the-pvs-of-an-ioc), you
can follow the below procedure:

* Start an {{IOC_program}}.
* In its {{IOC_shell}}, copy the output of the `dbl` command and paste
  it into a new temporary file : `/tmp/dbl`.
* Then look at the [`dbl_to_react_monit.sh`](../../examples/dbl_to_react_monit.sh) script and change
  its top variables according to your needs. E.g.:

```{code} bash
  > #!/bin/sh
  >
  > ...
  >
  > ########################################
  > # /!\ CHANGE THE FOLLOWING VARIABLES /!\
  > ########################################
  >
~ > DBL="/tmp/dbl"
~ > MONIT_REACT="/path/to/target1-monit.react" # change this monitoring file for each IOC program
~ > EMAIL_SCRIPT="\/path\/to\/mailto-target1-admin.sh" # escape the '/' chars for the below sed cmd
  >
  > ########################################
  > ...
```

* Execute your modified version of [`dbl_to_react_monit.sh`](../../examples/dbl_to_react_monit.sh).
* The goal of this script is to generate a single 
  ["monitoring file"](https://gitlab.com/sshmonitor/monitor-reactor#monitoring-file) for each 
  {{IOC_program}} (i.e. for each monitored {{target}}).
* Repeat the previous steps for each {{IOC_program}} remaining.
* Finally you can run monitor-reactor over every monitoring file created.

**Warning**: monitor-reactor is a {{CA}} client, so don't forget the
{{EPICS}} {{CA}} environment variables (`EPICS_CA_ADDR_LIST` and
`EPICS_CA_AUTO_ADDR_LIST`) when running it. E.g.:

```{code} bash
$ EPICS_CA_ADDR_LIST="192.168.1.42:5066 192.168.1.42:5067" EPICS_CA_AUTO_ADDR_LIST=NO ./monitor-reactor.sh target1-monit.react
```
-->
