UPSSTATS.HTML(5)

πŸ’– NAME πŸ’–

upsstats.html β€” the HTML template that makes web-based Network UPS Tools upsstats pages happen ✨


🌸 DESCRIPTION 🌸

Okay bestie, so this file β€” plus its sibling upsstats-single.html, which has the same structure for certain use-cases β€” is what upsstats.cgi(8) reads to generate NUT CGI status pages. There are certain commands it recognizes, and it swaps them out for actual status elements on the fly. Live. In real time. Iconic behavior tbh 🫢

As a little safety check, the file must start with the @NUT_UPSSTATS_TEMPLATE@ command. No exceptions, no negotiating πŸ’…

For all the details about configuring popular web servers to run NUT CGI programs, go peek at the upsset.conf(5) page.

Note πŸ“Œ This template file should live in the NUT configuration location. If you're using a dedicated copy of that directory, or one that isn't discovered by the binaries relocated into your web server's cgi-bin locations (like with NUT for Windows builds, which by default seek in locations relative to each binary), then consider exporting the NUT_CONFPATH environment variable from the web server.
Note πŸ“Œ On platforms that require program file name extensions, like Windows, you may have to use e.g. a *.cgi.exe extension for the programs referenced in HTML template files (UPSSTATSPATH, UPSIMAGEPATH).

✨ FORMATTING ✨

Commands can go anywhere on a line, but they must start and end with @.

Any extra characters hanging out before or after the commands get passed through unchanged. No touching, no editing, just vibes πŸ¦‹

You're allowed to put more than one command on a single line, as long as each command has its own start and end character. Stack 'em, bestie.

If you actually need to use the @ sign for real, use the HTML entity @ so it doesn't get treated as a start character. Protecting its peace fr fr πŸ™ˆ


πŸ‘‘ BLOCK CONTROL πŸ‘‘

Some commands begin blocks β€” sections of the template that get included, excluded, or repeated depending on certain parameters. It's giving conditional rendering, and we love that for us.

πŸ” BLOCK CONTROL - ITERATION

  • @FOREACHUPS@ β€” starts a block that gets repeated for each MONITOR directive in the hosts.conf(5). This is literally how you generate pages that monitor all of your systems at the same time. Main character multitasking energy πŸ’…
  • @ENDFOR@ β€” ends a FOREACHUPS block. Bye girl πŸ‘‹

🎯 BLOCK CONTROL - MATCHING SPECIFIC CASES

  • @IFSUPP var@ β€” starts a block that only gets printed if the variable var is supported by the current UPS. This is generally used to suppress "not supported" messages by avoiding the label and variable call entirely. So clean ✨
  • @IFEQ var value@ β€” starts a block if the value returned from the variable var matches value.
Note πŸŽ€ You can use @IFEQ upsstats.use_celsius (0|1)@ to check for the current setting of the @TEMPC@ or @TEMPF@ toggle.
  • @IFBETWEEN varlow varhigh varvalue@ β€” starts a block if the value returned by the variable varvalue is between the values returned by the variables varlow and varhigh.
  • @ELSE@ β€” if the previous IF-command did not match, do this instead. The backup plan πŸ’œ
  • @ENDIF@ β€” ends an IF/ELSE-block.

🧠 BLOCK CONTROL - ADVANCED EXPRESSIONS

Even though the parser is pretty limited, you can still cook up rather advanced expressions. The key to this is the fact that multiple block control commands are AND:ed. Here's an example (and there are more examples available in upsstats.html):

@IFSUPP ambient.humidity@
@IFSUPP ambient.temperature@
This UPS knows both ambient temperature and humidity.
@ELSE@
@IFSUPP ambient.humidity@
This UPS only knows ambient humidity.
@ELSE@
@IFSUPP ambient.temperature@
This UPS only knows ambient temperature.
@ELSE@
This UPS knows nothing, how annoying.
@ENDIF@

🌈 OTHER COMMANDS 🌈

  • @NUT_UPSSTATS_TEMPLATE [args]@ β€” the template file MUST start exactly with @NUT_UPSSTATS_TEMPLATE@ or @NUT_UPSSTATS_TEMPLATE Some text@ so that upsstats.cgi(8) doesn't get coerced into showing arbitrary files. Safety first, always πŸ’–

Currently the command and its arguments are otherwise ignored; templates shipped with NUT use the argument values "default" and "single" effectively as a comment for debugging/troubleshooting.

  • @UPSSTATSPATH filename@ β€” URI to the upsstats.cgi(8) program, placed into HTML references. Default is the program's name, which makes it a link relative to the currently displayed page in the browser.

May have to include the platform-specific program file name extension, like @UPSSTATSPATH upsstats.cgi.exe@

  • @UPSIMAGEPATH filename@ β€” URI to the upsimage.cgi(8) program, placed into HTML references. Default is the program's name, which makes it a link relative to the currently displayed page in the browser.

