Skip to content
/ fty-nut Public

Translate NUT (Network UPS Tools) protocol to 42ity-proto

License

Notifications You must be signed in to change notification settings

42ity/fty-nut

Repository files navigation

fty-nut

fty-nut is a family of agents responsible for 42ITy interaction with NUT (see [http://www.networkupstools.org]) including both collection of device data and configuration of NUT to monitor new devices as assets are created.

To build, run:

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=usr -DBUILD_TESTING=On ..
make
sudo make install

Compilation of fty-nut creates two binaries fty-nut and fty-nut-configurator, which are run by systemd service.

How to run

To run fty-nut project:

  • from within the build/ tree, run:
./agent/fty-nut --mapping-file <path_to_mapping_file>
./agent/fty-nut --mapping-file /usr/share/fty-common-nut/mapping.conf

./fty-nut-configurator/fty-nut-configurator
  • from an installed base, using systemd, run:
systemctl start fty-nut
systemctl start fty-nut-configurator

Configuration file

To configure fty-nut, a two configuration files exist: fty-nut.cfg and fty-nut-configurator.cfg. Both contain standard configuration directives, under the server sections. Additional parameter

  • fty-nut.cfg
    • polling_interval - polling interval in seconds. Default value: 30 s

Mapping file

Mapping between NUT and fty-nut is saved in:

/usr/share/fty-common-nut/mapping.conf

State File

The fty-nut-configurator state file is located in

/var/lib/fty/fty-autoconfig/state

Architecture

Overview

fty-nut is composed of three actors:

  • fty_nut_server - server actor
  • alert_actor - actor handling device alerts and thresholds coming from NUT
  • sensor_actor - actor handling sensor measurements coming from NUT.

fty-nut-configurator is composed of 1 actor:

  • fty_nut_configurator_server - server actor which configures nut-server (upsd) based on results from nut scanner

fty-nut-command is composed of 1 actor:

  • fty-nut-command - bridge forwarding commands from Malamute to NUT devices

Protocols

Publishing Metrics

  • sensor_actor produces metrics from sensors connected to power devices on the shared memory (fty_shm).

Example: humidity.default@sensor-73758544 = 50.40% temperature.default@sensor-73758544 = 24.90C status.GPI1@sensorgpio-88301617 = closed

alerts for sensors are managed by fty-alert-engine (environmental sensors) and fty-alert-flexible (GPI sensors)

  • fty_nut_server produces metrics on the shared memory (fty_shm).

Example: status.outlet.2@ups-52c9a13e.

  • fty-nut-command doesn't produce metrics.

Publishing Alerts

  • alert_actor produces metrics on FTY_PROTO_STREAM_ALERT_SYS.
stream=_ALERTS_SYS
sender=bios-nut-alert
subject=outlet.group.1.voltage@epdu-54/OKG@epdu-54
D: 17-11-13 15:05:57 FTY_PROTO_ALERT:
D: 17-11-13 15:05:57     aux=
D: 17-11-13 15:05:57     time=1510560758
D: 17-11-13 15:05:57     ttl=90
D: 17-11-13 15:05:57     rule='outlet.group.1.voltage@epdu-54'
D: 17-11-13 15:05:57     name='epdu-54'
D: 17-11-13 15:05:57     state='RESOLVED'
D: 17-11-13 15:05:57     severity='OK'
D: 17-11-13 15:05:57     description='outlet.group.1.voltage is resolved'
D: 17-11-13 15:05:57     action=''
  • fty-nut-command doesn't produce alerts.

Consuming Assets

  • fty_nut_server, sensor_actor and alert_actor listen on FTY_PROTO_STREAM_ASSETS stream.
  • fty-nut-command doesn't consume assets.

Mailbox Requests

fty-nut-command has a fty-common-messagebus interface for power commands.