Download the PHP package drakelid/librenms-ups-battery without Composer

On this page you can find all versions of the php package drakelid/librenms-ups-battery. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package librenms-ups-battery

LibreNMS UPS Battery

CI PHP 8.2+ LibreNMS 26.x

Rank your UPSes by battery runtime, load or any other sensor, on one page in LibreNMS.

Open it for an overview of every UPS: power status, runtime, charge, load, temperature, battery status, self-test and when the battery is due for replacement. Or pick a device type and a metric and get a sorted list of hostnames with their current value. Typical questions it answers:

The plugin only reads sensor data LibreNMS has already collected. It adds no tables, no migrations and no polling, and it works for any sensor class and device type, not just UPSes.

Illustrative sketch with example values.

Features

Reports

Battery health

Severity and freshness

Convenience

Permissions

Requirements

Installation

Install script (recommended)

Packagist with LibreNMS' own plugin installer (lnms plugin:add). The plugin is then registered in composer.json and composer.plugins.json, shows up in Plugin Admin and survives LibreNMS updates.

The script checks PHP and write access, picks the newest tagged release (or dev-main while no release has been tagged), runs lnms plugin:add, enables the plugin, refreshes the route and view caches and verifies the result.

Option Meaning
-d, --dir DIR LibreNMS directory (default $LIBRENMS_DIR or /opt/librenms)
-v, --version VER Install or switch to a version or constraint, for example 1.0.0, ^1.0 or dev-main
-u, --update Update an existing installation
--no-enable Leave the plugin disabled after a fresh install
-n, --dry-run Run the checks and show the commands, change nothing
-y, --yes Do not ask for confirmation

Keep the script outside /root so the LibreNMS user can read it. bash install.sh --help lists everything.

Manual installation

Then open UPS Battery in the top navigation bar (or Overview > Plugins > UPS Battery). The plugin is enabled as soon as it is installed; disable and configure it under Overview > Plugins > Plugin Admin.

Update and remove

Development checkout

To try a local copy, point composer at the folder (a symlink, so edits show up immediately):

Verify the installation

scripts/verify.sh checks the plugin against your real LibreNMS data: PHP syntax, route registration, Blade compilation (including the settings page and device card), the unit tests if composer install has been run in the plugin folder, and a smoke test of the whole pipeline (query, sorting, compare view, CSV).

It prints the UPSes with the lowest runtime, so you can compare them with the device pages in LibreNMS. From a development checkout, run scripts/verify.sh in that folder instead.

Configuration

Open Overview > Plugins > Plugin Admin and choose ups-battery.

Setting Default Meaning
Default device type empty (all types) Value of devices.type selected when the page opens, for example power. UPSs are not always typed power, so leave it empty unless you need it
Default metric runtime Sensor class shown when the page opens
Default number of rows 25 One of 10, 25, 50, 100 or all
Thresholds empty Severity rules per metric, see below
Auto-refresh interval 300 s 0 turns it off, otherwise 30 to 3600 seconds
Stale after 30 min Rows whose sensor value is older than this get a warning icon
Language English English or Norwegian (bokmål)
Top navigation on Also show "UPS Battery" as a top-level item in the navigation bar
Battery lifetime 48 months Added to the install date to get the next battery swap, see Battery replacement
Warn before the swap 90 days Swaps due within this many days are yellow, overdue swaps red
Suspect battery: runtime below 10 min See Suspect batteries
Suspect battery: load at most 30 %
Suspect battery: charge at least 95 %
Weekly report off Switch, recipients, day, time and number of rows, see Weekly email report

Invalid values never break the page; they are replaced by the defaults.

Thresholds

One rule set per line: <metric> <critical-rule> [<warning-rule>], where a rule is < or > followed by a number. Text after # is a comment.

Rules use the unit LibreNMS stores (minutes for runtime, % for load and charge, degrees Celsius for temperature, whatever unit a user has chosen) and replace the LibreNMS limits for that metric. Invalid lines are ignored and listed under the text box.

Matching alert rules. The page only colours rows. Under the form the settings page lists, for the saved thresholds, the equivalent LibreNMS alert rules, for example macros.device_up = 1 AND sensors.sensor_class = "runtime" AND sensors.sensor_current < 10. Paste them on the Advanced tab under Alerts > Alert Rules > Create rule to get alerts that agree with the colours. The warning rule leaves out the critical range, so a sensor never triggers both.

Battery replacement

The next battery swap of a UPS is worked out from, in this order:

  1. the install date entered on the UPS overview (pencil in the Installed column) plus the Battery lifetime setting,
  2. the recommended replacement date the UPS reports (APC, "Battery Recommended Days Remaining"),
  3. the last replacement date the UPS reports plus the battery lifetime (APC, "Last Battery Replacement").

Without any of them the swap date is unknown and the UPS is counted under "No swap date". Enter the date when you replace a battery; leaving the prompt empty removes it. The date is stored as the LibreNMS device attribute ups-battery.battery_installed, so it survives plugin updates and is removed with the device.

Most UPS batteries (VRLA) last three to five years; set the lifetime to what the manufacturer specifies for your batteries and site temperature.

The other columns of the UPS overview come from the sensors LibreNMS has discovered: the Status column from the output source state ("On battery"/"On mains"), Battery from the battery status or replace-battery indicator plus the bad battery pack count, Self-test from the diagnostics result. These are known for APC and the standard UPS-MIB; for other vendors they are recognised by the sensor name. LibreNMS does not store the date of the last self-test, so only its result is shown.

Supported UPSs

The plugin reads the sensors LibreNMS discovers, so any UPS that LibreNMS monitors with a battery charge or a remaining battery time shows up. The sensor names of every UPS OS in LibreNMS were checked, and these are recognised in particular:

LibreNMS OS Status / on battery Battery status Self-test Battery dates
apc output status replace indicator diagnostics result recommended and last replacement
Standard UPS-MIB (RFC 1628): abbups, apc-mgeups, dell-ups, deltaups, eaton-mgeups, eatonupsm2, ge-ups, generex-ups, hpe-rtups, huaweiups, liebert, marathonups, netmanplus, orvaldi-ups, poweralert, webpower, ... output source, or time on battery battery status test result eatonupsm2: last replacement
eaton-mgeups, apc-mgeups on battery / on input power
eatonups (XUPS-MIB) battery discharging battery status battery test
cyberpower, netagent2 output status battery status, replace indicator
socomec-ups, vertiv-ita2 output source battery status
powerwalker system status
webpower-smart2 time on battery battery group status battery test
algcom-dc-ups, imcopower-*, eltek-webpower, enexus and other DC power systems operation mode / power state battery and charger states
Linux/Unix host with NUT (ups-nut SNMP extend) on battery / on line flags low battery, replace battery flags

Other vendors' state sensors are recognised by their names (battery, output source, self-test). When a UPS has no output status, the Status column is worked out from its mains or input status, its input voltage or frequency, or its charger state; the tooltip says which sensor was used. Runtime-class sensors that are not a remaining battery time (time already spent on battery, battery dates, uptimes, filter and fan run hours) are not used as runtime, so routers, cooling units and similar devices do not appear as UPSs. If a UPS is missing or a column stays empty, run scripts/verify.sh and check which sensors LibreNMS has discovered for it.

Suspect batteries

A short runtime is normal at high load or while the battery is still charging. It is suspicious when the UPS is lightly loaded and fully charged, because then the battery itself is the likely cause. A battery is flagged when

runtime < limit, and load ≤ limit, and (charge is unknown or charge ≥ limit)

with the limits from the settings (10 minutes, 30 % and 95 % by default). For a device the shortest runtime, the highest load and the lowest charge decide. A battery cannot be judged without a runtime and a load sensor.

Where you see it: the Battery column in the compare view (select runtime and load), the Suspect batteries only filter next to it, a warning on the device page and a table in the weekly report. The CSV export has a suspect_battery column.

Weekly email report

Switch it on in the settings and enter one or more recipients. Every week, on the day and time you choose, LibreNMS' scheduler sends an HTML email with the number of UPSes, critical and warning counts, the UPSes with the shortest runtime (top 10, 25, 50 or 100), the suspect batteries and the battery swaps that are overdue or due within the warning window.

Common UPS metrics

Metric (sensor class) Unit Default order
runtime minutes shortest first
charge % lowest first
load % highest first
temperature °C or °F, per user highest first
power, current W, A highest first
voltage, frequency V, Hz ascending (use thresholds to flag deviations)
state text most severe first

Which classes exist depends on what each UPS exposes over SNMP; the metric list only shows classes that exist for the selected device type.

API

