Skip to content
Snippets Groups Projects
Commit d0d7c302 authored by Stefano Di Frischia's avatar Stefano Di Frischia
Browse files

Merge branch 'master' into L2SS-777-add-observations-to-prometheus-exporter

parents 9d3e385c 81cb5961
Branches
Tags
1 merge request!387Resolve L2SS-777 "Add observations to prometheus exporter"
Showing
with 1214 additions and 11 deletions
...@@ -101,6 +101,7 @@ docker_build_image_all: ...@@ -101,6 +101,7 @@ docker_build_image_all:
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-observation latest - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-observation latest
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-observation-control latest - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-observation-control latest
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-psoc latest - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-psoc latest
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-pcon latest
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-recv latest - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-recv latest
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-sdp latest - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-sdp latest
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-bst latest - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-bst latest
...@@ -267,6 +268,17 @@ docker_build_image_device_psoc: ...@@ -267,6 +268,17 @@ docker_build_image_device_psoc:
script: script:
# Do not remove 'bash' or statement will be ignored by primitive docker shell # Do not remove 'bash' or statement will be ignored by primitive docker shell
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-psoc $tag - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-psoc $tag
docker_build_image_device_pcon:
extends: .base_docker_images_except
only:
refs:
- merge_requests
changes:
- docker-compose/device-pcon.yml
- docker-compose/lofar-device-base/*
script:
# Do not remove 'bash' or statement will be ignored by primitive docker shell
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-pcon $tag
docker_build_image_device_tilebeam: docker_build_image_device_tilebeam:
extends: .base_docker_images_except extends: .base_docker_images_except
only: only:
......
...@@ -46,9 +46,9 @@ ...@@ -46,9 +46,9 @@
"PSOC": { "PSOC": {
"STAT/PSOC/1": { "STAT/PSOC/1": {
"properties": { "properties": {
"SNMP_host": ["10.87.2.145"], "SNMP_host": ["127.0.0.1"],
"SNMP_community": ["public"], "SNMP_community": ["public"],
"SNMP_mib_dir": ["devices/psoc_mib/PowerNet-MIB.mib"], "SNMP_mib_dir": ["devices/mibs/PowerNet-MIB.mib"],
"SNMP_timeout": ["10.0"], "SNMP_timeout": ["10.0"],
"SNMP_version": ["1"], "SNMP_version": ["1"],
"PSOC_sockets": [ "PSOC_sockets": [
...@@ -66,6 +66,21 @@ ...@@ -66,6 +66,21 @@
} }
} }
}, },
"PCON": {
"STAT": {
"PCON": {
"STAT/PCON/1": {
"properties": {
"SNMP_host": ["127.0.0.1"],
"SNMP_community": ["public"],
"SNMP_mib_dir": ["devices/mibs/ACC-MIB.mib"],
"SNMP_timeout": ["10.0"],
"SNMP_version": ["1"]
}
}
}
}
},
"TemperatureManager": { "TemperatureManager": {
"STAT": { "STAT": {
"TemperatureManager": { "TemperatureManager": {
......
...@@ -526,6 +526,38 @@ ...@@ -526,6 +526,38 @@
} }
} }
}, },
"PSOC": {
"STAT": {
"PSOC": {
"STAT/PSOC/1": {
"properties": {
"SNMP_host": ["10.87.2.145"],
"PSOC_sockets": [
"socket_1",
"socket_2",
"socket_3",
"socket_4",
"socket_5",
"socket_6",
"socket_7",
"socket_8"
]
}
}
}
}
},
"PCON": {
"STAT": {
"PCON": {
"STAT/PCON/1": {
"properties": {
"SNMP_host": ["10.151.225.5"]
}
}
}
}
},
"UNB2": { "UNB2": {
"STAT": { "STAT": {
"UNB2": { "UNB2": {
......
#
# Requires:
# - lofar-device-base.yml
#
version: '2.1'
volumes:
iers-data: {}
services:
device-pcon:
image: device-pcon
# build explicitly, as docker-compose does not understand a local image
# being shared among services.
build:
context: ..
dockerfile: docker-compose/lofar-device-base/Dockerfile
args:
SOURCE_IMAGE: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}-tango-itango:${TANGO_ITANGO_VERSION}
container_name: ${CONTAINER_NAME_PREFIX}device-pcon
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "10"
networks:
- control
ports:
- "5719:5719" # unique port for this DS
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ..:/opt/lofar/tango:rw
environment:
- TANGO_HOST=${TANGO_HOST}
working_dir: /opt/lofar/tango
entrypoint:
- bin/start-ds.sh
# configure CORBA to _listen_ on 0:port, but tell others we're _reachable_ through ${HOSTNAME}:port, since CORBA
# can't know about our Docker port forwarding
- l2ss-pcon pcon STAT -v -ORBendPoint giop:tcp:device-pcon:5719 -ORBendPointPublish giop:tcp:${HOSTNAME}:5719
restart: unless-stopped
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
}, },
"STAT/PSOC/1": { "STAT/PSOC/1": {
}, },
"STAT/PCON/1": {
},
"STAT/RECV/1": { "STAT/RECV/1": {
"include": [ "include": [
"ANT_mask_RW", "ANT_mask_RW",
......
...@@ -69,7 +69,8 @@ sleep 1 # dsconfig container must be up and running... ...@@ -69,7 +69,8 @@ sleep 1 # dsconfig container must be up and running...
# shellcheck disable=SC2016 # shellcheck disable=SC2016
echo '/usr/local/bin/wait-for-it.sh ${TANGO_HOST} --strict --timeout=300 -- true' | make run dsconfig bash - echo '/usr/local/bin/wait-for-it.sh ${TANGO_HOST} --strict --timeout=300 -- true' | make run dsconfig bash -
DEVICES="device-boot device-apsct device-apspu device-sdp device-recv device-bst device-sst device-unb2 device-xst device-beamlet device-digitalbeam device-tilebeam device-psoc device-antennafield device-temperature-manager device-observation device-observation-control" DEVICES="device-boot device-apsct device-apspu device-sdp device-recv device-bst device-sst device-unb2 device-xst device-beamlet device-digitalbeam device-tilebeam device-psoc device-pcon device-antennafield device-temperature-manager device-observation device-observation-control"
SIMULATORS="sdptr-sim recv-sim unb2-sim apsct-sim apspu-sim" SIMULATORS="sdptr-sim recv-sim unb2-sim apsct-sim apspu-sim"
# Build only the required images, please do not build everything that makes CI # Build only the required images, please do not build everything that makes CI
......
...@@ -37,6 +37,7 @@ console_scripts = ...@@ -37,6 +37,7 @@ console_scripts =
l2ss-apsct = tangostationcontrol.devices.apsct:main l2ss-apsct = tangostationcontrol.devices.apsct:main
l2ss-apspu = tangostationcontrol.devices.apspu:main l2ss-apspu = tangostationcontrol.devices.apspu:main
l2ss-psoc = tangostationcontrol.devices.psoc:main l2ss-psoc = tangostationcontrol.devices.psoc:main
l2ss-pcon = tangostationcontrol.devices.pcon:main
l2ss-tilebeam = tangostationcontrol.devices.tilebeam:main l2ss-tilebeam = tangostationcontrol.devices.tilebeam:main
l2ss-beamlet = tangostationcontrol.devices.sdp.beamlet:main l2ss-beamlet = tangostationcontrol.devices.sdp.beamlet:main
l2ss-digitalbeam = tangostationcontrol.devices.sdp.digitalbeam:main l2ss-digitalbeam = tangostationcontrol.devices.sdp.digitalbeam:main
......
...@@ -83,7 +83,10 @@ class SNMP_client(CommClient): ...@@ -83,7 +83,10 @@ class SNMP_client(CommClient):
# SNMP has tables that require an index number to access them. regular non-table variable have an index of 0 # SNMP has tables that require an index number to access them. regular non-table variable have an index of 0
idx = annotation.get('index', 0) idx = annotation.get('index', 0)
return mib, name, idx # SNMP values like to use weird units like tenths of amps because its all integers. We added a scaling factor to correct for that.
scaling_factor = annotation.get('scaling_factor', 1)
return mib, name, idx, scaling_factor
except KeyError: except KeyError:
raise ValueError(f"SNMP attribute annotation requires a dict argument with both a 'name' and 'mib' key. Instead got: {annotation}") raise ValueError(f"SNMP attribute annotation requires a dict argument with both a 'name' and 'mib' key. Instead got: {annotation}")
...@@ -108,11 +111,11 @@ class SNMP_client(CommClient): ...@@ -108,11 +111,11 @@ class SNMP_client(CommClient):
""" """
# process the annotation # process the annotation
mib, name, idx = self._process_annotation(annotation) mib, name, idx, scaling_factor = self._process_annotation(annotation)
# get all the necessary data to set up the read/write functions from the attribute_wrapper # get all the necessary data to set up the read/write functions from the attribute_wrapper
dim_x, dim_y, dtype = self.setup_value_conversion(attribute) dim_x, dim_y, dtype = self.setup_value_conversion(attribute)
snmp_attr = snmp_attribute(self.SNMP_comm, mib, name, idx, dtype, dim_x, dim_y) snmp_attr = snmp_attribute(self.SNMP_comm, mib, name, idx, dtype, dim_x, dim_y, scaling_factor)
# return the read/write functions # return the read/write functions
def read_function(): def read_function():
...@@ -125,13 +128,14 @@ class SNMP_client(CommClient): ...@@ -125,13 +128,14 @@ class SNMP_client(CommClient):
class snmp_attribute: class snmp_attribute:
def __init__(self, comm: SNMP_comm, mib, name, idx, dtype, dim_x, dim_y): def __init__(self, comm: SNMP_comm, mib, name, idx, dtype, dim_x, dim_y, scaling_factor=1):
self.comm = comm self.comm = comm
self.mib = mib self.mib = mib
self.name = name self.name = name
self.idx = idx self.idx = idx
self.dtype = dtype self.dtype = dtype
self.scaling_factor = scaling_factor
self.len = self.get_len(dim_x, dim_y) self.len = self.get_len(dim_x, dim_y)
self.is_scalar = self.len == 1 self.is_scalar = self.len == 1
...@@ -203,7 +207,7 @@ class snmp_attribute: ...@@ -203,7 +207,7 @@ class snmp_attribute:
# IpAddress values get printed as their raw value but in hex (7F 20 20 01 for 127.0.0.1 for example) # IpAddress values get printed as their raw value but in hex (7F 20 20 01 for 127.0.0.1 for example)
vals.append(varBind[1].prettyPrint()) vals.append(varBind[1].prettyPrint())
elif snmp_type is hlapi.Integer32 or snmp_type is hlapi.Integer and self.dtype == str: elif (snmp_type is hlapi.Integer32 or snmp_type is hlapi.Integer) and self.dtype == str:
# Integers can have 'named values', Where a value can be translated to a specific name. A dict basically # Integers can have 'named values', Where a value can be translated to a specific name. A dict basically
# Example: {1: "other", 2: "invalid", 3: "dynamic", 4: "static",} # Example: {1: "other", 2: "invalid", 3: "dynamic", 4: "static",}
...@@ -215,7 +219,10 @@ class snmp_attribute: ...@@ -215,7 +219,10 @@ class snmp_attribute:
vals.append(varBind[1].prettyPrint()) vals.append(varBind[1].prettyPrint())
else: else:
# convert from the funky pysnmp types to numpy types and then append # convert from the funky pysnmp types to numpy types and then append
vals.append(snmp_to_numpy_dict[snmp_type](varBind[1])) value = snmp_to_numpy_dict[snmp_type](varBind[1])
# scale the value correctly and append.
vals.append(value * self.scaling_factor)
if self.is_scalar: if self.is_scalar:
vals = vals[0] vals = vals[0]
...@@ -235,7 +242,5 @@ class mib_loader: ...@@ -235,7 +242,5 @@ class mib_loader:
logger.debug(f"mib sources: {self.mibBuilder.getMibSources()}") logger.debug(f"mib sources: {self.mibBuilder.getMibSources()}")
def load_pymib(self, mib_name): def load_pymib(self, mib_name):
logger.debug(f"test {self.mibBuilder.getMibSources()}")
logger.debug(f"test {mib_name}")
self.mibBuilder.loadModules(mib_name) self.mibBuilder.loadModules(mib_name)
...@@ -235,6 +235,7 @@ class Boot(lofar_device): ...@@ -235,6 +235,7 @@ class Boot(lofar_device):
mandatory=False, mandatory=False,
default_value=["STAT/Docker/1", # Docker controls the device containers, so it goes before anything else default_value=["STAT/Docker/1", # Docker controls the device containers, so it goes before anything else
"STAT/PSOC/1", # PSOC boot early to detect power delivery failure as fast as possible "STAT/PSOC/1", # PSOC boot early to detect power delivery failure as fast as possible
"STAT/PCON/1", # PCON boot early because it is responsible for power delivery.
"STAT/APSPU/1", # APS Power Units control other hardware we want to initialise "STAT/APSPU/1", # APS Power Units control other hardware we want to initialise
"STAT/APSCT/1", "STAT/APSCT/1",
"STAT/RECV/1", # RCUs are input for SDP, so initialise them first "STAT/RECV/1", # RCUs are input for SDP, so initialise them first
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment