def __init__(self, name_suffix, nsum=100): """ List of sensors and handler to be connected to a mkrecv process """ self.sensors = {} self.sensors['global_payload_frac'] = Sensor.float( "global-payload-received-fraction-{}".format(name_suffix), description="Ratio of received and expected payload.", params=[0, 1]) self.sensors['received_heaps_frac'] = Sensor.float( "received-heaps-frac-{}".format(name_suffix), description="Fraction of received heaps for last {} slots.".format( 100), params=[0, 1]) self.sensors['slot_received_heaps'] = Sensor.integer( "slot_received-heaps-{}".format(name_suffix), description="Received heaps.", ) self.sensors['slot_expected_heaps'] = Sensor.integer( "slot_expected-heaps-{}".format(name_suffix), description="Expected heaps.", ) self.sensors['missing_heaps'] = Sensor.string( "missing-heaps-{}".format(name_suffix), description="Missing heaps per multicast group.", ) self.__received_heaps = 0. self.__expected_heaps = 0. self.__idx = 0 self.__nsum = nsum self.__missing_heaps = np.zeros(8)
def setup_sensors(self): """ Setup monitoring sensors """ EDDPipeline.setup_sensors(self) self._fw_connection_status = Sensor.discrete( "fits-writer-connection-status", description="Status of the fits writer conenction", params=["Unmanaged", "Connected", "Unconnected"], default="Unmanaged", initial_status=Sensor.UNKNOWN) self.add_sensor(self._fw_connection_status) self._fw_packages_sent = Sensor.integer( "fw-sent-packages", description= "Number of packages sent to fits writer in this measurement", initial_status=Sensor.UNKNOWN) self.add_sensor(self._fw_packages_sent) self._fw_packages_dropped = Sensor.integer( "fw-dropped-packages", description= "Number of packages dropped by fits writer in this measurement", initial_status=Sensor.UNKNOWN) self.add_sensor(self._fw_packages_dropped) self._incomplete_heaps = Sensor.integer( "incomplete-heaps", description="Incomplete heaps received.", initial_status=Sensor.UNKNOWN) self.add_sensor(self._incomplete_heaps) self._complete_heaps = Sensor.integer( "complete-heaps", description="Complete heaps received.", initial_status=Sensor.UNKNOWN) self.add_sensor(self._complete_heaps) self._invalid_packages = Sensor.integer( "invalid-packages", description="Number of invalid packages dropped.", initial_status=Sensor.UNKNOWN) self.add_sensor(self._invalid_packages) self._bandpass = Sensor.string( "bandpass", description="band-pass data (base64 encoded)", initial_status=Sensor.UNKNOWN) self.add_sensor(self._bandpass)
def setup_sensors(self): """Set up basic monitoring sensors. """ for name, params in self._parser.items(): if params["type"] == "float": sensor = Sensor.float(name, description=params["description"], unit=params.get("units", None), default=params.get("default", 0.0), initial_status=Sensor.UNKNOWN) elif params["type"] == "string": sensor = Sensor.string(name, description=params["description"], default=params.get("default", ""), initial_status=Sensor.UNKNOWN) elif params["type"] == "int": sensor = Sensor.integer(name, description=params["description"], default=params.get("default", 0), unit=params.get("units", None), initial_status=Sensor.UNKNOWN) elif params["type"] == "bool": sensor = Sensor.boolean(name, description=params["description"], default=params.get("default", False), initial_status=Sensor.UNKNOWN) else: raise Exception("Unknown sensor type '{0}' requested".format( params["type"])) self.add_sensor(sensor)
def setup_sensors(self): """ @brief Setup monitoring sensors """ self._device_status_sensor = Sensor.discrete( "device-status", description="Health status of FIServer", params=self.DEVICE_STATUSES, default="ok", initial_status=Sensor.UNKNOWN) self.add_sensor(self._device_status_sensor) self._active_beams_sensor = Sensor.float( "nbeams", description="Number of beams that are currently active", default=1, initial_status=Sensor.UNKNOWN) self.add_sensor(self._active_beams_sensor) self._nchannels_sensor = Sensor.float( "nchannels", description="Number of channels in each beam", default=1, initial_status=Sensor.UNKNOWN) self.add_sensor(self._nchannels_sensor) self._integration_time_sensor = Sensor.float( "integration-time", description="The integration time for each beam", default=1, initial_status=Sensor.UNKNOWN) self.add_sensor(self._integration_time_sensor) self._nblank_phases_sensor = Sensor.integer( "nblank-phases", description="The number of blank phases", default=1, initial_status=Sensor.UNKNOWN) self.add_sensor(self._nblank_phases_sensor)
def setup_sensors(self): """ Setup monitoring sensors """ EDDPipeline.setup_sensors(self) self._spectra_written = Sensor.integer( "written-packages", description="Number of spectra written to file.", initial_status=Sensor.UNKNOWN) self.add_sensor(self._spectra_written) self._incomplete_heaps = Sensor.integer( "incomplete-heaps", description="Incomplete heaps received.", initial_status=Sensor.UNKNOWN) self.add_sensor(self._incomplete_heaps) self._complete_heaps = Sensor.integer( "complete-heaps", description="Complete heaps received.", initial_status=Sensor.UNKNOWN) self.add_sensor(self._complete_heaps) self._current_file = Sensor.string("current-file", description="Current filename.", initial_status=Sensor.UNKNOWN) self.add_sensor(self._current_file) self._current_file_size = Sensor.float("current-file-size", description="Current filesize.", initial_status=Sensor.UNKNOWN) self.add_sensor(self._current_file_size) self._bandpass = Sensor.string( "bandpass", description="band-pass data (base64 encoded)", initial_status=Sensor.UNKNOWN) self.add_sensor(self._bandpass)
def setup_sensors_beam(self, beam): b = str(beam) self._beam_sensors = {} self.script.log(2, "KATCPServer::setup_sensors_beam beam=" + b) self._beam_sensors["observing"] = Sensor.boolean("observing", description="Beam " + b + " is observing", unit="", default=0) self.add_sensor(self._beam_sensors["observing"]) self._beam_sensors["snr"] = Sensor.float("snr", description="SNR of Beam " + b, unit="", params=[0, 1e9], default=0) self.add_sensor(self._beam_sensors["snr"]) self._beam_sensors["beamformer_stddev_polh"] = Sensor.float( "beamformer_stddev_polh", description="Standard deviation of beam voltages for pol H", unit="", params=[0, 127], default=0) self.add_sensor(self._beam_sensors["beamformer_stddev_polh"]) self._beam_sensors["beamformer_stddev_polv"] = Sensor.float( "beamformer_stddev_polv", description="Standard deviation of beam voltages for pol V", unit="", params=[0, 127], default=0) self.add_sensor(self._beam_sensors["beamformer_stddev_polv"]) self._beam_sensors["integrated"] = Sensor.float( "integrated", description="Length of integration for Beam " + b, unit="", default=0) self.add_sensor(self._beam_sensors["integrated"]) self._beam_sensors["input_channels"] = Sensor.integer( "input_channels", description="Number of configured input channels for Beam " + b, unit="", default=0) self.add_sensor(self._beam_sensors["input_channels"])
def setup_sensors_beam (self, beam): b = str(beam) self._beam_sensors = {} self.script.log(2, "KATCPServer::setup_sensors_beam beam="+b) self._beam_sensors["observing"] = Sensor.boolean("observing", description="Beam " + b + " is observing", unit="", default=0) self.add_sensor(self._beam_sensors["observing"]) self._beam_sensors["snr"] = Sensor.float("snr", description="SNR of Beam "+b, unit="", params=[0,1e9], default=0) self.add_sensor(self._beam_sensors["snr"]) self._beam_sensors["beamformer_stddev_polh"] = Sensor.float("beamformer_stddev_polh", description="Standard deviation of beam voltages for pol H", unit="", params=[0,127], default=0) self.add_sensor(self._beam_sensors["beamformer_stddev_polh"]) self._beam_sensors["beamformer_stddev_polv"] = Sensor.float("beamformer_stddev_polv", description="Standard deviation of beam voltages for pol V", unit="", params=[0,127], default=0) self.add_sensor(self._beam_sensors["beamformer_stddev_polv"]) self._beam_sensors["integrated"] = Sensor.float("integrated", description="Length of integration for Beam "+b, unit="", default=0) self.add_sensor(self._beam_sensors["integrated"]) self._beam_sensors["input_channels"] = Sensor.integer("input_channels", description="Number of configured input channels for Beam "+b, unit="", default=0) self.add_sensor(self._beam_sensors["input_channels"])
def setup_sensors(self): """Set up basic monitoring sensors. """ for name, params in self._parser.items(): v = params.copy() v.pop('updater') if 'range' in v: v.pop('range') self.__eddDataStore.addTelescopeDataItem(name, v) if params["type"] == "float": sensor = Sensor.float(name, description=params["description"], unit=params.get("units", None), default=params.get("default", 0.0), initial_status=Sensor.UNKNOWN) elif params["type"] == "string": sensor = Sensor.string(name, description=params["description"], default=params.get("default", ""), initial_status=Sensor.UNKNOWN) elif params["type"] == "int": sensor = Sensor.integer(name, description=params["description"], default=params.get("default", 0), unit=params.get("units", None), initial_status=Sensor.UNKNOWN) elif params["type"] == "bool": sensor = Sensor.boolean(name, description=params["description"], default=params.get("default", False), initial_status=Sensor.UNKNOWN) else: raise Exception("Unknown sensor type '{0}' requested".format( params["type"])) self.add_sensor(sensor)
def setup_sensors_host (self, host, port): self.script.log(2, "KATCPServer::setup_sensors_host ("+host+","+port+")") sock = sockets.openSocket (DL, host, int(port), 1) if sock: self.script.log(2, "KATCPServer::setup_sensors_host sock.send(" + self.script.lmc_cmd + ")") sock.send (self.script.lmc_cmd + "\r\n") lmc_reply = sock.recv (65536) sock.close() xml = xmltodict.parse(lmc_reply) self._host_sensors = {} # Disk sensors self.script.log(2, "KATCPServer::setup_sensors_host configuring disk sensors") disk_prefix = host+".disk" self._host_sensors["disk_size"] = Sensor.float(disk_prefix+".size", description=host+": disk size", unit="MB", params=[8192,1e9], default=0) self._host_sensors["disk_available"] = Sensor.float(disk_prefix+".available", description=host+": disk available space", unit="MB", params=[1024,1e9], default=0) self.add_sensor(self._host_sensors["disk_size"]) self.add_sensor(self._host_sensors["disk_available"]) # Server Load sensors self.script.log(2, "KATCPServer::setup_sensors_host configuring load sensors") self._host_sensors["num_cores"] = Sensor.integer (host+".num_cores", description=host+": disk available space", unit="MB", params=[1,64], default=0) self._host_sensors["load1"] = Sensor.float(host+".load.1min", description=host+": 1 minute load ", unit="", default=0) self._host_sensors["load5"] = Sensor.float(host+".load.5min", description=host+": 5 minute load ", unit="", default=0) self._host_sensors["load15"] = Sensor.float(host+".load.15min", description=host+": 15 minute load ", unit="", default=0) self.add_sensor(self._host_sensors["num_cores"]) self.add_sensor(self._host_sensors["load1"]) self.add_sensor(self._host_sensors["load5"]) self.add_sensor(self._host_sensors["load15"]) cpu_temp_pattern = re.compile("cpu[0-9]+_temp") fan_speed_pattern = re.compile("fan[0-9,a-z]+") power_supply_pattern = re.compile("ps[0-9]+_status") self.script.log(2, "KATCPServer::setup_sensors_host configuring other metrics") if not xml["lmc_reply"]["sensors"] == None: for sensor in xml["lmc_reply"]["sensors"]["metric"]: name = sensor["@name"] if name == "system_temp": self._host_sensors[name] = Sensor.float((host+".system_temp"), description=host+": system temperature", unit="C", params=[-20,150], default=0) self.add_sensor(self._host_sensors[name]) if cpu_temp_pattern.match(name): (cpu, junk) = name.split("_") self._host_sensors[name] = Sensor.float((host+"." + name), description=host+": "+ cpu +" temperature", unit="C", params=[-20,150], default=0) self.add_sensor(self._host_sensors[name]) if fan_speed_pattern.match(name): self._host_sensors[name] = Sensor.float((host+"." + name), description=host+": "+name+" speed", unit="RPM", params=[0,20000], default=0) self.add_sensor(self._host_sensors[name]) if power_supply_pattern.match(name): self._host_sensors[name] = Sensor.boolean((host+"." + name), description=host+": "+name, unit="", default=0) self.add_sensor(self._host_sensors[name]) # TODO consider adding power supply sensors: e.g. # device-status-kronos1-powersupply1 # device-status-kronos1-powersupply2 # device-status-kronos2-powersupply1 # device-status-kronos2-powersupply2 # TODO consider adding raid/disk sensors: e.g. # device-status-<host>-raid # device-status-<host>-raid-disk1 # device-status-<host>-raid-disk2 self.script.log(2, "KATCPServer::setup_sensors_host done!") else: self.script.log(2, "KATCPServer::setup_sensors_host no sensors found") else: self.script.log(-2, "KATCPServer::setup_sensors_host: could not connect to LMC")
def setup_sensors(self): """ @brief Setup the default KATCP sensors. @note As this call is made only upon an FBFUSE configure call a mass inform is required to let connected clients know that the proxy interface has changed. """ self._state_sensor = LoggingSensor.discrete( "state", description = "Denotes the state of this FBF instance", params = self.STATES, default = self.IDLE, initial_status = Sensor.NOMINAL) self._state_sensor.set_logger(self.log) self.add_sensor(self._state_sensor) self._ca_address_sensor = Sensor.string( "configuration-authority", description = "The address of the server that will be deferred to for configurations", default = "", initial_status = Sensor.UNKNOWN) self.add_sensor(self._ca_address_sensor) self._available_antennas_sensor = Sensor.string( "available-antennas", description = "The antennas that are currently available for beamforming", default = json.dumps({antenna.name:antenna.format_katcp() for antenna in self._katpoint_antennas}), initial_status = Sensor.NOMINAL) self.add_sensor(self._available_antennas_sensor) self._phase_reference_sensor = Sensor.string( "phase-reference", description="A KATPOINT target string denoting the F-engine phasing centre", default="unset,radec,0,0", initial_status=Sensor.UNKNOWN) self.add_sensor(self._phase_reference_sensor) reference_antenna = Antenna("reference,{ref.lat},{ref.lon},{ref.elev}".format( ref=self._katpoint_antennas[0].ref_observer)) self._reference_antenna_sensor = Sensor.string( "reference-antenna", description="A KATPOINT antenna string denoting the reference antenna", default=reference_antenna.format_katcp(), initial_status=Sensor.NOMINAL) self.add_sensor(self._reference_antenna_sensor) self._bandwidth_sensor = Sensor.float( "bandwidth", description = "The bandwidth this product is configured to process", default = self._default_sb_config['bandwidth'], initial_status = Sensor.UNKNOWN) self.add_sensor(self._bandwidth_sensor) self._nchans_sensor = Sensor.integer( "nchannels", description = "The number of channels to be processesed", default = self._n_channels, initial_status = Sensor.UNKNOWN) self.add_sensor(self._nchans_sensor) self._cfreq_sensor = Sensor.float( "centre-frequency", description = "The centre frequency of the band this product configured to process", default = self._default_sb_config['centre-frequency'], initial_status = Sensor.UNKNOWN) self.add_sensor(self._cfreq_sensor) self._cbc_nbeams_sensor = Sensor.integer( "coherent-beam-count", description = "The number of coherent beams that this FBF instance can currently produce", default = self._default_sb_config['coherent-beams-nbeams'], initial_status = Sensor.UNKNOWN) self.add_sensor(self._cbc_nbeams_sensor) self._cbc_nbeams_per_group = Sensor.integer( "coherent-beam-count-per-group", description = "The number of coherent beams packed into a multicast group", default = 1, initial_status = Sensor.UNKNOWN) self.add_sensor(self._cbc_nbeams_per_group) self._cbc_ngroups = Sensor.integer( "coherent-beam-ngroups", description = "The number of multicast groups used for coherent beam transmission", default = 1, initial_status = Sensor.UNKNOWN) self.add_sensor(self._cbc_ngroups) self._cbc_nbeams_per_server_set = Sensor.integer( "coherent-beam-nbeams-per-server-set", description = "The number of beams produced by each server set", default = 1, initial_status = Sensor.UNKNOWN) self.add_sensor(self._cbc_nbeams_per_server_set) self._cbc_tscrunch_sensor = Sensor.integer( "coherent-beam-tscrunch", description = "The number time samples that will be integrated when producing coherent beams", default = self._default_sb_config['coherent-beams-tscrunch'], initial_status = Sensor.UNKNOWN) self.add_sensor(self._cbc_tscrunch_sensor) self._cbc_fscrunch_sensor = Sensor.integer( "coherent-beam-fscrunch", description = "The number frequency channels that will be integrated when producing coherent beams", default = self._default_sb_config['coherent-beams-fscrunch'], initial_status = Sensor.UNKNOWN) self.add_sensor(self._cbc_fscrunch_sensor) self._cbc_antennas_sensor = Sensor.string( "coherent-beam-antennas", description = "The antennas that will be used when producing coherent beams", default = self._default_sb_config['coherent-beams-antennas'], initial_status = Sensor.UNKNOWN) self.add_sensor(self._cbc_antennas_sensor) self._cbc_mcast_groups_sensor = Sensor.string( "coherent-beam-multicast-groups", description = "Multicast groups used by this instance for sending coherent beam data", default = "", initial_status = Sensor.UNKNOWN) self.add_sensor(self._cbc_mcast_groups_sensor) self._cbc_mcast_groups_mapping_sensor = Sensor.string( "coherent-beam-multicast-group-mapping", description = "Mapping of mutlicast group address to the coherent beams in that group", default= "", initial_status = Sensor.UNKNOWN) self.add_sensor(self._cbc_mcast_groups_mapping_sensor) self._ibc_nbeams_sensor = Sensor.integer( "incoherent-beam-count", description = "The number of incoherent beams that this FBF instance can currently produce", default = 1, initial_status = Sensor.UNKNOWN) self.add_sensor(self._ibc_nbeams_sensor) self._ibc_tscrunch_sensor = Sensor.integer( "incoherent-beam-tscrunch", description = "The number time samples that will be integrated when producing incoherent beams", default = self._default_sb_config['incoherent-beam-tscrunch'], initial_status = Sensor.UNKNOWN) self.add_sensor(self._ibc_tscrunch_sensor) self._ibc_fscrunch_sensor = Sensor.integer( "incoherent-beam-fscrunch", description = "The number frequency channels that will be integrated when producing incoherent beams", default = self._default_sb_config['incoherent-beam-fscrunch'], initial_status = Sensor.UNKNOWN) self.add_sensor(self._ibc_fscrunch_sensor) self._ibc_antennas_sensor = Sensor.string( "incoherent-beam-antennas", description = "The antennas that will be used when producing incoherent beams", default = self._default_sb_config['incoherent-beam-antennas'], initial_status = Sensor.UNKNOWN) self.add_sensor(self._ibc_antennas_sensor) self._ibc_mcast_group_sensor = Sensor.string( "incoherent-beam-multicast-group", description = "Multicast group used by this instance for sending incoherent beam data", default = "", initial_status = Sensor.UNKNOWN) self.add_sensor(self._ibc_mcast_group_sensor) self._servers_sensor = Sensor.string( "servers", description = "The worker server instances currently allocated to this product", default = ",".join(["{s.hostname}:{s.port}".format(s=server) for server in self._servers]), initial_status = Sensor.UNKNOWN) self.add_sensor(self._servers_sensor) self._nserver_sets_sensor = Sensor.integer( "nserver-sets", description = "The number of server sets (independent subscriptions to the F-engines)", default = 1, initial_status = Sensor.UNKNOWN) self.add_sensor(self._nserver_sets_sensor) self._nservers_per_set_sensor = Sensor.integer( "nservers-per-set", description = "The number of servers per server set", default = 1, initial_status = Sensor.UNKNOWN) self.add_sensor(self._nservers_per_set_sensor) self._delay_config_server_sensor = Sensor.string( "delay-config-server", description = "The address of the delay configuration server for this product", default = "", initial_status = Sensor.UNKNOWN) self.add_sensor(self._delay_config_server_sensor)
def setup_sensors(self): # Position sensors self._SCM_request_azim = Sensor.float("SCM.request-azim", "Sky-space requested azimuth position.", "Degrees CW of north") self.add_sensor(self._SCM_request_azim) self._SCM_request_elev = Sensor.float("SCM.request-elev", "Sky-space requested elevation position.", "Degrees CW of north") self.add_sensor(self._SCM_request_elev) self._SCM_desired_azim = Sensor.float("SCM.desired-azim", "Sky-space desired azimuth position.", "Degrees CW of north") self.add_sensor(self._SCM_desired_azim) self._SCM_desired_elev = Sensor.float("SCM.desired-elev", "Sky-space desired elevation position.", "Degrees CW of north") self.add_sensor(self._SCM_desired_elev) self._SCM_actual_azim = Sensor.float("SCM.actual-azim", "Sky-space actual azimuth position.", "Degrees CW of north") self.add_sensor(self._SCM_actual_azim) self._SCM_actual_elev = Sensor.float("SCM.actual-elev", "Sky-space actual elevation position.", "Degrees CW of north") self.add_sensor(self._SCM_actual_elev) # Pointing model self._SCM_pmodel1 = Sensor.float("SCM.pmodel1", "Pointing model parameter 1") self.add_sensor(self._SCM_pmodel1) self._SCM_pmodel2 = Sensor.float("SCM.pmodel2", "Pointing model parameter 2") self.add_sensor(self._SCM_pmodel2) self._SCM_pmodel3 = Sensor.float("SCM.pmodel3", "Pointing model parameter 3") self.add_sensor(self._SCM_pmodel3) self._SCM_pmodel4 = Sensor.float("SCM.pmodel4", "Pointing model parameter 4") self.add_sensor(self._SCM_pmodel4) self._SCM_pmodel5 = Sensor.float("SCM.pmodel5", "Pointing model parameter 5") self.add_sensor(self._SCM_pmodel5) self._SCM_pmodel6 = Sensor.float("SCM.pmodel6", "Pointing model parameter 6") self.add_sensor(self._SCM_pmodel6) self._SCM_pmodel7 = Sensor.float("SCM.pmodel7", "Pointing model parameter 7") self.add_sensor(self._SCM_pmodel7) self._SCM_pmodel8 = Sensor.float("SCM.pmodel8", "Pointing model parameter 8") self.add_sensor(self._SCM_pmodel8) self._SCM_pmodel9 = Sensor.float("SCM.pmodel9", "Pointing model parameter 9") self.add_sensor(self._SCM_pmodel9) self._SCM_pmodel10 = Sensor.float("SCM.pmodel10", "Pointing model parameter 10") self.add_sensor(self._SCM_pmodel10) self._SCM_pmodel11 = Sensor.float("SCM.pmodel11", "Pointing model parameter 11") self.add_sensor(self._SCM_pmodel11) self._SCM_pmodel12 = Sensor.float("SCM.pmodel12", "Pointing model parameter 12") self.add_sensor(self._SCM_pmodel12) self._SCM_pmodel13 = Sensor.float("SCM.pmodel13", "Pointing model parameter 13") self.add_sensor(self._SCM_pmodel13) self._SCM_pmodel14= Sensor.float("SCM.pmodel14", "Pointing model parameter 14") self.add_sensor(self._SCM_pmodel14) self._SCM_pmodel15= Sensor.float("SCM.pmodel15", "Pointing model parameter 15") self.add_sensor(self._SCM_pmodel15) self._SCM_pmodel16 = Sensor.float("SCM.pmodel16", "Pointing model parameter 16") self.add_sensor(self._SCM_pmodel16) self._SCM_pmodel17 = Sensor.float("SCM.pmodel17", "Pointing model parameter 17") self.add_sensor(self._SCM_pmodel17) self._SCM_pmodel18 = Sensor.float("SCM.pmodel18", "Pointing model parameter 18") self.add_sensor(self._SCM_pmodel18) self._SCM_pmodel19 = Sensor.float("SCM.pmodel19", "Pointing model parameter 19") self.add_sensor(self._SCM_pmodel19) self._SCM_pmodel20 = Sensor.float("SCM.pmodel20", "Pointing model parameter 20") self.add_sensor(self._SCM_pmodel20) self._SCM_pmodel21 = Sensor.float("SCM.pmodel21", "Pointing model parameter 21") self.add_sensor(self._SCM_pmodel21) self._SCM_pmodel22 = Sensor.float("SCM.pmodel22", "Pointing model parameter 22") self.add_sensor(self._SCM_pmodel22) self._SCM_pmodel23 = Sensor.float("SCM.pmodel23", "Pointing model parameter 23") self.add_sensor(self._SCM_pmodel23) self._SCM_pmodel24 = Sensor.float("SCM.pmodel24", "Pointing model parameter 24") self.add_sensor(self._SCM_pmodel24) self._SCM_pmodel25 = Sensor.float("SCM.pmodel25", "Pointing model parameter 25") self.add_sensor(self._SCM_pmodel25) self._SCM_pmodel26 = Sensor.float("SCM.pmodel26", "Pointing model parameter 26") self.add_sensor(self._SCM_pmodel26) self._SCM_pmodel27 = Sensor.float("SCM.pmodel27", "Pointing model parameter 27") self.add_sensor(self._SCM_pmodel27) self._SCM_pmodel28 = Sensor.float("SCM.pmodel28", "Pointing model parameter 28") self.add_sensor(self._SCM_pmodel28) self._SCM_pmodel29 = Sensor.float("SCM.pmodel29", "Pointing model parameter 29") self.add_sensor(self._SCM_pmodel29) self._SCM_pmodel30 = Sensor.float("SCM.pmodel30", "Pointing model parameter 30") self.add_sensor(self._SCM_pmodel30) # # Target self._SCM_Target = Sensor.string("SCM.Target", "Target description string in katpoint format") self.add_sensor(self._SCM_Target) # Antenna activity self._SCM_Antenna_Activity = Sensor.string("SCM.AntennaActivity", "Antenna activity label") self.add_sensor(self._SCM_Antenna_Activity) # RF sensor information self._SCM_LcpAttenuation = Sensor.float("SCM.LcpAttenuation", "Variable attenuator setting on LCP") self.add_sensor(self._SCM_LcpAttenuation) self._SCM_RcpAttenuation = Sensor.float("SCM.RcpAttenuation", "Variable attenuator setting on RCP") self.add_sensor(self._SCM_RcpAttenuation) self._RFC_LcpFreqSel = Sensor.boolean("RFC.LcpFreqSel", "LCP Frequency Select Switch") self.add_sensor(self._RFC_LcpFreqSel) self._RFC_RcpFreqSel = Sensor.boolean("RFC.RcpFreqSel", "RCP Frequency Select Switch") self.add_sensor(self._RFC_RcpFreqSel) self._RFC_IntermediateStage_5GHz = Sensor.float("RFC.IntermediateStage_5GHz", "5 GHz Intermediate Stage LO frequency") self.add_sensor(self._RFC_IntermediateStage_5GHz) self._RFC_IntermediateStage_6_7GHz = Sensor.float("RFC.IntermediateStage_6_7GHz", "6.7 GHz Intermediate Stage LO frequency") self.add_sensor(self._RFC_IntermediateStage_6_7GHz) self._RFC_FinalStage = Sensor.float("RFC.FinalStage", "Final Stage LO frequency") self.add_sensor(self._RFC_FinalStage) # Noise diode sensor information self._RFC_NoiseDiode_1 = Sensor.integer("RFC.NoiseDiode_1", "All noise diode data (bitfield)") self.add_sensor(self._RFC_NoiseDiode_1) # EMS information self._EMS_WindDirection = Sensor.float("EMS.WindDirection", "Wind direction") self.add_sensor(self._EMS_WindDirection) self._EMS_WindSpeed = Sensor.float("EMS.WindSpeed", "Wind speed") self.add_sensor(self._EMS_WindSpeed) self._EMS_AirTemperature = Sensor.float("EMS.AirTemperature", "Air temperature") self.add_sensor(self._EMS_AirTemperature) self._EMS_AbsolutePressure = Sensor.float("EMS.AbsolutePressure", "Air pressure") self.add_sensor(self._EMS_AbsolutePressure) self._EMS_RelativeHumidity = Sensor.float("EMS.RelativeHumidity", "Ambient relative humidity") self.add_sensor(self._EMS_RelativeHumidity) self.animation_thread = threading.Thread(target=self.sensor_value_thread_function) self.animation_thread.start()
def setup_sensors_host (self, host, port): self.script.log(1, "KATCPServer::setup_sensors_host ("+host+","+port+")") sock = sockets.openSocket (DL, host, int(port), 1) if sock: self.script.log(2, "KATCPServer::setup_sensors_host sock.send(" + self.script.lmc_cmd + ")") sock.send (self.script.lmc_cmd + "\r\n") lmc_reply = sock.recv (65536) sock.close() xml = xmltodict.parse(lmc_reply) self.script.log(2, "KATCPServer::setup_sensors_host sock.recv=" + str(xml)) self._host_sensors = {} # Disk sensors self.script.log(2, "KATCPServer::setup_sensors_host configuring disk sensors") disk_prefix = host+".disk" self._host_sensors["disk_size"] = Sensor.float(disk_prefix+".size", description=host+": disk size", unit="MB", params=[8192,1e9], default=0) self._host_sensors["disk_available"] = Sensor.float(disk_prefix+".available", description=host+": disk available space", unit="MB", params=[1024,1e9], default=0) self.add_sensor(self._host_sensors["disk_size"]) self.add_sensor(self._host_sensors["disk_available"]) # Server Load sensors self.script.log(2, "KATCPServer::setup_sensors_host configuring load sensors") self._host_sensors["num_cores"] = Sensor.integer (host+".num_cores", description=host+": disk available space", unit="MB", params=[1,64], default=0) self._host_sensors["load1"] = Sensor.float(host+".load.1min", description=host+": 1 minute load ", unit="", default=0) self._host_sensors["load5"] = Sensor.float(host+".load.5min", description=host+": 5 minute load ", unit="", default=0) self._host_sensors["load15"] = Sensor.float(host+".load.15min", description=host+": 15 minute load ", unit="", default=0) self._host_sensors["local_time_synced"] = Sensor.boolean("local_time_synced", description=host+": NTP server synchronisation", unit="", default=0) self.add_sensor(self._host_sensors["num_cores"]) self.add_sensor(self._host_sensors["num_cores"]) self.add_sensor(self._host_sensors["load1"]) self.add_sensor(self._host_sensors["load5"]) self.add_sensor(self._host_sensors["load15"]) self.add_sensor(self._host_sensors["local_time_synced"]) cpu_temp_pattern = re.compile("cpu[0-9]+_temp") fan_speed_pattern = re.compile("fan[0-9,a-z]+") power_supply_pattern = re.compile("ps[0-9]+_status") self.script.log(2, "KATCPServer::setup_sensors_host configuring other metrics") if not xml["lmc_reply"]["sensors"] == None: for sensor in xml["lmc_reply"]["sensors"]["metric"]: name = sensor["@name"] if name == "system_temp": self._host_sensors[name] = Sensor.float((host+".system_temp"), description=host+": system temperature", unit="C", params=[-20,150], default=0) self.add_sensor(self._host_sensors[name]) if cpu_temp_pattern.match(name): (cpu, junk) = name.split("_") self._host_sensors[name] = Sensor.float((host+"." + name), description=host+": "+ cpu +" temperature", unit="C", params=[-20,150], default=0) self.add_sensor(self._host_sensors[name]) if fan_speed_pattern.match(name): self._host_sensors[name] = Sensor.float((host+"." + name), description=host+": "+name+" speed", unit="RPM", params=[0,20000], default=0) self.add_sensor(self._host_sensors[name]) if power_supply_pattern.match(name): self._host_sensors[name] = Sensor.boolean((host+"." + name), description=host+": "+name, unit="", default=0) self.add_sensor(self._host_sensors[name]) # TODO consider adding power supply sensors: e.g. # device-status-kronos1-powersupply1 # device-status-kronos1-powersupply2 # device-status-kronos2-powersupply1 # device-status-kronos2-powersupply2 # TODO consider adding raid/disk sensors: e.g. # device-status-<host>-raid # device-status-<host>-raid-disk1 # device-status-<host>-raid-disk2 self.script.log(2, "KATCPServer::setup_sensors_host done!") else: self.script.log(2, "KATCPServer::setup_sensors_host no sensors found") else: self.script.log(-2, "KATCPServer::setup_sensors_host: could not connect to LMC")