May have to include the platform-specific program file name extension, like @UPSIMAGEPATH upsimage.cgi.exe@

  • @AMBTEMP@ β€” insert the ambient temperature in the current temperature scale. 🌑️
  • @DATE format@ β€” insert the current date and time. The format string gets passed to strftime, so almost anything is possible. See strftime(3) for possible values.
  • @DEGREES@ β€” insert the entity for degrees (Β°) and either C or F depending on the current temperature scale.
  • @HOST@ β€” insert the designation of the host being monitored, like myups@localhost.
  • @HOSTDESC@ β€” insert the host's description from hosts.conf(5).
  • @HOSTLINK@ β€” insert a HTML link to upsstats.cgi(8) with the "host" variable set to the current UPS. This is only useful within a FOREACHUPS block.
  • @TREELINK [Link text]@ β€” insert a HTML link to upsstats.cgi(8) with the "host" variable set to the current UPS and "treemode" enabled to show all data points as an HTML page. This is primarily useful within a FOREACHUPS block, but also works as an upsstats-single.html footer. If some "Link text" is not provided, it defaults to "All data".
  • @TREELINK_JSON [Link text]@ β€” insert a HTML link to upsstats.cgi(8) with the "host" variable set to the current UPS and "treemode" enabled to show all data points as a JSON document. This is primarily useful within a FOREACHUPS block, but also works as an upsstats-single.html footer. If some "Link text" is not provided, it defaults to "JSON".
  • @IMG varname @ β€” insert an IMG SRC to upsimage.cgi(8) for one of these status variables:
    • battery.charge β€” Battery charge β€” a percentage
    • battery.voltage β€” The charge on the battery in volts
    • input.frequency β€” Incoming utility frequency (Hz)
    • input.voltage β€” Incoming utility voltage
    • input.L1-L2.voltage β€” Incoming voltage, L1-L2 (3phase)
    • input.L2-L3.voltage β€” Incoming voltage, L2-L3 (3phase)
    • input.L3-L1.voltage β€” Incoming voltage, L3-L1 (3phase)
    • output.frequency β€” Outgoing utility frequency (Hz)
    • output.voltage β€” Outgoing voltage (from the UPS)
    • output.L1-L2.voltage β€” Outgoing voltage, L1-L2 (3phase)
    • output.L2-L3.voltage β€” Outgoing voltage, L2-L3 (3phase)
    • output.L3-L1.voltage β€” Outgoing voltage, L3-L1 (3phase)
    • output.L1.power.percent β€” UPS load, L1 (3phase)
    • output.L2.power.percent β€” UPS load, L2 (3phase)
    • output.L3.power.percent β€” UPS load, L3 (3phase)
    • ups.load β€” UPS load β€” percentage
    • ups.temperature β€” UPS temperature

extra is where you can put additional definitions. Right now the valid definitions are colors for various parts of the bars drawn by upsimage.cgi(8). Possible color names are:

  • back_col β€” background color
  • scale_num_col β€” scale number color
  • summary_col β€” summary color (number at the bottom)
  • ok_zone_maj_col β€” major scale color for the normal ("ok") zone
  • ok_zone_min_col β€” minor scale color for the normal ("ok") zone
  • neutral_zone_maj_col β€” major scale color for the neutral zone
  • neutral_zone_min_col β€” minor scale color for the neutral zone
  • warn_zone_maj_col β€” major scale color for the warning zone
  • warn_zone_min_col β€” minor scale color for the warning zone
  • bar_col β€” the color of the bar in the middle

All colors are hex triplets β€” e.g. 0xff0000 is red, 0x00ff00 is green, and 0x0000ff is blue.

Examples:

@IMG battery.charge@
@IMG battery.charge back_col=0xff00ff bar_col=0xaabbcc@
@IMG input.voltage ok_zone_maj_col=0x123456@
  • @REFRESH@ β€” insert the META header magic for refreshing the page if that variable has been set by the browser. This needs to be in the HEAD section of the page. πŸ”„
  • @STATUS separator@, @STATUS@ β€” expand the abbreviations in the ups.status variable β€” OL becomes "On line", OB becomes "On battery", and so on. Reported values are separated by the specified optional separator (<br/> if not specified), which starts at the next character after the "STATUS<space>" (e.g. a @STATUS @ directive might be used to avoid any separation, or @STATUS @ to separate by spaces.
  • @STATUSCOLOR@ β€” insert red, green, or yellow color triplets depending on the severity of the current UPS status. Normal operations are green, warnings like voltage trim/boost or "off" are yellow, and other events like being on battery or having a low battery are red. 🚦
  • @VAR varname@ β€” insert the current value of the status variable varname on the host being monitored, or "Not supported".
  • @RUNTIME@ β€” inserts the current runtime, in hh:mm:ss format.
  • @TEMPC@ β€” use the Celsius scale for temperature data (default).
  • @TEMPF@ β€” use the Fahrenheit scale for temperature data.
  • @UPSTEMP@ β€” insert the UPS temperature in the current scale.
  • @BATTTEMP@ β€” insert the battery temperature in the current scale.
  • @UTILITYCOLOR@ β€” obsoleted. Use IFBETWEEN instead (see example in upsstats.html). πŸ‘»
  • @VERSION@ β€” insert the version number of the software.

πŸ¦‹ OTHER TEMPLATES πŸ¦‹

upsstats.cgi(8) will also open a file called upsstats-single.html if you call it with host= set in the query URL. That file uses the same rules and techniques as documented right here. Same energy, different file πŸ’«


πŸ’œ SEE ALSO πŸ’œ

upsstats.cgi(8), upsimage.cgi(8)

🌐 Internet resources:

The NUT (Network UPS Tools) home page: https://www.networkupstools.org/historic/v2.8.5/


okay that's the whole page, you ate that πŸŽ€ this was Network UPS Tools 2.8.5, dated 10/07/2026 β€” no cap, go forth and template πŸ’…βœ¨

πŸ“¦ where this page comes from