The page is backed by JSON endpoints that can also be used directly. All routes require a logged-in user (session cookie).

Route Purpose
GET /plugin/ups-battery/report The report page
GET /plugin/ups-battery/options?type= Filter options (device types, OS, groups, metrics) as JSON
GET /plugin/ups-battery/ups?type=&os=&group=&q=&attention=1&focus=on_battery\|overdue\|due\|alarm\|unknown\|down&sort=status\|hostname\|location\|runtime\|charge\|load\|temperature\|swap&dir=&limit=&format=json\|csv UPS overview rows and summary cards as JSON, or the rows as CSV
POST /plugin/ups-battery/battery with {"device_id": 12, "installed": "2025-03-01"} Sets the battery install date (empty installed removes it). Needs the permission to update devices
GET /plugin/ups-battery/data?type=&class=&os=&group=&q=&sensor=&sort=&dir=&limit=&aggregate=&format=json\|csv Single-metric rows as JSON or CSV
GET /plugin/ups-battery/matrix?type=&classes=runtime,load,charge&os=&group=&q=&sensor=&suspect=1&sort=&dir=&limit=&format=json\|csv Compare-metrics rows as JSON or CSV
GET/POST /plugin/ups-battery/views, POST .../views/delete Saved views of the current user
GET /plugin/ups-battery/assets/report.js The page script

limit=0 returns every row. sensor filters on the sensor name, suspect=1 keeps only suspect batteries (needs runtime and load in classes). Invalid parameters return HTTP 422 with {"message": "..."}. The full request and response shapes are in chapters 12 to 14 of the specification.

Troubleshooting

Symptom Fix
"UPS Battery" is missing in the Plugins menu Enable ups-battery under Plugin Admin and reload the page. If it is enabled, reload PHP-FPM (for example systemctl reload php8.3-fpm).
404 on /plugin/ups-battery/report sudo -u librenms php artisan route:clear, then route:cache again if you cache routes.
The plugin disabled itself and a notification appeared A hook threw an error. Read logs/librenms.log, fix the cause and re-enable it under Plugin Admin.
Empty metric list No sensors of that device type exist, or your user has no device access. Filter options are cached for 60 seconds.
HTTP 422 from a data endpoint The request contained an unknown device type, class, OS or group; the response says which.
"Too many sensors" More than 50,000 sensors match. Narrow the filters (device type, OS, group).
Rows are never coloured LibreNMS has no limits for those sensors. Add a threshold rule.
The weekly report does not arrive Run php artisan ups-battery:report --dry-run to see the report, then php artisan ups-battery:report [email protected] to see the error. Check the email settings of LibreNMS and that the scheduler runs (php artisan schedule:list should show the report; the settings must have the report switched on and a valid recipient).
Links in the report email point to localhost Set APP_URL in the LibreNMS .env to the address people use.
"Suspect batteries only" is greyed out Select both the runtime and the load metric in the compare view.
plugin:add cannot find a version No release is tagged yet. Use dev-main (the install script does this automatically).

Development

GitHub Actions (integration.yml installs the plugin into a real LibreNMS (run it by hand or wait for the weekly run) and checks that it boots, registers its routes and command and compiles its views. It has not been run yet, so treat the first run as a test of the workflow itself.

Folder Contents
src/Report/ Filters, sorting, aggregation, thresholds, suspect batteries, saved views, CSV and the weekly report as plain PHP (unit tested without LibreNMS), plus SensorReportService, the only class that talks to the LibreNMS database
src/Http/, src/Hooks/, src/Console/ Controller, the menu, settings and device overview hooks, and the ups-battery:report command
resources/views/ Blade views: report, settings, menu entry and device card
resources/js/ report.js, the page script (no build step, no dependencies)
lang/ English and Norwegian (bokmål) strings, kept at the same keys
scripts/ install.sh and verify.sh
tests/ Pest tests (Unit/) and jsdom tests for the page script (js/)

SensorReportService, the controller, the hooks and the rendered pages need a LibreNMS with data. They are checked with scripts/verify.sh and the acceptance checklist in the specification.

Not planned: a LibreNMS dashboard widget. Widgets are core controllers and the plugin API has no widget hook, so it would need an upstream change in LibreNMS.

Documentation and license


All versions of librenms-ups-battery with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
librenms/plugin-interfaces Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package drakelid/librenms-ups-battery contains the following files

Loading the files please wait ...