1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
|
Desc: Network protocol info
File: protocol.txt
Date: 18 February 2004
Auth: Russell Kroll <rkroll@exploits.org>
As of May 2002, this protocol now has an official port number from IANA,
which is 3493. The old number (3305) was a relic of the original code's
ancestry, and conflicted with other services. Version 0.50.0 and up
use 3493 by default.
This protocol runs over TCP. UDP support was dropped in July 2003. It
had been deprecated for some time and was only capable of the simplest
query commands as authentication is impossible over a UDP socket.
Old command removal notice
==========================
Before version 1.5.0, a number of old commands were supported. These
have been removed from the specification. For more information, consult
an older version of the software.
Command reference
=================
Multi-word elements are contained within "quotes" for easier parsing.
Embedded quotes are escaped with backslashes. Embedded backslashes are
also escaped by representing them as \\. This protocol is intended to
be interpreted with parseconf or something similar.
GET
===
Retrieve a single response from the server.
Possible sub-commands:
NUMLOGINS
---------
Form: GET NUMLOGINS <upsname>
GET NUMLOGINS su700
Response: NUMLOGINS <upsname> <value>
NUMLOGINS su700 1
<value> is the number of clients which have done LOGIN for this UPS.
This is used by the master upsmon to determine how many clients are
still connected when starting the shutdown process.
This replaces the old "REQ NUMLOGINS" command.
UPSDESC
-------
Form: GET UPSDESC <upsname>
GET UPSDESC su700
Response: UPSDESC <upsname> "<description>"
UPSDESC su700 "Development box"
<description> is the value of "desc=" from ups.conf for this UPS. If it
is not set, upsd will return "Unavailable".
This can be used to provide human-readable descriptions instead of a
cryptic "upsname@hostname" string.
VAR
---
Form: GET VAR <upsname> <varname>
GET VAR su700 ups.status
Response: VAR <upsname> <varname> "<value>"
VAR su700 ups.status "OL"
This replaces the old "REQ" command.
TYPE
----
Form: GET TYPE <upsname> <varname>
GET TYPE su700 input.transfer.low
Response: TYPE <upsname> <varname> <type>...
TYPE su700 input.transfer.low ENUM
<type> can be several values, and multiple words may be returned:
RW - this variable may be set to another value with SET
ENUM - an enumerated type, which supports a few specific values
STRING:n - this is a string of maximum length n
ENUM and STRING are usually associated with RW, but not always.
This replaces the old "VARTYPE" command.
DESC
----
Form: GET DESC <upsname> <varname>
GET DESC su700 ups.status
Response: DESC <upsname> <varname> "<description>"
DESC su700 ups.status "UPS status"
<description> is a string that gives a brief explanation of the named
variable. upsd may return "Unavailable" if the file which provides this
description is not installed.
Different versions of this file may be used in some situations to
provide for localization and internationalization.
This replaces the old "VARDESC" command.
CMDDESC
-------
Form: GET CMDDESC <upsname> <cmdname>
GET CMDDESC su700 load.on
Response: CMDDESC <upsname> <cmdname> "<description>"
CMDDESC su700 load.on "Turn on the load immediately"
This is like DESC above, but it applies to the instant commands.
This replaces the old "INSTCMDDESC" command.
LIST
====
The LIST functions all share a common container format. They will
return "BEGIN LIST" and then repeat the initial query. The list then
follows, with as many lines are necessary to convey it. "END LIST" with
the initial query attached then follows.
The formatting may seem a bit redundant, but it makes a different form
of client possible. You can send a LIST query and then go off and wait
for it to get back to you. When it arrives, you don't need complicated
state machines to remember which list is which.
UPS
---
Form: LIST UPS
Response: BEGIN LIST UPS
UPS <upsname> "<description>"
...
END LIST UPS
BEGIN LIST UPS
UPS su700 "Development box"
END LIST UPS
<upsname> is a name from ups.conf, and <description> is the value of
desc= from ups.conf, if available. It will be set to "Unavailable"
otherwise.
This can be used to determine what values of <upsname> are valid before
calling other functions on the server. This is also a good way to
handle situations where a single upsd supports multiple drivers.
Clients which perform a UPS discovery process may find this useful.
VAR
---
Form: LIST VAR <upsname>
LIST VAR su700
Response: BEGIN LIST VAR <upsname>
VAR <upsname> <varname> "<value>"
...
END LIST VAR <upsname>
BEGIN LIST VAR su700
VAR su700 ups.mfr "APC"
VAR su700 ups.mfr.date "10/17/96"
...
END LIST VAR su700
This replaces the old "LISTVARS" command.
RW
--
Form: LIST RW <upsname>
LIST RW su700
Response: BEGIN LIST RW <upsname>
RW <upsname> <varname> "<value>"
...
END LIST RW <upsname>
BEGIN LIST RW su700
RW su700 output.voltage.target.battery "115"
RW su700 ups.delay.shutdown "020"
...
END LIST RW su700
This replaces the old "LISTRW" command.
CMD
---
Form: LIST CMD <upsname>
LIST CMD su700
Response: BEGIN LIST CMD <upsname>
CMD <upsname> <cmdname>
...
END LIST CMD <cmdname>
BEGIN LIST CMD su700
CMD su700 load.on
CMD su700 test.panel.start
...
END LIST CMD su700
This replaces the old "LISTINSTCMD" command.
ENUM
----
Form: LIST ENUM <upsname> <varname>
LIST ENUM su700 input.transfer.low
Response: BEGIN LIST ENUM <upsname> <varname>
ENUM <upsname> <varname> "<value>"
...
END LIST ENUM <upsname> <varname>
BEGIN LIST ENUM su700 input.transfer.low
ENUM su700 input.transfer.low "103"
ENUM su700 input.transfer.low "100"
...
END LIST ENUM su700 input.transfer.low
This replaces the old "ENUM" command.
Note: this does not support the old "SELECTED" notation. You must
request the current value separately.
SET
---
Form: SET VAR <upsname> <varname> "<value>"
SET VAR su700 ups.id "My UPS"
INSTCMD
-------
Form: INSTCMD <upsname> <cmdname>
INSTCMD su700 test.panel.start
LOGOUT
======
Form: LOGOUT
Returns: OK Goodbye (recent versions)
Used to disconnect gracefully from the server.
Older versions just said "Goodbye...".
LOGIN
=====
Form: LOGIN <upsname>
Returns: OK (upon success)
or various errors
Requires: "upsmon slave" or "upsmon master" in upsd.users
Use this to log the fact that a system is drawing power from this UPS.
The upsmon master will wait until the count of attached systems reaches
1 - itself. This allows the slaves to shut down first.
NOTE: You probably shouldn't send this command unless you are upsmon,
or a upsmon replacement.
MASTER
======
Form: MASTER <upsname>
Returns: OK (upon success)
or various errors
Requires: "upsmon master" in upsd.users
This function doesn't do much by itself. It is used by upsmon to make
sure that master-level functions like FSD are available if necessary.
FSD
===
Form: FSD <upsname>
Returns: OK FSD-SET (success)
or various errors
Requires: "upsmon master" in upsd.users
or "FSD" action granted in upsd.users
upsmon in master mode is the primary user of this function. It sets this
"forced shutdown" flag on any UPS when it plans to power it off. This is
done so that slave systems will know about it and shut down before the
power disappears.
Setting this flag makes "FSD" appear in a STATUS request for this UPS.
Finding "FSD" in a status request should be treated just like a "OB LB".
It should be noted that FSD is currently a latch - once set, there is
no way to clear it short of restarting upsd or dropping then re-adding
it in the ups.conf. This may cause issues when upsd is running on a
system that is not shut down due to the UPS event.
PASSWORD
========
Form: PASSWORD <password>
Returns: OK (upon success)
or various errors
Sets the password associated with a connection. Used for later
authentication for commands that require it.
USERNAME
========
Form: USERNAME <username>
Returns: OK (upon success)
or various errors
Sets the username associated with a connection. This is also used for
authentication, specifically in conjunction with the upsd.users file.
STARTTLS
========
Form: STARTTLS
Returns: OK STARTTLS
or various errors
This tells upsd to switch to TLS mode internally, so all future
communications will be encrypted. You must also change to TLS mode in
the client after receiving the OK, or the connection will be useless.
Other commands
==============
HELP - lists the commands supported by this server
VER - shows the version of the server currently in use
These two are not intended to be used directly by programs. Humans can
make use of this program by using telnet or netcat. If you use
telnet, make sure you don't have it set to negotiate extra options.
upsd doesn't speak telnet and will probably misunderstand your first
request due to the extra junk in the buffer.
Error responses
===============
ERR <message> [<extra>...]
<message> is always one element; it never contains spaces. This may
be used to allow additional information (<extra>) in the future.
ACCESS-DENIED
- The client's host and/or authentication details (username, password)
are not sufficient to execute the requested command.
UNKNOWN-UPS
- The UPS specified in the request is not known to upsd. This usually
means that it didn't match anything in ups.conf.
VAR-NOT-SUPPORTED
- The specified UPS doesn't support the variable in the request.
This is also sent for unrecognized variables which are in a space
which is handled by upsd, such as server.*.
CMD-NOT-SUPPORTED
- The specified UPS doesn't support the instant command in the request.
INVALID-ARGUMENT
- The client sent an argument to a command which is not recognized or
is otherwise invalid in this context. This is typically caused by
sending a valid command like GET with an invalid subcommand.
INSTCMD-FAILED
- upsd failed to deliver the instant command request to the driver.
No further information is available to the client. This typically
indicates a dead or broken driver.
SET-FAILED
- upsd failed to deliver the set request to the driver. This is
just like INSTCMD-FAILED above.
READONLY
- The requested variable in a SET command is not writable.
TOO-LONG
- The requested value in a SET command is too long.
FEATURE-NOT-SUPPORTED
- This instance of upsd does not support the requested feature. This
is only used for TLS/SSL mode (STARTTLS) at the moment.
FEATURE-NOT-CONFIGURED
- This instance of upsd hasn't been configured properly to allow the
requested feature to operate. This is also limited to STARTTLS for
now.
ALREADY-SSL-MODE
- TLS/SSL mode is already enabled on this connection, so upsd can't
start it again.
DRIVER-NOT-CONNECTED
- upsd can't perform the requested command, since the driver for that
UPS is not connected. This usually means that the driver is not
running, or if it is, the ups.conf is misconfigured.
DATA-STALE
- upsd is connected to the driver for the UPS, but that driver isn't
providing regular updates or has specifically marked the data
as stale. upsd refuses to provide variables on stale units to avoid
false readings.
This generally means that the driver is running, but it has lost
communications with the hardware. Check the physical connection
to the equipment.
ALREADY-LOGGED-IN
- The client already sent LOGIN for a UPS and can't do it again.
There is presently a limit of one LOGIN record per connection.
INVALID-PASSWORD
- The client sent an invalid PASSWORD - perhaps an empty one.
ALREADY-SET-PASSWORD
- The client already set a PASSWORD and can't set another. This also
should never happen with normal NUT clients.
INVALID-USERNAME
- The client sent an invalid USERNAME.
ALREADY-SET-USERNAME
- The client has already set a USERNAME, and can't set another. This
should never happen with normal NUT clients.
USERNAME-REQUIRED
- The requested command requires a username for authentication,
but the client hasn't set one.
PASSWORD-REQUIRED
- The requested command requires a passname for authentication,
but the client hasn't set one.
UNKNOWN-COMMAND
- upsd doesn't recognize the requested command.
This can be useful for backwards compatibility with older versions
of upsd. Some NUT clients will try GET and fall back on REQ after
receiving this response.
INVALID-VALUE
- The value specified in the request is not valid. This usually
applies to a SET of an ENUM type which is using a value which is
not in the list of allowed values.
Future ideas
============
Dense lists
-----------
The LIST commands may be given the ability to handle options some day.
For example, "LIST VARS <ups> +DESC" would return the current value
like now, but it would also append the description of that variable.
Command status
--------------
After sending an INSTCMD or SET, a client will eventually be able to
poll to see whether it was completed successfully by the driver.
|