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'scgi-binlocations (like with NUT for Windows builds, which by default seek in locations relative to each binary), then consider exporting theNUT_CONFPATHenvironment 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.exeextension 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 eachMONITORdirective in thehosts.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 aFOREACHUPSblock. 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 thatupsstats.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 theupsstats.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 theupsimage.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 tostrftime, so almost anything is possible. Seestrftime(3)for possible values.@DEGREES@β insert the entity for degrees (Β°) and eitherCorFdepending on the current temperature scale.@HOST@β insert the designation of the host being monitored, likemyups@localhost.@HOSTDESC@β insert the host's description fromhosts.conf(5).@HOSTLINK@β insert a HTML link toupsstats.cgi(8)with the"host"variable set to the current UPS. This is only useful within aFOREACHUPSblock.@TREELINK [Link text]@β insert a HTML link toupsstats.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 aFOREACHUPSblock, but also works as anupsstats-single.htmlfooter. If some "Link text" is not provided, it defaults to"All data".@TREELINK_JSON [Link text]@β insert a HTML link toupsstats.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 aFOREACHUPSblock, but also works as anupsstats-single.htmlfooter. If some "Link text" is not provided, it defaults to"JSON".@IMG varname @β insert an IMG SRC toupsimage.cgi(8)for one of these status variables:battery.chargeβ Battery charge β a percentagebattery.voltageβ The charge on the battery in voltsinput.frequencyβ Incoming utility frequency (Hz)input.voltageβ Incoming utility voltageinput.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 β percentageups.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 colorscale_num_colβ scale number colorsummary_colβ summary color (number at the bottom)ok_zone_maj_colβ major scale color for the normal ("ok") zoneok_zone_min_colβ minor scale color for the normal ("ok") zoneneutral_zone_maj_colβ major scale color for the neutral zoneneutral_zone_min_colβ minor scale color for the neutral zonewarn_zone_maj_colβ major scale color for the warning zonewarn_zone_min_colβ minor scale color for the warning zonebar_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 theHEADsection of the page. π@STATUS separator@,@STATUS@β expand the abbreviations in theups.statusvariable βOLbecomes "On line",OBbecomes "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, inhh:mm:ssformat.@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. UseIFBETWEENinstead (see example inupsstats.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
- fedora 43: nut-cgi 2.8.5-9.fc43 Β· GPL-2.0-or-later AND GPL-3.0-or-later
- fedora 44: nut-cgi 2.8.5-9.fc44 Β· GPL-2.0-or-later AND GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms