mirror of
https://github.com/fairwaves/UHD-Fairwaves.git
synced 2025-11-15 11:01:36 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50a1b928ec | ||
|
|
41a94769fe | ||
|
|
b1e80e5c27 | ||
|
|
014e8123a3 |
12
debian/changelog
vendored
12
debian/changelog
vendored
@@ -1,3 +1,15 @@
|
|||||||
|
umtrx (1.0.11) trusty; urgency=low
|
||||||
|
|
||||||
|
* collectd: use 'fairwaves-monitoring' user to run plugin
|
||||||
|
|
||||||
|
-- Kirill Zakharenko <earwin@gmail.com> Sun, 27 Mar 2016 19:37:39 +0100
|
||||||
|
|
||||||
|
umtrx (1.0.10) trusty; urgency=low
|
||||||
|
|
||||||
|
* collectd: rewritten counter collection plugin
|
||||||
|
|
||||||
|
-- Kirill Zakharenko <earwin@gmail.com> Mon, 21 Mar 2016 19:21:00 +0100
|
||||||
|
|
||||||
umtrx (1.0.9) trusty; urgency=low
|
umtrx (1.0.9) trusty; urgency=low
|
||||||
|
|
||||||
* collectd: osmo-nitb counter collection plugin
|
* collectd: osmo-nitb counter collection plugin
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ TypesDB "/usr/share/collectd/umtrx.types.db"
|
|||||||
|
|
||||||
LoadPlugin exec
|
LoadPlugin exec
|
||||||
<Plugin exec>
|
<Plugin exec>
|
||||||
Exec "fairwaves:fairwaves" "/usr/share/umtrx/umtrx2collectd.py"
|
Exec "fairwaves-monitoring" "/usr/share/umtrx/umtrx2collectd.py"
|
||||||
</Plugin>
|
</Plugin>
|
||||||
|
|||||||
@@ -1,5 +1 @@
|
|||||||
Voltages1 PR1:GAUGE:0:32, PR2:GAUGE:0:32, PF1:GAUGE:0:32, PF2:GAUGE:0:32
|
sensor value:GAUGE:U:U
|
||||||
Voltages2 Zero:GAUGE:0:32, Vin:GAUGE:0:32, VinPA:GAUGE:0:32, DCOUT:GAUGE:0:32
|
|
||||||
Temperature A:GAUGE:-40:120, B:GAUGE:-40:120
|
|
||||||
ReturnLoss C1:GAUGE:0:32, C2:GAUGE:0:32
|
|
||||||
VSWR C1:GAUGE:0:32, C2:GAUGE:0:32
|
|
||||||
|
|||||||
@@ -2,74 +2,52 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sched,time
|
import sched, time
|
||||||
|
|
||||||
from umtrx_property_tree import umtrx_property_tree
|
from umtrx_property_tree import umtrx_property_tree
|
||||||
from umtrx_vswr import umtrx_vswr
|
from umtrx_vswr import umtrx_vswr
|
||||||
|
|
||||||
|
BOARD_ID = "0"
|
||||||
|
SENSORS_PATH = "/mboards/{id}/sensors".format(id=BOARD_ID)
|
||||||
|
VSWR_CALIBRATION = 0 # = TM10_VSWR_cal
|
||||||
|
|
||||||
HOSTNAME = os.environ['COLLECTD_HOSTNAME'] if 'COLLECTD_HOSTNAME' in os.environ else 'localhost'
|
HOSTNAME = os.environ['COLLECTD_HOSTNAME'] if 'COLLECTD_HOSTNAME' in os.environ else 'localhost'
|
||||||
INTERVAL = os.environ['COLLECTD_INTERVAL'] if 'COLLECTD_INTERVAL' in os.environ else '60'
|
INTERVAL = os.environ['COLLECTD_INTERVAL'] if 'COLLECTD_INTERVAL' in os.environ else '60'
|
||||||
|
|
||||||
|
|
||||||
umtrx = umtrx_property_tree()
|
umtrx = umtrx_property_tree()
|
||||||
umtrx.connect()
|
umtrx.connect()
|
||||||
|
|
||||||
sensors_path = "/mboards/0/sensors"
|
# typically this yields: ['tempA', 'tempB', 'voltagePR1', 'voltagePF1', 'voltagePR2', 'voltagePF2', 'voltagezero', 'voltageVin', 'voltageVinPA', 'voltageDCOUT']
|
||||||
res = umtrx.list_path_raw(sensors_path)
|
sensors_list = umtrx.list_path_raw(SENSORS_PATH).get("result", [])
|
||||||
# ['tempA', 'tempB', 'voltagePR1', 'voltagePF1', 'voltagePR2', 'voltagePF2', 'voltagezero', 'voltageVin', 'voltageVinPA', 'voltageDCOUT']
|
|
||||||
sensors_list = res.get('result', [])
|
|
||||||
|
|
||||||
|
|
||||||
# Voltages1 PR1:GAUGE:0:32, PR2:GAUGE:0:32, PF1:GAUGE:0:32, PF2:GAUGE:0:32
|
|
||||||
# Voltages2 Zero:GAUGE:0:32, Vin:GAUGE:0:32, VinPA:GAUGE:0:32, DCOUT:GAUGE:0:32
|
|
||||||
# Temperature A:GAUGE:-40:120, B:GAUGE:-40:120,
|
|
||||||
# ReturnLoss C1:GAUGE:0:32, C2:GAUGE:0:32
|
|
||||||
# VSWR C1:GAUGE:0:32, C2:GAUGE:0:32
|
|
||||||
|
|
||||||
def publish_set(name, values):
|
|
||||||
res = [HOSTNAME, name, INTERVAL]
|
|
||||||
res.extend(values)
|
|
||||||
src = "PUTVAL \"%s/UmTRX/%s\" interval=%s N:" + ":".join(["%s"] * len(values))
|
|
||||||
print src % tuple(res)
|
|
||||||
|
|
||||||
|
|
||||||
def publish():
|
def publish():
|
||||||
sets = {'Voltages1': ['VoltagePR1', 'VoltagePR2', 'VoltagePF1', 'VoltagePF2'],
|
now = time.time()
|
||||||
'Voltages2': ['Voltagezero', 'VoltageVin', 'VoltageVinPA', 'VoltageDCOUT'],
|
|
||||||
'Temperature': ['TempA', 'TempB'], 'VSWR': ['Channel_1_VSWR', 'Channel_2_VSWR'],
|
|
||||||
'ReturnLoss': ['Channel_1_ReturnLoss', 'Channel_2_ReturnLoss']}
|
|
||||||
|
|
||||||
current_sensors = {}
|
current_sensors = {sensor: umtrx.query_sensor_value(SENSORS_PATH + "/" + sensor) for sensor in sensors_list}
|
||||||
|
|
||||||
for sensor in sensors_list:
|
for channel in ["1", "2"]:
|
||||||
sensor_data = umtrx.query_sensor_raw(sensors_path + "/" + sensor)['result']
|
vpf_name = "voltagePF" + channel
|
||||||
current_sensors[sensor_data['name']] = sensor_data['value']
|
vpr_name = "voltagePR" + channel
|
||||||
|
|
||||||
# vswr_calibration = TM10_VSWR_cal
|
if vpf_name in current_sensors and vpr_name in current_sensors:
|
||||||
vswr_calibration = 0
|
vswr = umtrx_vswr(float(current_sensors[vpf_name]), float(current_sensors[vpr_name]), VSWR_CALIBRATION)
|
||||||
|
current_sensors["VSWR" + channel] = vswr.vswr()
|
||||||
|
current_sensors["ReturnLoss" + channel] = vswr.return_loss()
|
||||||
|
|
||||||
for num in [1, 2]:
|
for name, value in current_sensors.items():
|
||||||
vpr_name = 'voltagePR' + str(num)
|
print "PUTVAL {host}/umtrx-{id}/sensor-{name} interval={interval} {now}:{value}".format(
|
||||||
vpf_name = 'voltagePF' + str(num)
|
host=HOSTNAME, id=BOARD_ID, name=name, interval=INTERVAL, now=now, value=value)
|
||||||
if vpr_name in sensors_list and vpf_name in sensors_list:
|
|
||||||
vpr = float(umtrx.query_sensor_value(sensors_path + '/' + vpr_name))
|
|
||||||
vpf = float(umtrx.query_sensor_value(sensors_path + '/' + vpf_name))
|
|
||||||
|
|
||||||
vswr = umtrx_vswr(vpf, vpr, vswr_calibration)
|
|
||||||
|
|
||||||
current_sensors['Channel_%d_VSWR' % num] = vswr.vswr()
|
|
||||||
current_sensors['Channel_%d_ReturnLoss' % num] = vswr.return_loss()
|
|
||||||
|
|
||||||
for key, values in sets.iteritems():
|
|
||||||
publish_set(key, [current_sensors[name] for name in values])
|
|
||||||
|
|
||||||
|
|
||||||
s = sched.scheduler(time.time, time.sleep)
|
s = sched.scheduler(time.time, time.sleep)
|
||||||
|
|
||||||
|
|
||||||
def timer_loop():
|
def timer_loop():
|
||||||
s.enter(float(INTERVAL), 1, timer_loop, ())
|
s.enter(float(INTERVAL), 1, timer_loop, ())
|
||||||
publish()
|
publish()
|
||||||
|
|
||||||
|
|
||||||
timer_loop()
|
timer_loop()
|
||||||
s.run()
|
s.run()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user