# How to specify some EPICS records' fields

Prerequisites:

* [Installation how-to](./install_update_remove_how_to.md#how-to-install).
* [Firewall how-to for SSH](./firewall_how_to.md#firewall-configuration-for-ssh).
* [Firewall how-to for EPICS](./firewall_how_to.md#standard-firewall-configuration-for-epics).
* [SSH how-to](./ssh_how_to.md).
* [`.cmd` and `.substitutions` how-to](./cmd_and_sub_how_to.md)
* [Security how-to](./security_how_to.md)
* [Run SSH Monitor how-to](./run_ssh_monitor_how_to.md)
* [Custom shell instructions how-to](./custom_shell_instructions_how_to.md)

You might want to customize some {{record}}s
associated to the {{shell_instruction}}s specified in the {{substitutions}} files
(e.g. `myTargetMonitoringTop/iocBoot/iocMyTargetMonitoring/target1.substitutions`).
To do so,
you can add some {{macro}}s associated to the following common {{EPICS}} fields:

* `DESC`
* `EGU`
* `HIHI`
* `HHSV`
* `HIGH`
* `HSV`
* `LOLO`
* `LLSV`
* `LOW`
* `LSV`
* `DRVL`
* `DRVH`
* `HOPR`
* `LOPR`
* `PREC`
* `HYST`
* `ADEL`
* `MDEL`

E.g., from the example in the [custom shell instructions how-to](./custom_shell_instructions_how_to.md),
let's configure an alarm over the CSS monitoring
(let's also configure an engineering unit `EGU`, and a description `DESC`),
in case it eats up too much CPU:

```{code} bash
$ vi myTargetMonitoringTop/iocBoot/iocMyTargetMonitoring/custom_monitoring.substitutions
    > ...
    >         # scalar instruction 3 used to extract CPU usage of CSS (Control System Studio)
    >         # the result of this instruction is stored in the record called "${PREFIX}${CATEGORY}${PV_NAME_SCALAR_3}"
    >         PV_NAME_SCALAR_3 = "cpu_usage_css"
    >         SCALAR_3_INSTRUCTION = "ps -eo %cpu,args | grep css | awk '{print $1}' | paste -sd+ - | bc"
    >         LOAD_SCALAR_3 = ""
  + >         DESC_SCALAR_3 = "monitor the CPU usage of CSS"
  + >         LOAD_DESC_SCALAR_3 = ""
  + >         EGU_SCALAR_3 = "%"
  + >         LOAD_EGU_SCALAR_3 = ""
  + >         HIGH_SCALAR_3 = "80"
  + >         LOAD_HIGH_SCALAR_3 = ""
  + >         HIHI_SCALAR_3 = "90"
  + >         LOAD_HIHI_SCALAR_3 = ""
  + >         HSV_SCALAR_3 = "MINOR"
  + >         LOAD_HSV_SCALAR_3 = ""
  + >         HHSV_SCALAR_3 = "MAJOR"
  + >         LOAD_HHSV_SCALAR_3 = ""
    > ...
```

```{seealso}
You will find more details about the supported EPICS {{record}}s fields
in the [`.cmd`, `.template` and `.substitutions` explanations](../../explanations/cmd_and_template_and_sub_explanations.md).
```

## SCAN field

The `SCAN` {{field}} cannot be changed per {{record}}/{{shell_instruction}}.
Instead, the `SCAN` {{macro}} is specified in a {{SSH_Monitor}} {{substitutions}} file
only once per `CATEGORY` {{macro}} and not once per {{record}} / {{shell_instruction}}
(see [the `.cmd`, `.template` and `.substitutions` explanations](../../explanations/cmd_and_template_and_sub_explanations.md)
for more details about how and why).

If you want to override the default `SCAN` value,
(e.g. when loading
[a default SSH Monitor `.substitutions` file](sshmonitor-directory-gitlab-url:sshmonitorApp/db)),
then the recommended way is to load the {{SSH_Monitor}} {{substitutions}} file
(from your {{cmd}} file)
with the `SCAN_MACRO` {{macro}}.
E.g. like so:

```{code} bash
dbLoadTemplate("${TOP}/db/example_monitoring.substitutions", "PREFIX_MACRO=${PREFIX}, SSH_OPTS_AND_ARGS_MACRO=${SSH_OPTS_AND_ARGS}, SCAN_MACRO=1 hour")
```

In this case,
the default `SCAN` value will be overwritten by the content of the `SCAN_MACRO` {{macro}},
i.e. it will be set to `1 hour`.

