nicolargo / glances

Glances an Eye on your system. A top/htop alternative for GNU/Linux, BSD, Mac OS and Windows operating systems.
http://nicolargo.github.io/glances/
Other
26.36k stars 1.5k forks source link

UPS support #488

Open rmenessec opened 9 years ago

rmenessec commented 9 years ago

Would it be possible to add support for basic UPS status--say batt level, temp, and offline / online status?

PyNUT appears to ship as part of the Network UPS Tools.

Thanks!

nicolargo commented 9 years ago

Development test bed:

rmenessec commented 9 years ago

Well, no, PyNUT isn't available via pip. It only appears to be shipped with each release of NUT. That said, it's available as a separately installable package via at least Debian-derived distros ("python-nut").

I have several non-APC units, so apcupsd wouldn't get me glances support; I'm not sure if the first link is meant to imply adding support via apcupsd.

nicolargo commented 7 years ago

Could be implemented through an AMP ==> http://glances.readthedocs.io/en/stable/aoa/amps.html

rmenessec commented 7 years ago

@nicolargo , there's nothing in the documentation to indicate that an AMP can be used to evaluate command output. I'm also not seeing a way to discard stderr. This—

# upslist0 2> /dev/null ups.load
9

—becomes this—

Ups_load            1   Init SSL without certificate database
                    9

—in the current best case, with the label malformed, useless stderr output included, and no obvious processing of the value (9%). I don't see a way to trigger a warning or error in Glances if the value is, for example, 75% or 90%. There's no intelligent formatting of the output, and no way to define it, either.

What I was really looking for was something like the output from lm_sensors that Glances already formats, displays attractively, and handles error reporting for.

Since it's impossible to write some custom script to be executed by Glances that can take into account the display width and height and perform formatting and line-wrapping, it's also impossible to avoid wasting a huge amount of vertical and horizontal space. This information—

# upslist0 |& egrep '(battery.(charge|runtime|temperature|voltage))|(input.(frequency|voltage))|(output.(frequency|voltage))|(ups.(load|status)):'
battery.charge: 100
battery.charge.low: 25
battery.charge.warning: 50
battery.runtime: 6365
battery.temperature: 18.9
battery.voltage: 55.7
battery.voltage.nominal: 48.0
input.frequency: 59.9
input.voltage: 121.9
input.voltage.nominal: 120
output.frequency: 59.9
output.frequency.nominal: 60
output.voltage: 119.8
output.voltage.nominal: 120
ups.load: 9
ups.status: OL

—could be displayed on as little as one line with some abbreviation and grouping. The only way to do that, however, would be if Glances actually parsed the output as variables, which it doesn't.

(I tried sending some tabs and ANSI escape codes for color highlighting through AMP. The escapes were printed as literal characters and the tabs ended up uneven somehow. So it looks like Glances is in complete control of the display, and I can't customize it even the least bit by writing a wrapper to attempt to handle some of the parsing and formatting myself.)

One item that occurred to me, involving saved space? Glances could use some global options to optionally hide or "collapse" output as long as it doesn't indicate a warning / error / critical state. Intelligent retrieval of NUT variables—again, completely possible through the Python bindings the NUT project provides—could transform a list of "healthy" UPS variables into a space-saving "UPS: GOOD", or even just a "UPS" section header in green, with no contents.

Likewise, it would be great to be able to hide filesystems that aren't over a certain percentage used, sensors or a laptop battery that are within normal parameters, and so forth. The same could be done with the process listing, by providing the ability to hide processes that aren't performing storage I/O or network I/O, aren't utilizing more than a configurable range (1-5%?) of CPU time, and so forth.

If this is something you'd consider, I'd be happy to split it into a separate issue.

Thanks!

utdrmac commented 5 years ago

Has there been any progress on this?

RazCrimson commented 1 year ago

In case anyone is interested in contributing, newer version of PyNUT: https://github.com/rshipp/python-nut2