Skip to content

Commit

Permalink
doc/nixos: add phoebus-alarm guide
Browse files Browse the repository at this point in the history
  • Loading branch information
minijackson committed Oct 18, 2023
1 parent c519cc1 commit 4aa2b77
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ website:
contents:
- ./nixos/tutorials/archiver-appliance.md
- section: User Guides
contents:
- ./nixos/guides/phoebus-alarm.md
- section: Explanations
- section: References
contents:
Expand Down
40 changes: 40 additions & 0 deletions doc/nixos/guides/_pre-requisites.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Pre-requisites

- Having a NixOS machine with a flake configuration.

If you're not sure how to do this,
you can follow the [Archiver Appliance tutorial],
which is a good introduction on how to make a NixOS VM.

If you have such a configuration,
make sure that:

- You have the `epnix` flake input
- You have added `epnix` as an argument to your flake outputs
- You have imported EPNix' NixOS module

For example:

``` {.diff filename="flake.nix"}
{
# ...
+ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";

# ...
outputs = {
self,
nixpkgs,
+ epnix,
}: {
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
modules = [
+ epnix.nixosModules.nixos

# ...
];
};
};
}
```

[Archiver Appliance tutorial]: ../tutorials/archiver-appliance.md
124 changes: 124 additions & 0 deletions doc/nixos/guides/phoebus-alarm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
title: Phoebus Alarm single server setup
---

The Phoebus Alarm collection of services enables monitoring EPICS PVs,
and report alarms in a server.
Phoebus clients can then contact this server,
to see a list of current alarms, earlier alarms, and so on.

This guide focuses on installing and configuring these services on a single server.

For more information about these services:

- [Official Alarm Server documentation].
- [README of Alarm Server]. For your information, don't follow this guide on NixOS.
- [Official Alarm Logging Service documentation].

The Phoebus Alarm Logging Service can also be called the Phoebus Alarm Logger.

{{< include _pre-requisites.md >}}

[Official Alarm Server documentation]: https://control-system-studio.readthedocs.io/en/latest/services/alarm-server/doc/index.html
[README of Alarm Server]: https://github.com/ControlSystemStudio/phoebus/blob/master/app/alarm/Readme.md
[Official Alarm Logging Service documentation]: https://control-system-studio.readthedocs.io/en/latest/services/alarm-logger/doc/index.html

# Enabling the Phoebus Alarm services

To enable the Phoebus Alarm server and the Phoebus Alarm Logger,
add this to your configuration:

``` nix
{config, ...}: let
kafkaPort = toString config.services.apache-kafka.port;
# Replace this with your machine's IP address
# or DNS domain name
ip = "192.168.1.42";
kafkaSock = "${ip}:${kafkaPort}";
in {
# The Phoebus Alarm server also enables the Phoebus Alarm Logger
services.phoebus-alarm = {
enable = true;
openFirewall = true;
settings."org.phoebus.applications.alarm/server" = "${kafkaSock}";
};
# Tell Apache Kafka to listen on this IP address
# If you don't have a DNS domain name, it's best to set a specific, non-local IP address.
services.apache-kafka.extraProperties = ''
listeners=PLAINTEXT://${kafkaSock}
'';
# Elasticsearch, needed by Phoebus Alarm Logger, is not free software (SSPL | Elastic License).
# To accept the license, add the code below:
nixpkgs.config.allowUnfreePredicate = pkg:
builtins.elem (lib.getName pkg) [
"elasticsearch"
];
}
```

# Configuring topics

The Phoebus Alarm system uses "topics" as a way of grouping alarms.
These topics are the available roots of your alarm tree.
You need to synchronize the topic names between:

- Phoebus Alarm Server
- Phoebus Alarm Logger
- Phoebus graphical clients

Changing the topic names in the Phoebus Alarm Server NixOS modules automatically creates them.

::: callout-warning
Currently, the Phoebus Alarm Server doesn't support several topics.
:::

For example,
if you want to have the topic `Project`,
add this configuration to the server:

``` nix
{config, ...}: let
topics = ["Project"];
in {
services.phoebus-alarm-server = {
# ...
settings = {
# ...
"org.phoebus.applications.alarm/config_names" = topics;
};
};
services.phoebus-alarm-logger.settings.alarm_topics = topics;
}
```

For the Phoebus graphical client,
add this configuration:

``` ini
# config_name is only used in the Phoebus graphical client
org.phoebus.applications.alarm/config_name = Project
org.phoebus.applications.alarm/config_names = Project
```

# Configuring the address list

If you want to limit the IOCs reachable by the Phoebus Alarm Server,
use this option:

``` nix
{
services.phoebus-alarm-server = {
# ...
settings = {
# ...
# The Phoebus Alarm Server will only have access to these IOCs
"org.phoebus.pv.ca/addr_list" = ["192.168.1.5" "192.168.1.42"];
"org.phoebus.pv.ca/auto_addr_list" = false;
};
};
}
```

0 comments on commit 4aa2b77

Please sign in to comment.