Skip to content

Some modifications for Eaton5E #3

Description

@jlarmando1985

Hi, I'd needed to do some modifications to getting it work with Eaton 5E. Plus I've changed the output to work as float fields in InfluxDB:

from __future__ import print_function
import subprocess

cmd="upsc eaton5E"

output=""
string_measurements=["battery.charge","battery.runtime","input.voltage","output.voltage","ups.beeper.status","ups.load","ups.status"]

p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)

for line in p.stdout.readlines(): #read and store result in log file
    line = line.decode("utf-8").rstrip()
    key = line[:line.find(":")]
    value = line[line.find(":")+2:]
    if key in string_measurements:
        if value.isalpha():
            value = '"' + value + '"'
        measurement = key + "=" + value
        if output != "":
            measurement = "," + measurement
        output += measurement

output = "ups " + output.rstrip()
print(output, end='')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions