Giter VIP home page Giter VIP logo

Comments (7)

angela-d avatar angela-d commented on June 11, 2024

Line 61 should be:

print("<text>Input voltage fluctuation " + banner_model + banner_serial + "</text>")

Source: https://github.com/angela-d/prtg-ups-monitor/blob/master/battery_sensor.py

from prtg-ups-monitor.

bust4rhymes avatar bust4rhymes commented on June 11, 2024

That was done by me trying to get around the issue but even with the space between the issue is still the same:

File "/var/prtg/scriptsxml/battery_sensor.py", line 231, in
obtain_status()
File "/var/prtg/scriptsxml/battery_sensor.py", line 61, in obtain_status
print("Input voltage fluctuation " + banner_model + banner_serial + "")
UnboundLocalError: local variable 'banner_serial' referenced before assignment

from prtg-ups-monitor.

angela-d avatar angela-d commented on June 11, 2024

What issue are you having that you're trying to fix by modifying the code?

If you run (from a terminal after having SSH'd into the pi):

upsc tc

What is your output?

banner_serial is a variable that assumes statuses[1] is set - if for some reason your battery is outputting something different, it's likely this is where its failing. Calling NUT direct would be able to show us what it's generating before it gets to the PRTG Python script.

from prtg-ups-monitor.

bust4rhymes avatar bust4rhymes commented on June 11, 2024

The UPSC query work fine. I just replaced the default TC for TL:
The issue happen when i call the "battery_sensor.py" the query start is returning the proper informations but at the end it is giving those error a posted earlier.
When you talk about statuses[1] are you regarding to the variable ups.status returned from UPSC ?

pi@raspberrypi:~ $ upsc TL
Init SSL without certificate database
battery.voltage: 13.90
battery.voltage.nominal: 12
device.mfr: Tripp Lite
device.model: SMART500RT1U
device.type: ups
driver.name: tripplite_usb
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.synchronous: no
driver.version: 2.7.4
driver.version.internal: 0.29
input.voltage: 119
input.voltage.maximum: 125
input.voltage.minimum: 0
input.voltage.nominal: 120
outlet.1.desc: Load 1
outlet.1.id: 1
outlet.1.switch: 1
outlet.1.switchable: 1
outlet.2.desc: Load 2
outlet.2.id: 2
outlet.2.switchable: 0
ups.debug.D: 00 77 00 8b 0d 00 00 '.w.....'
ups.debug.L: 15 00 00 07 58 58 0d '....XX.'
ups.debug.load_banks: 1
ups.debug.M: 00 00 00 7d 0d 00 00 '.......'
ups.debug.P: 30 30 35 30 30 58 0d '00500X.'
ups.debug.S: 01 04 00 00 64 00 0d '....d..'
ups.debug.T: 1d 00 02 57 01 58 0d '...W.X.'
ups.debug.V: 02 00 0c 01 58 58 0d '....XX.'
ups.delay.shutdown: 64
ups.firmware: F334401
ups.firmware.aux: protocol 3005
ups.id: 0
ups.mfr: Tripp Lite
ups.model: SMART500RT1U
ups.power.nominal: 500
ups.productid: 0001
ups.status: OL
ups.temperature: 0
ups.vendorid: 09ae

from prtg-ups-monitor.

angela-d avatar angela-d commented on June 11, 2024

Ah, your battery isn't returning a serial (as the code is expecting to see).

Make sure you're running the Github code (undo any changes you've made, to ensure if there are any additional problems, it's based on undefined variables and not typos or anything like that).

If you made changes you know are working and would like to keep, I'd advise making a backup of the file you modified and then try the changes below.

Lines 37-40 (original):

        if statuses[0] == 'Ups Model':
            banner_model = "Model: " + statuses[1]
        if statuses[0] == 'Ups Serial':
            banner_serial = " Serial: " + statuses[1]

Change to:

        if statuses[0] == 'Ups Model':
            banner_model = "Model: " + statuses[1]
        if statuses[0] == 'Ups Serial':
            banner_serial = " Serial: " + statuses[1]
        else:
            banner_serial = ""

If this works for you, I can push an update in the code. So far, I've only used this on one battery model so I didn't run into this while testing.

from prtg-ups-monitor.

bust4rhymes avatar bust4rhymes commented on June 11, 2024

That worked! i now have proper JSON return and PRTG is showing all sensor.
If this dont cause any issues with other UPS i suggest to add this modification to the actual script.

Thanks for your help

2020-03-20_08h30_13

from prtg-ups-monitor.

angela-d avatar angela-d commented on June 11, 2024

I just pushed the change, so anyone else going forward, shouldn't run into this. :)
Also updated the readme with your model, so anyone else using the same should know it'll work for them.

Lastly, for all of those sensors returning "Channel relation not found" for you, click the settings to the far right and configure a unit measurement. (I also changed this to a more informative message, by default)

from prtg-ups-monitor.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.