check the status of the specified sensor
332444
def check_sensor(self, helper):
        
        try:
            sensor_name, sensor_state, sensor_type = self.sess.get_oids(
                self.oids['oid_sensor_name'], self.oids['oid_sensor_state'], self.oids['oid_sensor_type'])
        except health_monitoring_plugins.SnmpException as e:
            helper.exit(summary=str(e), exit_code=unknown, perfdata='')

        try:
            sensor_state_string = states[int(sensor_state)]
        except KeyError as e:
            helper.exit(summary="Invalid sensor response " + sensor_state, exit_code=unknown, perfdata='')
        sensor_unit = "" # if it's a onOff Sensor or something like that, we need an empty string for the summary
        sensor_unit_string = ""
        sensor_value = ""
        sensor_digit = ""
        real_sensor_value = ""
        sensor_warning_upper = ""
        sensor_critical_upper = ""
        sensor_warning_lower = ""
        sensor_critical_lower = ""

        if int(sensor_type) not in [14, 16, 17, 18, 19, 20]:
            # for all sensors except these, we want to calculate the real value and show the metric.
            # 14: onOff
            # 16: vibration
            # 17: waterDetection
            # 18: smokeDetection
            # 19: binary
            # 20: contact
            try:
                sensor_unit, sensor_digit, sensor_warning_upper, sensor_critical_upper, sensor_warning_lower, sensor_critical_lower, sensor_value = self.sess.get_oids(
                    self.oids['oid_sensor_unit'], self.oids['oid_sensor_digit'],
                    self.oids['oid_sensor_warning_upper'], self.oids['oid_sensor_critical_upper'],
                    self.oids['oid_sensor_warning_lower'], self.oids['oid_sensor_critical_lower'],
                    self.oids['oid_sensor_value'])
            except health_monitoring_plugins.SnmpException as e:
                helper.exit(summary=str(e), exit_code=unknown, perfdata='')

            sensor_unit_string          = units[int(sensor_unit)]
            real_sensor_value           = real_value(int(sensor_value), sensor_digit)
            real_sensor_warning_upper   = real_value(sensor_warning_upper, sensor_digit)
            real_sensor_critical_upper  = real_value(sensor_critical_upper, sensor_digit)
            real_sensor_warning_lower   = real_value(sensor_warning_lower, sensor_digit)
            real_sensor_critical_lower  = real_value(sensor_critical_lower, sensor_digit)
            # metrics are only possible for these sensors
            helper.add_metric(sensor_name + " -%s- " % sensor_unit_string, real_sensor_value,
                              real_sensor_warning_lower +\
                              ":" + real_sensor_warning_upper, real_sensor_critical_lower +\
                              ":" + real_sensor_critical_upper, "", "", "")

        # "OK" state
        if sensor_state_string in ["closed", "normal", "on", "notDetected", "ok", "yes", "one", "two", "inSync"]:
            helper.status(ok)

        # "WARNING" state
        elif sensor_state_string in ["open", "belowLowerWarning", "aboveUpperWarning", "marginal", "standby"]:
            helper.status(warning)

        # "CRITICAL" state
        elif sensor_state_string in ["belowLowerCritical", "aboveUpperCritical", "off", "detected", "alarmed", "fail", "no", "outOfSync"]:
            helper.status(critical)

        # "UNKOWN" state    
        elif sensor_state_string in ["unavailable"]:
            helper.status(unknown)

        # received an undefined state    
        else:
            helper.exit(summary="Something went wrong - received undefined state", exit_code=unknown, perfdata='')

        # summary is shown for all sensors
        helper.add_summary("Sensor %s - '%s' %s%s is: %s" % (self.number, sensor_name, real_sensor_value, sensor_unit_string, sensor_state_string))
56550
function SensorCheck(sensorRootObj) {

	var promise = new Promise(function(resolve, reject) {

		var runCheck = function (tries) {

			setTimeout(function() {

				if (sensorRootObj && sensorRootObj.data) {

					resolve();

				} else if (tries >= 20) {

					reject();

				} else {

					runCheck(++tries);

				}

			}, 50);

		};

		runCheck(0);

	});

	return promise;

}
1069282
def process_status(self, helper, session, check):
        """""""
        snmp_result_status = helper.get_snmp_value(session, helper, DEVICE_GLOBAL_OIDS['oid_' + check])

        if check == "system_lcd":
            helper.update_status(helper, normal_check("global", snmp_result_status, "LCD status"))
        elif check == "global_storage":
            helper.update_status(helper, normal_check("global", snmp_result_status, "Storage status"))
        elif check == "system_power":
            helper.update_status(helper, self.check_system_power_status(snmp_result_status))
        elif check == "global_system":
            helper.update_status(helper,
                                 normal_check("global", snmp_result_status, "Device status"))
737763
def check_status(self, **kwargs):
        
        for work in self:
            work.check_status()

        if kwargs.pop("show", False):
            self.show_status(**kwargs)
