Hello, is there a way to query from the cmdline if the UPS data is stale? "upsc" outputs a lot of information, but not if the data is stale. Example output from a "stale" UPS on the server: (nut version: nut-2.7.2-3.el7) # upsc apcsmart battery.charge: 100 battery.charge.low: 10 battery.charge.warning: 50 battery.mfr.date: 2014/09/01 battery.runtime: 1320 battery.runtime.low: 300 battery.temperature: 36.0 battery.type: PbAc battery.voltage: 25.7 battery.voltage.nominal: 24.0 device.mfr: American Power Conversion device.model: Smart-UPS 1500 device.serial: ASXXXXXXXXXX device.type: ups driver.name: usbhid-ups driver.parameter.pollfreq: 30 driver.parameter.pollinterval: 2 driver.parameter.port: auto driver.version: 2.7.2 driver.version.data: APC HID 0.95 driver.version.internal: 0.38 input.sensitivity: high input.transfer.high: 253 input.transfer.low: 208 input.transfer.reason: input voltage out of range input.voltage: 233.2 output.frequency: 50.0 output.voltage: 233.2 output.voltage.nominal: 230.0 ups.beeper.status: enabled ups.delay.shutdown: 20 ups.delay.start: 30 ups.firmware: 601.1.I ups.firmware.aux: 1.3 ups.load: 38.3 ups.mfr: American Power Conversion ups.mfr.date: 2002/02/05 ups.model: Smart-UPS 1500 ups.productid: 0002 ups.serial: ASXXXXXXXXXX ups.status: OL ups.test.result: No test initiated ups.timer.reboot: -1 ups.timer.shutdown: -1 ups.timer.start: -1 ups.vendorid: 051d If there's a way to query this from the cmdline, this could be monitored from an external system. The information seems to be part of the network protocol already, since "client" machines connected to this UPS server reported the data is stale in the logs. That's how I noticed it in the first place :) Thanks, Thomas
On Jun 27, 2016, at 4:46 AM, Thomas Jarosch wrote:> > Hello, > > is there a way to query from the cmdline if the UPS data is stale?The "data stale" state applies to the entire set of variables for an UPS, so if the exit code of `upsc` is zero, the data set is not stale.> > "upsc" outputs a lot of information, but not if the data is stale. > Example output from a "stale" UPS on the server:Actually, you caught the UPS right after it was no longer stale -- otherwise, `upsc` would print just the "Error: Data stale" message instead of the variables.> driver.name: usbhid-ups > driver.parameter.pollfreq: 30 > driver.parameter.pollinterval: 2You can tune these parameters to avoid the stale condition, at the expense of slightly longer latency for updates. The smaller `pollinterval` (seconds between poll cycles) is used for items marked "HU_FLAG_QUICK_POLL" in the HID tables: https://github.com/networkupstools/nut/blob/master/drivers/apc-hid.c#L301 and the `pollfreq` value is used for polling the rest. More information here: http://networkupstools.org/docs/man/usbhid-ups.html (I think the interrupt stuff applies to APC models with USB ID 051d:0002) If needed, we can look at the debug output to see what is going on, but for whatever reason, a few "data stale" messages over the course of a day seems normal for many USB UPS interfaces. -- Charles Lepple clepple at gmail
Hi Charles, On Monday, 27. June 2016 08:59:02 Charles Lepple wrote:> > is there a way to query from the cmdline if the UPS data is stale? > > The "data stale" state applies to the entire set of variables for an UPS, > so if the exit code of `upsc` is zero, the data set is not stale. > > "upsc" outputs a lot of information, but not if the data is stale.you are right. The exit code is exactly what I need for nagios monitoring. When I invoke upsc multiple times, the data is sometimes stale, sometimes not. Current log output (I specifically didn't fix the issue yet): Jun 27 14:56:08 server upsd: UPS [apcsmart] data is no longer stale Jun 27 14:56:08 server upsd[3123]: UPS [apcsmart] data is no longer stale Jun 27 14:56:24 server upsd[3123]: Data for UPS [apcsmart] is stale - check driver Jun 27 14:56:24 server upsd: Data for UPS [apcsmart] is stale - check driver Jun 27 14:56:36 server upsmon: Poll UPS [apcsmart at localhost] failed - Data stale Jun 27 14:56:41 server upsmon: Poll UPS [apcsmart at localhost] failed - Data stale Jun 27 14:56:46 server upsmon: Poll UPS [apcsmart at localhost] failed - Data stale .. Jun 27 14:58:36 server upsmon: Poll UPS [apcsmart at localhost] failed - Data stale Jun 27 14:58:38 server upsd: UPS [apcsmart] data is no longer stale Jun 27 14:58:38 server upsd[3123]: UPS [apcsmart] data is no longer stale Jun 27 14:58:54 server upsd[3123]: Data for UPS [apcsmart] is stale - check driver Jun 27 14:58:54 server upsd: Data for UPS [apcsmart] is stale - check driver Jun 27 14:58:56 server upsmon: Poll UPS [apcsmart at localhost] failed - Data stale> > driver.name: usbhid-ups > > driver.parameter.pollfreq: 30 > > driver.parameter.pollinterval: 2 > > You can tune these parameters to avoid the stale condition, at the expense > of slightly longer latency for updates. The smaller `pollinterval` > (seconds between poll cycles) is used for items marked > "HU_FLAG_QUICK_POLL" in the HID tables: > https://github.com/networkupstools/nut/blob/master/drivers/apc-hid.c#L301 > and the `pollfreq` value is used for polling the rest. > > More information here: http://networkupstools.org/docs/man/usbhid-ups.html > (I think the interrupt stuff applies to APC models with USB ID 051d:0002) > > If needed, we can look at the debug output to see what is going on, but > for whatever reason, a few "data stale" messages over the course of a day > seems normal for many USB UPS interfaces.it's running fine for months normally. You are right again, I've checked the logs back to 2016-05-06 and there are a few "Data stale" messages over the course of the day. I think I'll leave the polling frequency on the default value and just add monitoring to get notified if the data is stale for a longer time period. Thanks a lot Charles, that was really helpful. Thomas