nut-debian/docs/developer-guide.txt

174 lines
4.0 KiB
Plaintext
Raw Normal View History

2011-01-26 11:35:08 +02:00
:titles.underlines: "__","==","--","~~","^^"
Network UPS Tools Developer Guide
_________________________________
:Author: Russell_Kroll,_Arnaud_Quette,_Charles_Lepple_and_Peter_Selinger
:Author Initials: RK, AQ, CL & PS
Introduction
============
NUT is both a powerful toolkit and framework that provides support for Power
Devices, such as Uninterruptible Power Supplies, Power Distribution Units
and Solar Controllers.
This document intend to describe how NUT is designed, and the way to
develop new device drivers and client applications.
[[design]]
include::design.txt[]
[[developers]]
include::developers.txt[]
[[new-drivers]]
include::new-drivers.txt[]
[[sock-protocol]]
include::sock-protocol.txt[]
[[augeas]]
include::../scripts/augeas/README[]
2012-01-24 12:22:33 +02:00
[[devscan]]
include::../tools/nut-scanner/README[]
2011-01-26 11:35:08 +02:00
[[new-clients]]
include::new-clients.txt[]
[[net-protocol]]
include::net-protocol.txt[]
[[dev-tools]]
NUT developers tools
====================
NUT provides several tools for clients and core developers, and QA people.
2012-01-24 12:22:33 +02:00
[[dev-simu]]
2011-01-26 11:35:08 +02:00
Device simulation
-----------------
The dummy-ups driver propose a simulation mode, also known as 'Dummy Mode'.
This mode allows to simulate any kind of devices, even non existing ones.
Using this method, you can either replay a real life sequence,
<<dev-recording,recorded from an actual device>>, or directly interact
2022-07-10 10:23:45 +03:00
through `upsrw` or by editing the device file, to modify the variables'
values.
2012-01-24 12:22:33 +02:00
Here is an example to setup a device simulation:
- install NUT as usual, if not already done
2022-07-10 10:23:45 +03:00
- get a simulation file (`.dev`) or sequence (`.seq`), or generate one using
the <<dev-recording,device recorder>>. Sample files are provided in the
`data` directory of the NUT source. You can also download these from
the development repository, such as the
link:https://github.com/networkupstools/nut/raw/master/data/evolution500.seq[evolution500.seq].
- copy the simulation file to your sysconfig directory, like `/etc/nut`
or `/etc/ups`
2012-01-24 12:22:33 +02:00
- configure NUT for simulation (linkman:ups.conf[5]):
+
[dummy]
driver = dummy-ups
port = evolution500.dev
desc = "dummy-ups in dummy mode"
+
2022-07-10 10:23:45 +03:00
- now start NUT, at least `dummy-ups` and `upsd`:
2012-01-24 12:22:33 +02:00
+
$ upsdrvctl start dummy
$ upsd
+
- and check the data:
+
$ upsc dummy
...
+
2022-07-10 10:23:45 +03:00
- you can also use `upsrw` to modify the data in memory:
2012-01-24 12:22:33 +02:00
+
$ upsrw -s ups.status="OB LB" -u user -p password dummy
+
2022-07-10 10:23:45 +03:00
- or directly edit your copy of `/etc/nut/evolution500.seq`.
In this case, modification will only apply according to the `TIMER`
events and the current position in the sequence.
2012-01-24 12:22:33 +02:00
2022-07-10 10:23:45 +03:00
For more information, refer to linkman:dummy-ups[8] manual page.
2011-01-26 11:35:08 +02:00
[[dev-recording]]
Device recording
----------------
2022-07-10 10:23:45 +03:00
To complete `dummy-ups`, NUT provides a device recorder script called
`nut-recorder.sh` and located in the 'tools/' directory of the
2011-01-26 11:35:08 +02:00
NUT source tree.
2022-07-10 10:23:45 +03:00
This script uses `upsc` to record device information, and stores
2011-01-26 11:35:08 +02:00
these in a differential fashion every 5 seconds (by default).
Its usage is the following:
Usage: dummy-recorder.sh <device-name> [output-file] [interval]
For example, to record information from the device 'myups' every 10 seconds:
2012-06-01 16:55:19 +03:00
nut-recorder.sh myups@localhost myups.seq 10
2011-01-26 11:35:08 +02:00
2012-01-24 12:22:33 +02:00
During the recording, you will want to generate power events, such as power
2022-07-10 10:23:45 +03:00
failure and restoration. These will be tracked in the simulation files, and
be eventually be replayed by the <<dev-simu,dummy-ups>> driver.
2011-01-26 11:35:08 +02:00
NUT core development and maintenance
====================================
This section is intended to people who want to develop new core features,
or to do some maintenance.
include::macros.txt[]
[[roadmap]]
include::../TODO[]
[[nut-names]]
Appendix A: NUT command and variable naming scheme
==================================================
include::nut-names.txt[]
2012-01-24 12:22:33 +02:00
2022-07-10 10:23:45 +03:00
[[daisychain]]
Appendix B: NUT daisychain support notes
========================================
include::daisychain.txt[]
2012-01-24 12:22:33 +02:00
[[lib-info]]
2022-07-10 10:23:45 +03:00
Appendix C: NUT libraries complementary information
2012-01-24 12:22:33 +02:00
===================================================
include::../lib/README[]