102087
def check(self):
        """"""

        if len(self.status_datasets) == 0:
            return False
        if all(self.status_datasets):
            return True
        return False
754785
def probe_check(name, status, device_type):
    """"""
    status_string = PROBE_STATE.get(int(status), "unknown")

    if status_string == "ok":
        return ok, "{} '{}': {}".format(device_type, name, status_string)

    if status_string == "unknown":
        return unknown, "{} '{}': {}".format(device_type, name, status_string)

    return critical, "{} '{}': {}".format(device_type, name, status_string)
786433
def status(self):
        ''''''
        message = self.status_message
        if message is None:
            message = STATUS[self.status_code]
        return '%s %s' % (self.status_code, message)
1204374
def normal_check(name, status, device_type):
    """"""
    status_string = NORMAL_STATE.get(int(status), "unknown")

    if status_string == "ok":
        return ok, "{} '{}': {}".format(device_type, name, status_string)

    elif status_string == "unknown":
        return unknown, "{} '{}': {}".format(device_type, name, status_string)

    return critical, "{} '{}': {}".format(device_type, name, status_string)
1358334
def read_sensor(self, device_id, sensor_uri):
        """"""
        url = MINUT_DEVICES_URL + "/{device_id}/{sensor_uri}".format(
            device_id=device_id, sensor_uri=sensor_uri)
        res = self._request(url, request_type='GET', data={'limit': 1})
        if not res.get('values'):
            return None
        return res.get('values')[-1].get('value')
1224235
def check_sensors():
    

    all_sensors = walk_data(sess, oid_description, helper)[0]
    all_status = walk_data(sess, oid_status, helper)[0]

    # here we zip all index and descriptions to have a list like
    # [('Fan Sensor', '2'), ('Power Supply Sensor', '4')]
    # we are doomed if the lists do not have the same length ...  but that should never happen ... hopefully
    zipped = zip(all_sensors, all_status)

    for sensor in zipped:
        description = sensor[0]
        status = sensor[1]
        # translate the value to human readable
        try:
            status_string = senor_status_table[status]
        except KeyError:
            # if we receive an invalid value, we don't want to crash... 
            helper.exit(summary="received an undefined value from device: " + status, exit_code=unknown, perfdata='')

        # for each sensor the summary is added like: Fan Sensor: good
        helper.add_summary("%s: %s" % (description, status_string))

        # set the status
        if status == "2":
            helper.status(critical)
        if status == "3":
            helper.status(warning)
834906
def get(self, sensor_type='temperature_core'):
        """"""
        self.__update__()
        if sensor_type == 'temperature_core':
            ret = [s for s in self.sensors_list if s['unit'] == SENSOR_TEMP_UNIT]
        elif sensor_type == 'fan_speed':
            ret = [s for s in self.sensors_list if s['unit'] == SENSOR_FAN_UNIT]
        else:
            # Unknown type
            logger.debug("Unknown sensor type %s" % sensor_type)
            ret = []
        return ret
971612
def is_sensor(self, sensorid, child_id=None):
        """"""
        ret = sensorid in self.sensors
        if not ret:
            _LOGGER.warning('Node %s is unknown', sensorid)
        if ret and child_id is not None:
            ret = child_id in self.sensors[sensorid].children
            if not ret:
                _LOGGER.warning('Child %s is unknown', child_id)
        if not ret and parse_ver(self.protocol_version) >= parse_ver('2.0'):
            _LOGGER.info('Requesting new presentation for node %s',
                         sensorid)
            msg = Message(gateway=self).modify(
                node_id=sensorid, child_id=SYSTEM_CHILD_ID,
                type=self.const.MessageType.internal,
                sub_type=self.const.Internal.I_PRESENTATION)
            if self._route_message(msg):
                self.add_job(msg.encode)
        return ret
1224285
def get_device_status(self, t):
        ''''''
        data = {}
        for name, (func, _, _) in self.addons.iteritems():
            data[name] = func(t)
        return data
481733
def status(self, obj):
        """"""

        data_size = DWORD()
        data = PDWORD()
        opcode_value_type = DWORD()
        self._wlan_query_interface(self._handle, obj['guid'], 6,
                                   byref(data_size), byref(data),
                                   byref(opcode_value_type))

        return status_dict[data.contents.value]
518661
def get_status(self):
    
    self.__update_state()
    if self._state.active:
      return self.RUNNING
    else:
      return self._state.result_status
460116
def status(self, obj):
        """"""

        reply = self._send_cmd_to_wpas(obj['name'], 'STATUS', True)
        result = reply.split('\n')

        status = ''
        for l in result:
            if l.startswith('wpa_state='):
                status = l[10:]
                return status_dict[status.lower()]
177553
def status(self, message, *args, **kwargs):
    """"""
    if self.isEnabledFor(GNUPG_STATUS_LEVEL):
        self._log(GNUPG_STATUS_LEVEL, message, args, **kwargs)